Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

instantremainder_widget.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. var Unibase;
  2. (function (Unibase) {
  3. let Platform;
  4. (function (Platform) {
  5. let Communications;
  6. (function (Communications) {
  7. let Components;
  8. (function (Components) {
  9. class InstantReminders_Widget extends Platform.Core.BaseComponent {
  10. constructor() {
  11. super(...arguments);
  12. this.instantReminderId = 0;
  13. this.isduplicate = true;
  14. }
  15. cssFiles() {
  16. return [];
  17. }
  18. jsFiles() {
  19. return ["platform/communications/managers/reminders/remindermanager.js", "platform/communications/requests/reminders/instantreminder.js", "platform/communications/infos/reminders/instantreminder.js", "platform/communications/requests/reminders/instantreminder.js", "libs/jquery/pagination/jquery.pagination.js", "platform/communications/enums/reminders/instantreminderstatus.js"];
  20. }
  21. html(id, containerid) {
  22. var html = `<form id="frmUnibase_ActionsData" data-validate="parsley" data-isdynamic="false">
  23. <div class="card bg-light">
  24. <div class="b-b bg-white card-header header">
  25. <span class="record_count"><b>Count:</b><span class="badge-light badge rounded ml-1 mb-1" id="response_count">0</span></span>
  26. <span class="isDuplicate mr-10"><input type="radio" name="instantreminder_option" class="isduplicate mr-1">Isduplicate</span>
  27. <span class="data mr-10"><input type="radio" name="instantreminder_option" class="isunique" >IsUnique</span>
  28. </div>
  29. <div class="card-body scrollable" style="overflow-y: scroll;">
  30. <div class="row">
  31. <table class="table">
  32. <thead>
  33. <tr id="Reminders_Row" class="bg-primary">
  34. </tr>
  35. </thead>
  36. <tbody class="ActionsDatalist_body"></tbody>
  37. </table>
  38. </div>
  39. </div>
  40. <div class="bg-white card-footer footer" id="instantreminder_footer">
  41. <a href="javascript:;" id="btnCloseInstantreminder" class="btn btn-light btn-sm mr-auto "> Close</a><div class="pagination pagination-rounded custom-pagination mb-2" id="divpagination"></div>
  42. </div>
  43. </div>
  44. </form>`;
  45. return html;
  46. }
  47. load(id, containerid, callback) {
  48. $('#btnCloseInstantreminder').click(function () {
  49. $('#' + containerid).modal('hide');
  50. $('#' + containerid).remove();
  51. });
  52. $('input[name="instantreminder_option"]').change(function () {
  53. var isduplicate = $('.isduplicate').is(":checked");
  54. Unibase.Platform.Communications.Managers.ReminderManager.Instance().updateIsDuplicate(InstantReminders_Widget.Instance().instantReminderId, isduplicate).then(function (response) {
  55. if (response.result != null) {
  56. InstantReminders_Widget.Instance().isduplicate = response.result;
  57. MessageHelper.Instance().showSuccess(response.message, "message_div");
  58. $('.ActionsDatalist_body').html('');
  59. Unibase.Platform.Communications.Managers.ReminderManager.Instance().getRecipients(InstantReminders_Widget.Instance().instantReminderId, response.result).then(function (response) {
  60. if (response.result != null) {
  61. Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loadrecipients(response.result);
  62. }
  63. });
  64. }
  65. });
  66. });
  67. if (InstantReminders_Widget.Instance().isduplicate) {
  68. $('.isduplicate').prop("checked", true);
  69. }
  70. else {
  71. $('.isunique').prop("checked", true);
  72. }
  73. }
  74. init(containerid) {
  75. if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
  76. for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
  77. if (obj.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_recordid") {
  78. InstantReminders_Widget.Instance().instantReminderId = Number(obj.Value);
  79. }
  80. }
  81. }
  82. Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loadJsFiles();
  83. Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().render(containerid);
  84. }
  85. render(containerid) {
  86. var html = `<div class="instantremainders"><div id="message_div"></div>
  87. <div class="bg-white card-header"><div class"remainder_datails mb-7 text-dark">
  88. <b>Reminder Details</b></div><table class="table">
  89. <thead style="background-color:#a1a1a1"><tr><th><b>Subject</b></th><th><b>Body</b>
  90. </th><th><b>Recipients</b></th><th></th></tr></thead><tbody class="card-body">
  91. </tbody></div></div>`;
  92. $("." + containerid).append(html);
  93. Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loaddetails(InstantReminders_Widget.Instance().instantReminderId);
  94. }
  95. loaddetails(instantreminderid) {
  96. Unibase.Platform.Communications.Managers.ReminderManager.Instance().getInstantReminder(instantreminderid).then(function (response) {
  97. if (response.result != null) {
  98. InstantReminders_Widget.Instance().isduplicate = response.result.IsDuplicate;
  99. var html = '<tr><td>' + response.result.Subject + '</td><td>' + response.result.Body + '</td><td><a href="#"onclick="Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loadpopup();">Recipients</a></td><td><span class="badge send_btn hidden pull-right" onclick="Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().sendReminder(' + InstantReminders_Widget.Instance().instantReminderId + ')" style="background-color:#00B0FF;color:#e9e8e8;cursor:pointer">Send</span></td></tr>';
  100. $('.card-body').html(html);
  101. if (response.result.ReminderStatus == Number(Unibase.Platform.Communications.Enums.InstantReminderStatus.Draft)) {
  102. $('.send_btn').removeClass('hidden');
  103. }
  104. }
  105. });
  106. }
  107. loadpopup(containerid) {
  108. this.navigationHelper.popup(InstantReminders_Widget.Instance().instantReminderId, containerid, Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance(), null, null);
  109. Unibase.Platform.Communications.Managers.ReminderManager.Instance().getRecipients(InstantReminders_Widget.instance.instantReminderId, InstantReminders_Widget.Instance().isduplicate).then(function (response) {
  110. if (response.result != null) {
  111. Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loadrecipients(response.result);
  112. }
  113. });
  114. }
  115. loadrecipients(response) {
  116. var properties = Object.getOwnPropertyNames(response[0]);
  117. var headerhtml = '';
  118. for (let j = 0; j < properties.length; j++) {
  119. headerhtml += '<th>' + properties[j] + '</th>';
  120. }
  121. headerhtml = '<th>S.no</th>' + headerhtml;
  122. $('#Reminders_Row').html(headerhtml);
  123. $('#response_count').text(response.length);
  124. Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loaddata(0, response, properties);
  125. var ele;
  126. ele = $('#divpagination');
  127. ele.pagination(response.length, 10, {
  128. current_page: 0,
  129. callback: function (page, component) {
  130. Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loaddata(page, response, properties);
  131. }
  132. });
  133. }
  134. loaddata(page, response, properties) {
  135. $('.ActionsDatalist_body').html('');
  136. var len = (page + 1) * 10;
  137. var initialval = len - 10;
  138. var html = '';
  139. for (let i = initialval; i < len; i++) {
  140. if (response.length > i) {
  141. var innerhtml = '';
  142. for (let j = 0; j < properties.length; j++) {
  143. innerhtml += '<td>' + response[i][properties[j]] + '</td>';
  144. }
  145. html += '<tr><td>' + (i + 1) + '</td>' + innerhtml + '</tr>';
  146. }
  147. else {
  148. break;
  149. }
  150. }
  151. $('.ActionsDatalist_body').html(html);
  152. }
  153. loadJsFiles() {
  154. var jsfiles = Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().jsFiles();
  155. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(jsfiles, function () {
  156. });
  157. }
  158. sendReminder(instantReminderId) {
  159. var instantReminder = new Unibase.Platform.Communications.Requests.InstantReminder();
  160. instantReminder.InstantReminderId = instantReminderId;
  161. instantReminder.ReminderStatus = Number(Unibase.Platform.Communications.Enums.InstantReminderStatus.Active);
  162. Unibase.Platform.Communications.Managers.ReminderManager.Instance().sendInstantReminder(instantReminder).then(function (response) {
  163. $('.send_btn').addClass('d-none');
  164. });
  165. }
  166. static Instance() {
  167. if (this.instance == undefined) {
  168. this.instance = new InstantReminders_Widget();
  169. }
  170. return this.instance;
  171. }
  172. }
  173. Components.InstantReminders_Widget = InstantReminders_Widget;
  174. })(Components = Communications.Components || (Communications.Components = {}));
  175. })(Communications = Platform.Communications || (Platform.Communications = {}));
  176. })(Platform = Unibase.Platform || (Unibase.Platform = {}));
  177. })(Unibase || (Unibase = {}));