123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804 |
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var Unibase;
- (function (Unibase) {
- let Themes;
- (function (Themes) {
- let Compact;
- (function (Compact) {
- let Components;
- (function (Components) {
- class Notification extends Unibase.Platform.Core.BaseComponent {
- static Instance() {
- return new Notification();
- }
- init(containerid) {
- Unibase.Themes.Compact.Components.Notification.containerid = containerid;
- Unibase.Themes.Compact.Components.Notification.Instance().GetUnreadRemindersCount();
- let remindersuniqueid = "Unibase_Platform_Communications_Reminders_App_Reminders";
- Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId(remindersuniqueid).then(function (response) {
- if (response.result != null) {
- Unibase.Themes.Compact.Components.Notification.ReminderAppid = response.result.InstalledAppId;
- }
- });
- let taskremindersuniqueid = "Unibase_Platform_Communications_Reminders_App_TaskReminders";
- Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId(taskremindersuniqueid).then(function (response) {
- if (response.result != null) {
- Unibase.Themes.Compact.Components.Notification.TaskReminderAppid = response.result.InstalledAppId;
- }
- });
- $("#Active_Process").click(function () {
- $("#Active_Process").addClass("active");
- $("#Active_Notification").removeClass("active");
- $("#Active_Tasks").removeClass("active");
- $(".Reminders").remove();
- Unibase.Themes.Compact.Components.Notification.Instance().GetRunnningProcess();
- });
- }
- tabView(id) {
- var viewallbtn = `<a class="btn btn-outline-primary mr-auto ml-auto px-3 py-1" href="javascript:;" onclick="Unibase.Themes.Compact.Components.Notification.Instance().ViewAll(6)" id="AddWidget_btnCreateWidget">View All</a>`;
- var viewallbtntask = `<a class="btn btn-outline-primary mr-auto ml-auto px-3 py-1" onclick="Unibase.Themes.Compact.Components.Notification.Instance().ViewAll(1)" href="javascript:;" id="AddWidget_btnCreateWidget">View All</a>`;
- let instance = this;
- $('.tab-view').removeClass('biz-notification-mobile-view border');
- $("#" + id).addClass('biz-notification-mobile-view border-0');
- if (id == 'notification-tab') {
- Unibase.Themes.Compact.Components.Notification.Instance().loadReminders('tab-view');
- $(".biz-settings-panel").css("background", "#fff9f9");
- }
- if (id == 'task-tab') {
- $('.clearall-checkbox').addClass('d-none');
- $('.clear_alldiv').addClass('d-none');
- Unibase.Themes.Compact.Components.Notification.Instance().loadTasks('tab-view');
- $(".biz-settings-panel").css("background", "#fff9f9");
- $(".notification-footer").html(viewallbtntask);
- }
- else {
- if (Unibase.Themes.Compact.Components.Notification.UnReadNotificationsCount == 0) {
- $('.clearall-checkbox').addClass('d-none');
- $('.clear_alldiv').addClass('d-none');
- }
- else {
- $('.clearall-checkbox').removeClass('d-none');
- $('.clear_alldiv').removeClass('d-none');
- }
- $(".biz-settings-panel").css("background", "#f7fbff");
- $(".notification-footer").html(viewallbtn);
- if ($('#notificationTabView .rem-item-wrap').length) {
- $(".notification-footer").removeClass('d-none');
- }
- else {
- $(".notification-footer").addClass('d-none');
- }
- }
- }
- loadNotificationsTask(html, tabType, binding) {
- let tabViewHeaderHTML = `
- <ul class="nav nav-tabs border-0 text-center mr-auto" id="myTab" role="tablist">
- <li class="nav-item task-litab">
- <a class="nav-link tab-view active biz-notification-mobile-view border-0" id="task-tab" data-toggle="tab" href="#taskTabView" id="task-tab" onclick="Unibase.Themes.Compact.Components.Notification.Instance().tabView('task-tab')" role="tab" aria-controls="profile" aria-selected="false"><span>Tasks</span><span class="badge badge-link badge-sm border font-12 ml-2 rounded-circle" id="tasks_count">0</span></a>
- </li>
- <li class="nav-item">
- <a class="nav-link border-0 tab-view" id="notification-tab" data-toggle="tab" href="#notificationTabView" onclick="Unibase.Themes.Compact.Components.Notification.Instance().tabView('notification-tab')" role="tab" aria-controls="home" aria-selected="true"><span>Notification</span><span class="badge badge-link badge-sm border font-12 ml-2 rounded-circle" id="notification_count">0</span></a>
- </li>
- <li class="nav-item clear_alldiv mt-10 d-none" style="position:absolute;right:32px"><a class="reminderstatus" onclick="Unibase.Themes.Compact.Components.Notification.Instance().changeReminderStatusAsRead()">Clear All</a></li>
- </ul><ul class="clear-all-checkbox"><input type="checkbox" class="mb-1 clearall-checkbox" style="position:absolute;right:12px;top:13px"></ul>`;
- let tabViewBodyHTML = `
- <div class="tab-content m-0" id="myTabContent">
- <div class="tab-pane show active" id="taskTabView" role="tabpanel" aria-labelledby="profile-tab"></div>
- <div class="tab-pane " id="notificationTabView" role="tabpanel" aria-labelledby="home-tab"></div>
- </div>`;
- if (binding == 1) {
- $('#settings-panel-head-title').remove();
- $('#myTab').remove();
- $('#settings_panel_close').after(tabViewHeaderHTML);
- $("#settings-panel-body").html(tabViewBodyHTML).parent().addClass('p-0');
- $('.settings-panel-head').removeClass('px-3').addClass('pr-3 pl-1');
- }
- if (tabType == 'notification') {
- $('#notificationTabView').html(html);
- }
- if (tabType == 'task') {
- $('#taskTabView').html(html);
- this.GetUnreadRemindersCount(false);
- }
- }
- changeReminderStatusAsRead() {
- bootbox.confirm({
- title: "<span class='dstry' style='color:red'>Clear All Notifications?</span>",
- message: "Are you sure! Do you want to clear all notifications? ",
- buttons: {
- cancel: {
- label: '<i class="fa fa-times"></i> Cancel'
- },
- confirm: {
- label: '<i class="fa fa-check"></i> Confirm'
- }
- },
- callback: function (result) {
- if (result) {
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().ChangeAllReminderStatusAsRead().then(function (response) {
- if (response.status == Unibase.Data.Status.Success) {
- var html = Unibase.Themes.Compact.Components.Notification.Instance().noremaindershtml();
- var finalcount = 0;
- var checkboxclass = "clearall-checkbox";
- if (isMobileApp()) {
- checkboxclass = "clear-all-checkbox";
- var count = Number($('#notificatonIconBadge').text());
- var tabcount = Number($('#notification_count').text());
- finalcount = count - tabcount;
- $('#notificationTabView').html(html);
- }
- else {
- $("#settings-panel-body").html(html).addClass('no-data');
- }
- if (finalcount <= 0) {
- $('#notificatonIconBadge').addClass('d-none');
- finalcount = 0;
- }
- $('#notificatonIconBadge').text(finalcount);
- $('.clear_alldiv').addClass('d-none');
- $('.' + checkboxclass).addClass('d-none');
- $('#notification_count').text(0);
- $('#notificationsViewAllBtn').addClass('d-none');
- }
- else {
- alert("failed to clear notifications");
- }
- });
- }
- else {
- return;
- }
- }
- });
- }
- loadReminders(tabview, count) {
- return __awaiter(this, void 0, void 0, function* () {
- $('.clear-all-checkbox').removeClass('d-none');
- $('#settingsPanelBodyWrap').removeClass('d-none');
- $('#chatPanelBodyWrap').addClass('d-none');
- if ($('.biz__nav__toggle').is(':visible')) {
- $('#biz_nav_close').click();
- }
- let instance = this, html = "";
- if (count != null) {
- count = '<span class="badge border rounded-circle badge-sm badge-link mr-4 font-14 " id="notification_count">0</span>';
- }
- else {
- count = '<span class="badge border rounded-circle badge-sm badge-link mr-4 font-14 " id="notification_count"></span>';
- }
- $(".biz-settings-panel").css("background", "#f7fbff");
- $(".settings-panel-head").removeClass("d-none py-2");
- $('#settings-panel-head-title').addClass('d-flex flex-row align-items-center py-1').empty().append(`<span class="notification_header my-2 mr-2 font-16 font-weight-400">Notifications</span>${count}<div class="clear_alldiv d-none" style="position:absolute;right:40px"><a class="reminderstatus" onclick="Unibase.Themes.Compact.Components.Notification.Instance().changeReminderStatusAsRead()">Clear All</a></div><input type="checkbox" class="clearall-checkbox ml-2" style="position:absolute;right:10px">`).parent().addClass('px-3 border-bottom').removeClass('py-10');
- $('#settings-panel-body').removeClass('px-3').addClass("biz-body-height");
- $(".notification-footer").removeClass("d-none");
- let remindertype = Unibase.Platform.Communications.Enums.ReminderType.Notification;
- Unibase.Themes.Compact.Components.Notification.Instance().GetUnreadRemindersCount(true);
- return yield Unibase.Platform.Communications.Managers.ReminderManager.Instance().getReminders(remindertype, 20).then(function (response) {
- html = "";
- for (let i = 0; i < response.length; i++) {
- let createformid = 0, installedappid = 0, refid = 0;
- if (response[i].RedirectOptions == null || response[i].RedirectOptions == undefined) {
- installedappid = response[i].InstalledAppId;
- refid = response[i].RefId;
- }
- else {
- createformid = response[i].RedirectOptions.CreateFormId;
- installedappid = response[i].RedirectOptions.InstalledAppId;
- refid = response[i].RedirectOptions.RefId;
- }
- let ReminderUrl = response[i].ReminderUrl;
- let IconUrl = response[i].IconUrl;
- if (IconUrl == undefined || IconUrl == null) {
- IconUrl = "tenants/themes/compact/imgs/defaultnotification.png";
- }
- if (IconUrl == "") {
- IconUrl = "tenants/themes/compact/imgs/notification.png";
- }
- let ReminderId = response[i].ReminderId;
- if (ReminderUrl == "") {
- ReminderUrl = null;
- }
- html += `<div class="rem-item-wrap">
- <div class="d-flex w-100">
- <a href="javascript:void(0);" class="w-100 px-2 text-dark" id="Rem-item-${ReminderId}" data-id="${ReminderId}" onclick="Unibase.Themes.Compact.Components.Notification.Instance().loadReminderDetails(${refid},${installedappid},'${response[i].UrlType}','${ReminderUrl}',${remindertype},${createformid},null)"
- class="text-dark py-1 w-90">
- <div class="d-flex w-100">
- <div class="w-60p p-2 mr-2 flex-shrink-0">
- <img src="${IconUrl}" data-dynamic="1" onerror="ReloadImage(event)" class="img-fluid" data-loaded="0">
- </div>
- <div class="flex-grow-1 overflow-hide">
- <div class="notifications-text word-break">
- <div class="d-flex justify-content-between">
- <span class="w-90">
- <p class="text-dark text-capitalize font-12 font-weight-600 text-truncate w-95 notification-subject" title="${response[i].Subject}">${response[i].Subject}</p>
- </span><span>
- <div class="d-flex pb-0 px-2">
- <div class="checkbox_div w-10 "><input type="checkbox" class="check_allreminders notify_check" style="position:relative;left:5px;top:5px" id="checkid_${ReminderId}"></div>
- </div>
- </div> </div>
- <div><span class="font-12 font-weight-400 word-break notifi_message_overflow">${response[i].Message}</span></div>
- <div class="d-flex align-items-center justify-content-between z-index-10">
- <div class="notifications-time font-12 font-weight-600">${Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocal(response[i].ReminderDate)}</div>
- <span class="font-12 font-weight-600 text-dark py-1 z-index-2" data-id="${ReminderId}" onclick="Unibase.Themes.Compact.Components.Notification.Instance().UpdateReminderStatus('${ReminderId}','Read');event.stopPropagation();">Mark as read</span>
- </div>
- </div>
- </div>
- </a>
- </div></div>`;
- if (i != response.length - 1)
- html += '<div class="dropdown-divider mx-3 m-0 p-0"></div>';
- }
- var checkcount = Number(`${response.length}`);
- var noreminders = Unibase.Themes.Compact.Components.Notification.Instance().noremaindershtml();
- var viewallbtn = `<a class="btn btn-outline-primary mr-auto ml-auto px-3 py-1 " href="javascript:;" onclick="Unibase.Themes.Compact.Components.Notification.Instance().ViewAll(6)" id="notificationsViewAllBtn">View All</a><a class="btn btn-outline-danger mr-auto ml-auto px-3 py-1 d-none" href="javascript:;" onclick=" Unibase.Themes.Compact.Components.Notification.Instance().markAsReadUnReadReminders();" id="notificationClearBtn">Clear <span class="d-inline-flex align-items-center font-14">(<span id="clearNotificationCount">0</span>)</span></a>`;
- if (tabview == 'tab-view') {
- $('.clearall-checkbox').removeClass('d-none');
- if (checkcount == 0) {
- instance.loadNotificationsTask(noreminders, 'notification', 0);
- $('.clear_alldiv').addClass('d-none');
- $(".notification-footer").addClass("d-none");
- $('.clearall-checkbox').addClass('d-none');
- }
- else {
- instance.loadNotificationsTask(html, 'notification', 0);
- $('.clear_alldiv').removeClass('d-none');
- $(".notification-footer").removeClass("d-none").html(viewallbtn);
- }
- }
- else {
- if (checkcount == 0) {
- $('.clearall-checkbox').addClass('d-none');
- $('.clear_alldiv').addClass('d-none');
- $("#settings-panel-body").html(noreminders).addClass('no-data');
- $(".notification-footer").addClass("d-none");
- }
- else {
- $('.clear_alldiv').removeClass('d-none');
- $('.clearall-checkbox').removeClass('d-none');
- $("#settings-panel-body").html(html).removeClass('no-data');
- $(".notification-footer").removeClass("d-none").html(viewallbtn);
- }
- }
- $('.biz-settings-panel #notification_count').text(Unibase.Themes.Compact.Components.Notification.UnReadNotificationsCount);
- $('.biz-settings-panel #tasks_count').text(Unibase.Themes.Compact.Components.Notification.UnReadTasksCount);
- if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 1) {
- $('.biz-settings-panel').addClass('layout-1');
- }
- if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 2) {
- $('.biz-settings-panel').addClass('layout-2');
- }
- $('.biz-settings-panel').addClass('notifications-tasks-panel');
- $('.biz-settings-panel .notification-subject').each(function (i, e) {
- if ($(e).prop('scrollWidth') < $(e).outerWidth() + 2) {
- $(e).removeAttr('title');
- }
- });
- $('.notify_check').on('click', function (e) {
- e.stopPropagation();
- var ischecked = true;
- $('.notify_check').each(function () {
- if ($(this).is(':checked')) {
- ischecked = true;
- }
- else {
- ischecked = false;
- return false;
- }
- });
- if (ischecked) {
- $('.clearall-checkbox').prop('checked', true);
- }
- else {
- $('.clearall-checkbox').prop('checked', false);
- }
- if ($('.notify_check').is(":checked")) {
- $('.task-litab').addClass('d-none');
- $('#notificationsViewAllBtn').addClass('d-none');
- $('#clearNotificationCount').text($('.notify_check:checked').length);
- $('#notificationClearBtn').removeClass('d-none');
- }
- else {
- $('.task-litab').removeClass('d-none');
- $('.clearall-checkbox').prop("checked", false);
- $('#notificationsViewAllBtn').removeClass('d-none');
- $('#notificationClearBtn').addClass('d-none');
- }
- });
- $('.clearall-checkbox').click(function () {
- if ($('.clearall-checkbox').is(":checked")) {
- $('.task-litab').addClass('d-none');
- $('.check_allreminders').prop("checked", true);
- $('#notificationsViewAllBtn').addClass('d-none');
- $('#clearNotificationCount').text($('.notify_check:checked').length);
- $('#notificationClearBtn').removeClass('d-none');
- }
- else {
- $('.task-litab').removeClass('d-none');
- $('.check_allreminders').prop("checked", false);
- $('#notificationsViewAllBtn').removeClass('d-none');
- $('#notificationClearBtn').addClass('d-none');
- }
- });
- });
- });
- }
- markAsReadUnReadReminders(ismobile) {
- var Reminders = [];
- $('.check_allreminders').each(function () {
- if ($(this).is(":checked")) {
- var id = $(this).attr("id");
- var reminderid = id.split("_")[1];
- Reminders.push(reminderid);
- }
- });
- var Reminder = { Reminders };
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().markAsReadUnreadReminders(Reminder).then(function (response) {
- if (response.status == Unibase.Data.Status.Success) {
- var tab = undefined;
- if (ismobile) {
- tab = 'tab-view';
- }
- Unibase.Themes.Compact.Components.Notification.Instance().loadReminders(tab, null);
- }
- });
- }
- GetUnreadRemindersCount(isnotification) {
- const instance = this;
- let user = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().getUnreadRemindersCountByUserId().then(function (response) {
- var obj = response.result;
- Unibase.Themes.Compact.Components.Notification.UnReadNotificationsCount = obj.NotificationCount;
- Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = obj.TasksCount;
- const notificationCount = Number(obj.NotificationCount);
- const taskCount = Number(obj.TasksCount);
- if (Unibase.Themes.Compact.Components.Index.Instance().tabMode) {
- instance.bindCountHtml(notificationCount, '#notificatonIconBadge');
- instance.bindCountHtml(taskCount, '#taskIconBadge');
- }
- else {
- let totalCount = notificationCount + taskCount;
- instance.bindCountHtml(totalCount, '#notificatonIconBadge');
- }
- $(".biz-settings-panel #notification_count").text(obj.NotificationCount);
- $(".biz-settings-panel #tasks_count").text(obj.TasksCount);
- });
- }
- bindCountHtml(count, countEl) {
- if (count > 0) {
- let countHtml = count.toString();
- if (count > 99) {
- countHtml = '99<sup class="fa fa-plus" style="font-size: 8px;"></sup>';
- }
- if (count > 9 || count > 99) {
- let countClass = 'count-double-digit';
- if (count > 99) {
- countClass = 'count-overflow';
- }
- $(countEl).closest('.dropdown-notifications').addClass(countClass);
- }
- $(countEl).html(countHtml).removeClass("d-none");
- }
- else {
- $(countEl).empty().addClass("d-none");
- }
- }
- loadTasks(tabView) {
- return __awaiter(this, void 0, void 0, function* () {
- let instance = this;
- $('#settingsPanelBodyWrap').removeClass('d-none');
- $('#chatPanelBodyWrap').addClass('d-none');
- $('#settings-panel-head-title').addClass('d-flex flex-row align-items-center py-1').empty().append('<span class="my-2 font-16 font-weight-400">Tasks</span><span class="ml-2 px-2 border rounded-circle font-14" id="tasks_count">0</span>').parent().addClass('px-3 border-bottom').removeClass('py-10');
- $(".biz-settings-panel").css("background", "#fff9f9");
- $('.settings-panel-head').removeClass('py-2 mobileChat-view d-none');
- $('#settings-panel-body').removeClass('px-3').addClass("biz-body-height");
- let remindertype = Unibase.Platform.Communications.Enums.ReminderType.Task;
- Unibase.Themes.Compact.Components.Notification.Instance().GetUnreadRemindersCount(false);
- return yield Unibase.Platform.Communications.Managers.ReminderManager.Instance().getReminders(remindertype, 20).then(function (response) {
- let html = "";
- for (let i = 0; i < response.length; i++) {
- let createformid = 0, installedappid = 0, refid = 0;
- if (response[i].RedirectOptions == null || response[i].RedirectOptions == undefined) {
- installedappid = response[i].InstalledAppId;
- refid = response[i].RefId;
- }
- else {
- createformid = response[i].RedirectOptions.CreateFormId;
- installedappid = response[i].RedirectOptions.InstalledAppId;
- refid = response[i].RedirectOptions.RefId;
- }
- let ReminderUrl = response[i].ReminderUrl;
- let IconUrl = response[i].IconUrl;
- if (IconUrl == "" || IconUrl == null) {
- IconUrl = "tenants/themes/compact/imgs/task.png";
- }
- let ReminderId = response[i].ReminderId;
- if (ReminderUrl == "") {
- ReminderUrl = null;
- }
- html += '<div id="Taskmedia_' + ReminderId + '" data-refid="' + response[i].RefGuid + '" class="task-list-item TaskLi_' + response[i].TaskId + '">' +
- '<div class="cursor-pointer d-flex pr-3 py-1 w-100" id="Rem-item-' + ReminderId + '" data-id="' + ReminderId + '" onclick="Unibase.Themes.Compact.Components.Notification.Instance().loadReminderDetails(' + refid + ',' + installedappid + ',\'' + response[i].UrlType + '\',\'' + ReminderUrl + '\',' + remindertype + ',' + createformid + ',null)">' +
- `<div class="w-60p p-2 mr-2 flex-shrink-0"><img src="${IconUrl}" data-dynamic="1" onerror="ReloadImage(event)" class="img-fluid" data-loaded="0"></div>
- <div class="notifications-text flex-grow-1 overflow-hide word-break">
- <p class="text-dark text-capitalize font-12 font-weight-600 w-95 text-truncate word-break task-subject" title="${response[i].Subject}">${response[i].Subject}</p>
- <p class="font-12 text-dark notifi_message_overflow"> ${response[i].Message}</p>
- <div class="d-flex align-items-center justify-content-between my-2">
- <div class="notifications-time font-12">${Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocal(response[i].ReminderDate)}</div>` +
- '<div><a class="pull-right text-primary Collapse_Manage' + ReminderId + ' font-12" style="text-decoration: none;" data-toggle="collapse" onclick="Unibase.Themes.Compact.Components.Notification.Instance().LoadApprovals(\'' + response[i].RefGuid + '\',\'' + ReminderId + '\',' + response[i].TaskId + ');event.stopPropagation();"> Manage <i class="text-dark fa fa-angle-down"></i>' +
- `</a></div></div></div></div>
- <div class="box collaps" id="collapseManageBtn_${ReminderId}">
- </div>
- </div>`;
- if (i != response.length - 1)
- html += '<div class="dropdown-divider mx-3 m-0 p-0"></div>';
- }
- $('.biz-settings-panel #tasks_count').text(Unibase.Themes.Compact.Components.Notification.UnReadTasksCount);
- var checkcount = Number(`${response.length}`);
- var noreminders = Unibase.Themes.Compact.Components.Notification.Instance().notaskshtml();
- var viewallbtntask = `<a class="btn btn-outline-primary mr-auto ml-auto px-3 py-1" onclick="Unibase.Themes.Compact.Components.Notification.Instance().ViewAll(1)" href="javascript:;" id="AddWidget_btnCreateWidget">View All</a>`;
- if (tabView == 'tab-view') {
- if (checkcount == 0) {
- instance.loadNotificationsTask(noreminders, 'task', 1);
- $(".notification-footer").addClass("d-none");
- }
- else {
- instance.loadNotificationsTask(html, 'task', 1);
- $(".notification-footer").removeClass("d-none").html(viewallbtntask);
- }
- }
- else {
- $(".biz-settings-panel").toggleClass("show");
- if (checkcount == 0) {
- $("#settings-panel-body").html(noreminders).addClass('no-data');
- $(".notification-footer").addClass("d-none");
- }
- else {
- $("#settings-panel-body").html(html).removeClass('no-data');
- $(".notification-footer").removeClass("d-none").html(viewallbtntask);
- }
- }
- $('.biz-settings-panel .task-subject').each(function (i, e) {
- if ($(e).prop('scrollWidth') < $(e).outerWidth() + 2) {
- $(e).removeAttr('title');
- }
- });
- if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 1) {
- $('.biz-settings-panel').addClass('layout-1');
- }
- if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 2) {
- $('.biz-settings-panel').addClass('layout-2');
- }
- $('.biz-settings-panel').addClass('notifications-tasks-panel');
- $('.clear-all-checkbox').addClass('d-none');
- });
- });
- }
- LoadApprovals(RefId, ReminderId, TaskId) {
- var html = "";
- if ($(`#manageBtnWrap_${ReminderId}`).length) {
- $("#collapseManageBtn_" + ReminderId).collapse('toggle');
- return;
- }
- Unibase.Platform.Communications.Managers.TaskManager.Instance().getTaskByRefId(RefId, TaskId).then(function (response) {
- if (response.result != null) {
- var Approvedbtn = "Approve";
- var Rejectbtn = "Reject";
- var rejectonclick = 'Unibase.Themes.Compact.Components.Notification.Instance().SaveTaskReason(\'' + ReminderId + '\',' + response.result.TaskId + ',\'Reject\');';
- if (response.result.ConfirmKeyText != null && response.result.ConfirmKeyText != undefined && response.result.ConfirmKeyText != "") {
- Approvedbtn = response.result.ConfirmKeyText;
- }
- if (response.result.RejectKeyText != null && response.result.RejectKeyText != undefined && response.result.RejectKeyText != "") {
- Rejectbtn = response.result.RejectKeyText;
- }
- if (Number(response.result.RejectFormId) != 0) {
- rejectonclick = 'Unibase.Themes.Compact.Components.Notification.Instance().ChangeApprovalStatus(\'' + ReminderId + '\',' + response.result.TaskId + ',\'Reject\',' + response.result.RejectFormId + ',' + response.result.RejectFormPkId + ')';
- }
- html += `<div class="d-flex justify-content-center align-items-center mb-2 mt-1 ml-3 accordion-header" id="manageBtnWrap_${ReminderId}">` +
- '<button class="btn btn-outline-success mr-2 ml-auto px-4 py-1 font-12" onclick="Unibase.Themes.Compact.Components.Notification.Instance().ChangeApprovalStatus(\'' + ReminderId + '\',' + response.result.TaskId + ',\'Accept\',' + response.result.ApprovalFormId + ',' + response.result.ApprovalFormPkId + ')">' + Approvedbtn + '</button>' +
- '<button class="btn btn-outline-danger mr-2 ml-auto px-4 py-1 font-12 collapsed" data-toggle="collapse" href="#collapseReject_' + ReminderId + '">' + Rejectbtn + '</button>' +
- '<button class="btn btn-outline-primary mr-auto ml-auto px-4 py-1 font-12" onclick = "Unibase.Themes.Compact.Components.Notification.Instance().confirmclosetask(' + TaskId + ',\'' + ReminderId + '\')">Close</button>' +
- '</div>' +
- '<div class="collapse py-1" id="collapseReject_' + ReminderId + '" data-parent="#collapseManageBtn_' + ReminderId + '">' +
- '<div class="d-flex justify-content-start mt-1 px-3">' +
- '<input type="text" id="Reason_' + TaskId + '" class="form-control focus_blue border-0 w-75 p-0 pl-1 mr-2" placeholder="Add Comment">' +
- '<a href="javascript:void(0);" class="btn-sm btn-success px-3 ml-2 p-0 d-flex flex-row align-items-center" onclick="' + rejectonclick + '">' +
- '<i class="fa fa-send-o font-11"></i>' +
- '</a>' +
- '</div>' +
- '</div>';
- $("#collapseManageBtn_" + ReminderId).html(html).collapse('show');
- }
- });
- }
- ChangeApprovalStatus(reminderid, taskid, status, formid, formpkid) {
- var reason = status == "Reject" ? $("#Reason_" + taskid).val().toString() : "Accepted";
- var obj = {
- TaskId: taskid, Reason: reason, Status: status
- };
- if (formid != 0) {
- Unibase.Themes.Compact.Components.Notification.TaskId = taskid;
- Unibase.Themes.Compact.Components.Notification.TaskReminderId = reminderid;
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(formid, formpkid, 0, 0, function (response) {
- if (response != null) {
- Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
- Unibase.Themes.Compact.Components.Notification.TaskId = 0;
- Unibase.Themes.Compact.Components.Notification.TaskReminderId = '';
- Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
- var refguid = $('.TaskLi_' + taskid).attr('data-refid');
- Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refguid);
- Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
- });
- }
- });
- }
- else {
- Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
- Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
- var refguid = $('.TaskLi_' + taskid).attr('data-refid');
- Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refguid);
- Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
- });
- }
- }
- SaveTaskReason(reminderid, taskid, status) {
- let reason = $("#Reason_" + taskid).val().toString();
- var obj = { TaskId: taskid, Reason: reason, Status: status };
- Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
- Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
- var refguid = $('.TaskLi_' + taskid).attr('data-refid');
- Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refguid);
- Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
- });
- }
- GetRunnningProcess() {
- $(".notifications-nicescroll-bar").html("");
- }
- loadReminderDetails(id, installedappid, urltype, reminderurl, remindertype, CreateFormId, callback) {
- let reminderid = $(event.currentTarget).attr('id').split('-')[2], instance = this;
- let status = "Read";
- if (remindertype != Number(Unibase.Platform.Communications.Enums.ReminderType.Task)) {
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().changeReminderStatus(reminderid, status).then(function (response) {
- $(".Reminders").remove();
- if (remindertype == Number(Unibase.Platform.Communications.Enums.ReminderType.Notification)) {
- Unibase.Themes.Compact.Components.Notification.Instance().loadReminders();
- }
- else if (remindertype == Number(Unibase.Platform.Communications.Enums.ReminderType.Task)) {
- Unibase.Themes.Compact.Components.Notification.Instance().loadTasks();
- }
- else if (remindertype == Number(Unibase.Platform.Communications.Enums.ReminderType.Process)) {
- Unibase.Themes.Compact.Components.Notification.Instance().GetRunnningProcess();
- }
- });
- }
- if (urltype == "List") {
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(installedappid, null);
- }
- else if (urltype == "Details") {
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(id, installedappid, null);
- }
- else if (urltype == "FileDownload") {
- Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(reminderurl);
- }
- else if (urltype == "FilePreview") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
- Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFilePreview(id);
- });
- }
- else if (urltype == "FolderPreview") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
- Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFolderPreview(id, installedappid);
- });
- }
- else if (urltype == "Create") {
- this.fileCacheHelper.loadJsFile("platform/forms/managers/formmanager.js", function () {
- Unibase.Platform.Forms.Managers.FormManager.Instance().getFormRoleByAppConfiguration(Number(CreateFormId)).then(function (response) {
- if (response.result != null) {
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(response.result.FormId, 0, Number(CreateFormId), 0, null);
- }
- });
- });
- }
- else if (urltype == "Link") {
- Unibase.Themes.Compact.Components.Notification.Instance().openLink(reminderurl);
- }
- instance.closeClickEvent();
- }
- closeClickEvent() {
- $('.settings-panel-head').find('.notification-viewall').html("");
- $(".biz-wrapper").removeClass("biz-settings-toggle");
- $(".hk-wrapper").removeClass("biz-settings-toggle");
- $('.hk-settings-panel').removeClass('show');
- $('.right-side-menu-content-wrap').find('.nav-item').removeClass('right-sunbnav-active');
- $('.biz-nav-fullwidth').addClass('hidden');
- }
- loadReminder_mobile(params) {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(['platform/communications/enums/reminders/remindertype.js', 'platform/communications/managers/reminders/remindermanager.js'], function () {
- let id = 0;
- let installedappid = 0;
- let createformid = 0;
- if (params.RedirectOptions == null || params.RedirectOptions == undefined) {
- installedappid = Number(params.installedappid);
- id = Number(params.recordid);
- }
- else {
- var redirectoption = params.RedirectOptions;
- if (typeof (params.RedirectOptions) == 'string') {
- if (redirectoption.includes('CreateFormId'))
- params.RedirectOptions = JSON.parse(params.RedirectOptions);
- }
- installedappid = Number(params.RedirectOptions.InstalledAppId);
- createformid = Number(params.RedirectOptions.CreateFormId);
- id = Number(params.RedirectOptions.RefId);
- }
- let urltype = params.urltype;
- let reminderurl = params.reminderurl;
- let remindertype = Number(params.remindertype);
- let reminderid = params.reminderid;
- let status = "Read";
- if (urltype == "List") {
- Unibase.Platform.Helpers.NavigationHelper.Instance().closeAllModals();
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(installedappid, null);
- }
- else if (urltype == "Details") {
- Unibase.Platform.Helpers.NavigationHelper.Instance().closeAllModals();
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(id, installedappid, null);
- }
- else if (urltype == "FileDownload") {
- Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(reminderurl);
- }
- else if (urltype == "FilePreview") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
- Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFilePreview(id);
- });
- }
- else if (urltype == "FolderPreview") {
- Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
- Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFolderPreview(id, installedappid);
- });
- }
- else if (urltype == "Create") {
- this.fileCacheHelper.loadJsFile("platform/forms/managers/formmanager.js", function () {
- Unibase.Platform.Forms.Managers.FormManager.Instance().getFormRoleByAppConfiguration(createformid).then(function (response) {
- if (response.result != null) {
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(response.result.FormId, 0, Number(createformid), 0, null);
- }
- });
- });
- }
- else if (urltype == "Link") {
- Unibase.Themes.Compact.Components.Notification.Instance().openLink(reminderurl);
- }
- });
- }
- confirmclosetask(taskid, reminderid) {
- bootbox.confirm({
- title: "<span class='dstry' style='color:red'>Close Task?</span>",
- message: "Are you sure? If you are deleting this task.Then work flow will override",
- buttons: {
- cancel: {
- label: '<i class="fa fa-times"></i> Cancel'
- },
- confirm: {
- label: '<i class="fa fa-check"></i> Confirm'
- }
- },
- callback: function (result) {
- if (result) {
- Unibase.Themes.Compact.Components.Notification.Instance().CloseTask(taskid, reminderid, "Completed");
- }
- else {
- return;
- }
- }
- });
- }
- CloseTask(taskid, reminderid, status) {
- var username = Unibase.Platform.Membership.Infos.Identity.currentUser.name;
- let reason = "Task is Closed by " + username;
- var obj = { TaskId: taskid, Reason: reason, Status: status };
- Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
- Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
- Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
- });
- }
- UpdateReminderStatus(reminderid, status) {
- Unibase.Platform.Communications.Managers.ReminderManager.Instance().changeReminderStatus(reminderid, status).then(function (response) {
- var tab = undefined;
- if (isMobileApp()) {
- tab = 'tab-view';
- }
- Unibase.Themes.Compact.Components.Notification.Instance().loadReminders(tab, null);
- });
- }
- Downloadfile(url) {
- Unibase.Platform.Helpers.AssetHelper.Instance().download(url);
- }
- ViewAll(Type) {
- let installedappid = 0, instance = this;
- if (Type === Number(Unibase.Platform.Communications.Enums.ReminderType.Notification)) {
- installedappid = Unibase.Themes.Compact.Components.Notification.ReminderAppid;
- }
- else {
- installedappid = Unibase.Themes.Compact.Components.Notification.TaskReminderAppid;
- }
- if (installedappid != 0) {
- Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(installedappid, null);
- }
- instance.closeClickEvent();
- }
- GetInstalledAppId(uniqueid) {
- return __awaiter(this, void 0, void 0, function* () {
- let result;
- Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId(uniqueid).then(function (response) {
- result = response;
- });
- return yield result;
- });
- }
- notaskshtml() {
- return `<div class="card text-center border-0 shadow-none w-100 notification-empty-card mb-0 bg-transparent" style="z-index:99"><div class="card-body mt-50 text-center" ><img src="tenants/themes/compact/imgs/task.png" onerror="ReloadImage(event)" class="h-200p w-200p"><p class="text-dark my-1 font-weight-600">You don't have any Tasks Right Now.</p><p class="font-14">Will notify you when Something arrives'</p> </div> <div class="card-footer text-center border-0 mb-10"><a class="btn btn-outline-primary mr-auto ml-auto" onclick="Unibase.Themes.Compact.Components.Notification.Instance().ViewAll(1)" href = "javascript:;" id = "AddWidget_btnCreateWidget">View Earlier Tasks</a></div></div>`;
- }
- noremaindershtml() {
- return `<div class="card text-center border-0 shadow-none w-100 notification-empty-card mb-0 bg-transparent" style = "z-index:99" > <div class="card-body mt-50 text-center"><img src="tenants/themes/compact/imgs/notification.png" onerror = "ReloadImage(event)" class="h-200p w-200p"><p class="text-dark my-1 font-weight-600">You don't have any Notifications yet.</p><p class="font-14">Will notify you when Something arrives'</p></div><div class="card-footer text-center border-0 mb-10"><a class="btn btn-outline-primary mr-auto ml-auto" href = "javascript:;" onclick = "Unibase.Themes.Compact.Components.Notification.Instance().ViewAll(6)" id = "AddWidget_btnCreateWidget">View Earlier Notifications</a></div></div>`;
- }
- reloadPage(refguid) {
- if (Unibase.Themes.Providers.DetailHelper.installedAppId != 0) {
- var versionguid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_versionguid").Value;
- if (refguid == versionguid) {
- var obj = Unibase.Themes.Compact.Components.Details.Instance();
- obj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
- obj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
- Unibase.Themes.Compact.Components.Details.Instance().loadPortlets(obj);
- }
- }
- }
- removetask(taskid) {
- var count = 0;
- var html = Unibase.Themes.Compact.Components.Notification.Instance().notaskshtml();
- if (isMobileApp()) {
- count = Number($('#notificatonIconBadge').text()) - 1;
- $('#notificatonIconBadge').text(count);
- if (count == 0) {
- $('#notificatonIconBadge').addClass('d-none');
- $('#taskTabView').html(html);
- $(".notification-footer").addClass("d-none");
- }
- }
- else {
- count = Number($('#taskIconBadge').text()) - 1;
- $('#taskIconBadge').text(count);
- if (count == 0) {
- $('#taskIconBadge').addClass('d-none');
- $("#settings-panel-body").html(html).addClass('no-data');
- $(".notification-footer").addClass("d-none");
- }
- }
- $('#tasks_count').text(count);
- $('#notification_list_' + taskid).remove();
- $('.TaskLi_' + taskid).remove();
- }
- openLink(link) {
- var linkelement = document.createElement('a');
- linkelement.href = link;
- $(linkelement).attr("target", "_blank");
- linkelement.click();
- }
- }
- Notification.Status = "Accept";
- Notification.Reason = "Accepted";
- Notification.TaskId = 0;
- Notification.TaskReminderId = '';
- Notification.UnReadNotificationsCount = 0;
- Notification.UnReadTasksCount = 0;
- Components.Notification = Notification;
- })(Components = Compact.Components || (Compact.Components = {}));
- })(Compact = Themes.Compact || (Themes.Compact = {}));
- })(Themes = Unibase.Themes || (Unibase.Themes = {}));
- })(Unibase || (Unibase = {}));
|