123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- var Unibase;
- (function (Unibase) {
- let Platform;
- (function (Platform) {
- let Communications;
- (function (Communications) {
- let Components;
- (function (Components) {
- class InstantReminders_Widget extends Platform.Core.BaseComponent {
- constructor() {
- super(...arguments);
- this.instantReminderId = 0;
- this.isduplicate = true;
- }
- cssFiles() {
- return [];
- }
- jsFiles() {
- 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"];
- }
- html(id, containerid) {
- var html = `<form id="frmUnibase_ActionsData" data-validate="parsley" data-isdynamic="false">
- <div class="card bg-light">
- <div class="b-b bg-white card-header header">
- <span class="record_count"><b>Count:</b><span class="badge-light badge rounded ml-1 mb-1" id="response_count">0</span></span>
- <span class="isDuplicate mr-10"><input type="radio" name="instantreminder_option" class="isduplicate mr-1">Isduplicate</span>
- <span class="data mr-10"><input type="radio" name="instantreminder_option" class="isunique" >IsUnique</span>
- </div>
- <div class="card-body scrollable" style="overflow-y: scroll;">
- <div class="row">
- <table class="table">
- <thead>
- <tr id="Reminders_Row" class="bg-primary">
- </tr>
- </thead>
- <tbody class="ActionsDatalist_body"></tbody>
- </table>
- </div>
- </div>
- <div class="bg-white card-footer footer" id="instantreminder_footer">
- <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>
- </div>
- </div>
- </form>`;
- return html;
- }
- load(id, containerid, callback) {
- $('#btnCloseInstantreminder').click(function () {
- $('#' + containerid).modal('hide');
- $('#' + containerid).remove();
- });
- $('input[name="instantreminder_option"]').change(function () {
- var isduplicate = $('.isduplicate').is(":checked");
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().updateIsDuplicate(InstantReminders_Widget.Instance().instantReminderId, isduplicate).then(function (response) {
- if (response.result != null) {
- InstantReminders_Widget.Instance().isduplicate = response.result;
- MessageHelper.Instance().showSuccess(response.message, "message_div");
- $('.ActionsDatalist_body').html('');
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().getRecipients(InstantReminders_Widget.Instance().instantReminderId, response.result).then(function (response) {
- if (response.result != null) {
- Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loadrecipients(response.result);
- }
- });
- }
- });
- });
- if (InstantReminders_Widget.Instance().isduplicate) {
- $('.isduplicate').prop("checked", true);
- }
- else {
- $('.isunique').prop("checked", true);
- }
- }
- init(containerid) {
- if (Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.length > 0) {
- for (let obj of Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters) {
- if (obj.Key === "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_recordid") {
- InstantReminders_Widget.Instance().instantReminderId = Number(obj.Value);
- }
- }
- }
- Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loadJsFiles();
- Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().render(containerid);
- }
- render(containerid) {
- var html = `<div class="instantremainders"><div id="message_div"></div>
- <div class="bg-white card-header"><div class"remainder_datails mb-7 text-dark">
- <b>Reminder Details</b></div><table class="table">
- <thead style="background-color:#a1a1a1"><tr><th><b>Subject</b></th><th><b>Body</b>
- </th><th><b>Recipients</b></th><th></th></tr></thead><tbody class="card-body">
- </tbody></div></div>`;
- $("." + containerid).append(html);
- Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loaddetails(InstantReminders_Widget.Instance().instantReminderId);
- }
- loaddetails(instantreminderid) {
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().getInstantReminder(instantreminderid).then(function (response) {
- if (response.result != null) {
- InstantReminders_Widget.Instance().isduplicate = response.result.IsDuplicate;
- 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>';
- $('.card-body').html(html);
- if (response.result.ReminderStatus == Number(Unibase.Platform.Communications.Enums.InstantReminderStatus.Draft)) {
- $('.send_btn').removeClass('hidden');
- }
- }
- });
- }
- loadpopup(containerid) {
- this.navigationHelper.popup(InstantReminders_Widget.Instance().instantReminderId, containerid, Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance(), null, null);
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().getRecipients(InstantReminders_Widget.instance.instantReminderId, InstantReminders_Widget.Instance().isduplicate).then(function (response) {
- if (response.result != null) {
- Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loadrecipients(response.result);
- }
- });
- }
- loadrecipients(response) {
- var properties = Object.getOwnPropertyNames(response[0]);
- var headerhtml = '';
- for (let j = 0; j < properties.length; j++) {
- headerhtml += '<th>' + properties[j] + '</th>';
- }
- headerhtml = '<th>S.no</th>' + headerhtml;
- $('#Reminders_Row').html(headerhtml);
- $('#response_count').text(response.length);
- Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loaddata(0, response, properties);
- var ele;
- ele = $('#divpagination');
- ele.pagination(response.length, 10, {
- current_page: 0,
- callback: function (page, component) {
- Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().loaddata(page, response, properties);
- }
- });
- }
- loaddata(page, response, properties) {
- $('.ActionsDatalist_body').html('');
- var len = (page + 1) * 10;
- var initialval = len - 10;
- var html = '';
- for (let i = initialval; i < len; i++) {
- if (response.length > i) {
- var innerhtml = '';
- for (let j = 0; j < properties.length; j++) {
- innerhtml += '<td>' + response[i][properties[j]] + '</td>';
- }
- html += '<tr><td>' + (i + 1) + '</td>' + innerhtml + '</tr>';
- }
- else {
- break;
- }
- }
- $('.ActionsDatalist_body').html(html);
- }
- loadJsFiles() {
- var jsfiles = Unibase.Platform.Communications.Components.InstantReminders_Widget.Instance().jsFiles();
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(jsfiles, function () {
- });
- }
- sendReminder(instantReminderId) {
- var instantReminder = new Unibase.Platform.Communications.Requests.InstantReminder();
- instantReminder.InstantReminderId = instantReminderId;
- instantReminder.ReminderStatus = Number(Unibase.Platform.Communications.Enums.InstantReminderStatus.Active);
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().sendInstantReminder(instantReminder).then(function (response) {
- $('.send_btn').addClass('d-none');
- });
- }
- static Instance() {
- if (this.instance == undefined) {
- this.instance = new InstantReminders_Widget();
- }
- return this.instance;
- }
- }
- Components.InstantReminders_Widget = InstantReminders_Widget;
- })(Components = Communications.Components || (Communications.Components = {}));
- })(Communications = Platform.Communications || (Platform.Communications = {}));
- })(Platform = Unibase.Platform || (Unibase.Platform = {}));
- })(Unibase || (Unibase = {}));
|