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.

notification.js 60KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  2. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  3. return new (P || (P = Promise))(function (resolve, reject) {
  4. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  5. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  7. step((generator = generator.apply(thisArg, _arguments || [])).next());
  8. });
  9. };
  10. var Unibase;
  11. (function (Unibase) {
  12. let Themes;
  13. (function (Themes) {
  14. let Compact;
  15. (function (Compact) {
  16. let Components;
  17. (function (Components) {
  18. class Notification extends Unibase.Platform.Core.BaseComponent {
  19. static Instance() {
  20. return new Notification();
  21. }
  22. init(containerid) {
  23. Unibase.Themes.Compact.Components.Notification.containerid = containerid;
  24. Unibase.Themes.Compact.Components.Notification.Instance().GetUnreadRemindersCount();
  25. let remindersuniqueid = "Unibase_Platform_Communications_Reminders_App_Reminders";
  26. Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId(remindersuniqueid).then(function (response) {
  27. if (response.result != null) {
  28. Unibase.Themes.Compact.Components.Notification.ReminderAppid = response.result.InstalledAppId;
  29. }
  30. });
  31. let taskremindersuniqueid = "Unibase_Platform_Communications_Reminders_App_TaskReminders";
  32. Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId(taskremindersuniqueid).then(function (response) {
  33. if (response.result != null) {
  34. Unibase.Themes.Compact.Components.Notification.TaskReminderAppid = response.result.InstalledAppId;
  35. }
  36. });
  37. $("#Active_Process").click(function () {
  38. $("#Active_Process").addClass("active");
  39. $("#Active_Notification").removeClass("active");
  40. $("#Active_Tasks").removeClass("active");
  41. $(".Reminders").remove();
  42. Unibase.Themes.Compact.Components.Notification.Instance().GetRunnningProcess();
  43. });
  44. }
  45. tabView(id) {
  46. 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>`;
  47. 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>`;
  48. let instance = this;
  49. $('.tab-view').removeClass('biz-notification-mobile-view border');
  50. $("#" + id).addClass('biz-notification-mobile-view border-0');
  51. if (id == 'notification-tab') {
  52. Unibase.Themes.Compact.Components.Notification.Instance().loadReminders('tab-view');
  53. $(".biz-settings-panel").css("background", "#fff9f9");
  54. }
  55. if (id == 'task-tab') {
  56. $('.clearall-checkbox').addClass('d-none');
  57. $('.clear_alldiv').addClass('d-none');
  58. Unibase.Themes.Compact.Components.Notification.Instance().loadTasks('tab-view');
  59. $(".biz-settings-panel").css("background", "#fff9f9");
  60. $(".notification-footer").html(viewallbtntask);
  61. }
  62. else {
  63. if (Unibase.Themes.Compact.Components.Notification.UnReadNotificationsCount == 0) {
  64. $('.clearall-checkbox').addClass('d-none');
  65. $('.clear_alldiv').addClass('d-none');
  66. }
  67. else {
  68. $('.clearall-checkbox').removeClass('d-none');
  69. $('.clear_alldiv').removeClass('d-none');
  70. }
  71. $(".biz-settings-panel").css("background", "#f7fbff");
  72. $(".notification-footer").html(viewallbtn);
  73. if ($('#notificationTabView .rem-item-wrap').length) {
  74. $(".notification-footer").removeClass('d-none');
  75. }
  76. else {
  77. $(".notification-footer").addClass('d-none');
  78. }
  79. }
  80. }
  81. loadNotificationsTask(html, tabType, binding) {
  82. let tabViewHeaderHTML = `
  83. <ul class="nav nav-tabs border-0 text-center mr-auto" id="myTab" role="tablist">
  84. <li class="nav-item task-litab">
  85. <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>
  86. </li>
  87. <li class="nav-item">
  88. <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>
  89. </li>
  90. <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>
  91. </ul><ul class="clear-all-checkbox"><input type="checkbox" class="mb-1 clearall-checkbox" style="position:absolute;right:12px;top:13px"></ul>`;
  92. let tabViewBodyHTML = `
  93. <div class="tab-content m-0" id="myTabContent">
  94. <div class="tab-pane show active" id="taskTabView" role="tabpanel" aria-labelledby="profile-tab"></div>
  95. <div class="tab-pane " id="notificationTabView" role="tabpanel" aria-labelledby="home-tab"></div>
  96. </div>`;
  97. if (binding == 1) {
  98. $('#settings-panel-head-title').remove();
  99. $('#myTab').remove();
  100. $('#settings_panel_close').after(tabViewHeaderHTML);
  101. $("#settings-panel-body").html(tabViewBodyHTML).parent().addClass('p-0');
  102. $('.settings-panel-head').removeClass('px-3').addClass('pr-3 pl-1');
  103. }
  104. if (tabType == 'notification') {
  105. $('#notificationTabView').html(html);
  106. }
  107. if (tabType == 'task') {
  108. $('#taskTabView').html(html);
  109. this.GetUnreadRemindersCount(false);
  110. }
  111. }
  112. changeReminderStatusAsRead() {
  113. bootbox.confirm({
  114. title: "<span class='dstry' style='color:red'>Clear All Notifications?</span>",
  115. message: "Are you sure! Do you want to clear all notifications? ",
  116. buttons: {
  117. cancel: {
  118. label: '<i class="fa fa-times"></i> Cancel'
  119. },
  120. confirm: {
  121. label: '<i class="fa fa-check"></i> Confirm'
  122. }
  123. },
  124. callback: function (result) {
  125. if (result) {
  126. Unibase.Platform.Communications.Managers.ReminderManager.Instance().ChangeAllReminderStatusAsRead().then(function (response) {
  127. if (response.status == Unibase.Data.Status.Success) {
  128. var html = Unibase.Themes.Compact.Components.Notification.Instance().noremaindershtml();
  129. var finalcount = 0;
  130. var checkboxclass = "clearall-checkbox";
  131. if (isMobileApp()) {
  132. checkboxclass = "clear-all-checkbox";
  133. var count = Number($('#notificatonIconBadge').text());
  134. var tabcount = Number($('#notification_count').text());
  135. finalcount = count - tabcount;
  136. $('#notificationTabView').html(html);
  137. }
  138. else {
  139. $("#settings-panel-body").html(html).addClass('no-data');
  140. }
  141. if (finalcount <= 0) {
  142. $('#notificatonIconBadge').addClass('d-none');
  143. finalcount = 0;
  144. }
  145. $('#notificatonIconBadge').text(finalcount);
  146. $('.clear_alldiv').addClass('d-none');
  147. $('.' + checkboxclass).addClass('d-none');
  148. $('#notification_count').text(0);
  149. $('#notificationsViewAllBtn').addClass('d-none');
  150. }
  151. else {
  152. alert("failed to clear notifications");
  153. }
  154. });
  155. }
  156. else {
  157. return;
  158. }
  159. }
  160. });
  161. }
  162. loadReminders(tabview, count) {
  163. return __awaiter(this, void 0, void 0, function* () {
  164. $('.clear-all-checkbox').removeClass('d-none');
  165. $('#settingsPanelBodyWrap').removeClass('d-none');
  166. $('#chatPanelBodyWrap').addClass('d-none');
  167. if ($('.biz__nav__toggle').is(':visible')) {
  168. $('#biz_nav_close').click();
  169. }
  170. let instance = this, html = "";
  171. if (count != null) {
  172. count = '<span class="badge border rounded-circle badge-sm badge-link mr-4 font-14 " id="notification_count">0</span>';
  173. }
  174. else {
  175. count = '<span class="badge border rounded-circle badge-sm badge-link mr-4 font-14 " id="notification_count"></span>';
  176. }
  177. $(".biz-settings-panel").css("background", "#f7fbff");
  178. $(".settings-panel-head").removeClass("d-none py-2");
  179. $('#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');
  180. $('#settings-panel-body').removeClass('px-3').addClass("biz-body-height");
  181. $(".notification-footer").removeClass("d-none");
  182. let remindertype = Unibase.Platform.Communications.Enums.ReminderType.Notification;
  183. Unibase.Themes.Compact.Components.Notification.Instance().GetUnreadRemindersCount(true);
  184. return yield Unibase.Platform.Communications.Managers.ReminderManager.Instance().getReminders(remindertype, 20).then(function (response) {
  185. html = "";
  186. for (let i = 0; i < response.length; i++) {
  187. let createformid = 0, installedappid = 0, refid = 0;
  188. if (response[i].RedirectOptions == null || response[i].RedirectOptions == undefined) {
  189. installedappid = response[i].InstalledAppId;
  190. refid = response[i].RefId;
  191. }
  192. else {
  193. createformid = response[i].RedirectOptions.CreateFormId;
  194. installedappid = response[i].RedirectOptions.InstalledAppId;
  195. refid = response[i].RedirectOptions.RefId;
  196. }
  197. let ReminderUrl = response[i].ReminderUrl;
  198. let IconUrl = response[i].IconUrl;
  199. if (IconUrl == undefined || IconUrl == null) {
  200. IconUrl = "tenants/themes/compact/imgs/defaultnotification.png";
  201. }
  202. if (IconUrl == "") {
  203. IconUrl = "tenants/themes/compact/imgs/notification.png";
  204. }
  205. let ReminderId = response[i].ReminderId;
  206. if (ReminderUrl == "") {
  207. ReminderUrl = null;
  208. }
  209. html += `<div class="rem-item-wrap">
  210. <div class="d-flex w-100">
  211. <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)"
  212. class="text-dark py-1 w-90">
  213. <div class="d-flex w-100">
  214. <div class="w-60p p-2 mr-2 flex-shrink-0">
  215. <img src="${IconUrl}" data-dynamic="1" onerror="ReloadImage(event)" class="img-fluid" data-loaded="0">
  216. </div>
  217. <div class="flex-grow-1 overflow-hide">
  218. <div class="notifications-text word-break">
  219. <div class="d-flex justify-content-between">
  220. <span class="w-90">
  221. <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>
  222. </span><span>
  223. <div class="d-flex pb-0 px-2">
  224. <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>
  225. </div>
  226. </div> </div>
  227. <div><span class="font-12 font-weight-400 word-break notifi_message_overflow">${response[i].Message}</span></div>
  228. <div class="d-flex align-items-center justify-content-between z-index-10">
  229. <div class="notifications-time font-12 font-weight-600">${Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocal(response[i].ReminderDate)}</div>
  230. <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>
  231. </div>
  232. </div>
  233. </div>
  234. </a>
  235. </div></div>`;
  236. if (i != response.length - 1)
  237. html += '<div class="dropdown-divider mx-3 m-0 p-0"></div>';
  238. }
  239. var checkcount = Number(`${response.length}`);
  240. var noreminders = Unibase.Themes.Compact.Components.Notification.Instance().noremaindershtml();
  241. 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>`;
  242. if (tabview == 'tab-view') {
  243. $('.clearall-checkbox').removeClass('d-none');
  244. if (checkcount == 0) {
  245. instance.loadNotificationsTask(noreminders, 'notification', 0);
  246. $('.clear_alldiv').addClass('d-none');
  247. $(".notification-footer").addClass("d-none");
  248. $('.clearall-checkbox').addClass('d-none');
  249. }
  250. else {
  251. instance.loadNotificationsTask(html, 'notification', 0);
  252. $('.clear_alldiv').removeClass('d-none');
  253. $(".notification-footer").removeClass("d-none").html(viewallbtn);
  254. }
  255. }
  256. else {
  257. if (checkcount == 0) {
  258. $('.clearall-checkbox').addClass('d-none');
  259. $('.clear_alldiv').addClass('d-none');
  260. $("#settings-panel-body").html(noreminders).addClass('no-data');
  261. $(".notification-footer").addClass("d-none");
  262. }
  263. else {
  264. $('.clear_alldiv').removeClass('d-none');
  265. $('.clearall-checkbox').removeClass('d-none');
  266. $("#settings-panel-body").html(html).removeClass('no-data');
  267. $(".notification-footer").removeClass("d-none").html(viewallbtn);
  268. }
  269. }
  270. $('.biz-settings-panel #notification_count').text(Unibase.Themes.Compact.Components.Notification.UnReadNotificationsCount);
  271. $('.biz-settings-panel #tasks_count').text(Unibase.Themes.Compact.Components.Notification.UnReadTasksCount);
  272. if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 1) {
  273. $('.biz-settings-panel').addClass('layout-1');
  274. }
  275. if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 2) {
  276. $('.biz-settings-panel').addClass('layout-2');
  277. }
  278. $('.biz-settings-panel').addClass('notifications-tasks-panel');
  279. $('.biz-settings-panel .notification-subject').each(function (i, e) {
  280. if ($(e).prop('scrollWidth') < $(e).outerWidth() + 2) {
  281. $(e).removeAttr('title');
  282. }
  283. });
  284. $('.notify_check').on('click', function (e) {
  285. e.stopPropagation();
  286. var ischecked = true;
  287. $('.notify_check').each(function () {
  288. if ($(this).is(':checked')) {
  289. ischecked = true;
  290. }
  291. else {
  292. ischecked = false;
  293. return false;
  294. }
  295. });
  296. if (ischecked) {
  297. $('.clearall-checkbox').prop('checked', true);
  298. }
  299. else {
  300. $('.clearall-checkbox').prop('checked', false);
  301. }
  302. if ($('.notify_check').is(":checked")) {
  303. $('.task-litab').addClass('d-none');
  304. $('#notificationsViewAllBtn').addClass('d-none');
  305. $('#clearNotificationCount').text($('.notify_check:checked').length);
  306. $('#notificationClearBtn').removeClass('d-none');
  307. }
  308. else {
  309. $('.task-litab').removeClass('d-none');
  310. $('.clearall-checkbox').prop("checked", false);
  311. $('#notificationsViewAllBtn').removeClass('d-none');
  312. $('#notificationClearBtn').addClass('d-none');
  313. }
  314. });
  315. $('.clearall-checkbox').click(function () {
  316. if ($('.clearall-checkbox').is(":checked")) {
  317. $('.task-litab').addClass('d-none');
  318. $('.check_allreminders').prop("checked", true);
  319. $('#notificationsViewAllBtn').addClass('d-none');
  320. $('#clearNotificationCount').text($('.notify_check:checked').length);
  321. $('#notificationClearBtn').removeClass('d-none');
  322. }
  323. else {
  324. $('.task-litab').removeClass('d-none');
  325. $('.check_allreminders').prop("checked", false);
  326. $('#notificationsViewAllBtn').removeClass('d-none');
  327. $('#notificationClearBtn').addClass('d-none');
  328. }
  329. });
  330. });
  331. });
  332. }
  333. markAsReadUnReadReminders(ismobile) {
  334. var Reminders = [];
  335. $('.check_allreminders').each(function () {
  336. if ($(this).is(":checked")) {
  337. var id = $(this).attr("id");
  338. var reminderid = id.split("_")[1];
  339. Reminders.push(reminderid);
  340. }
  341. });
  342. var Reminder = { Reminders };
  343. Unibase.Platform.Communications.Managers.ReminderManager.Instance().markAsReadUnreadReminders(Reminder).then(function (response) {
  344. if (response.status == Unibase.Data.Status.Success) {
  345. var tab = undefined;
  346. if (ismobile) {
  347. tab = 'tab-view';
  348. }
  349. Unibase.Themes.Compact.Components.Notification.Instance().loadReminders(tab, null);
  350. }
  351. });
  352. }
  353. GetUnreadRemindersCount(isnotification) {
  354. const instance = this;
  355. let user = Unibase.Platform.Membership.Infos.Identity.getCurrentUser();
  356. Unibase.Platform.Communications.Managers.ReminderManager.Instance().getUnreadRemindersCountByUserId().then(function (response) {
  357. var obj = response.result;
  358. Unibase.Themes.Compact.Components.Notification.UnReadNotificationsCount = obj.NotificationCount;
  359. Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = obj.TasksCount;
  360. const notificationCount = Number(obj.NotificationCount);
  361. const taskCount = Number(obj.TasksCount);
  362. if (Unibase.Themes.Compact.Components.Index.Instance().tabMode) {
  363. instance.bindCountHtml(notificationCount, '#notificatonIconBadge');
  364. instance.bindCountHtml(taskCount, '#taskIconBadge');
  365. }
  366. else {
  367. let totalCount = notificationCount + taskCount;
  368. instance.bindCountHtml(totalCount, '#notificatonIconBadge');
  369. }
  370. $(".biz-settings-panel #notification_count").text(obj.NotificationCount);
  371. $(".biz-settings-panel #tasks_count").text(obj.TasksCount);
  372. });
  373. }
  374. bindCountHtml(count, countEl) {
  375. if (count > 0) {
  376. let countHtml = count.toString();
  377. if (count > 99) {
  378. countHtml = '99<sup class="fa fa-plus" style="font-size: 8px;"></sup>';
  379. }
  380. if (count > 9 || count > 99) {
  381. let countClass = 'count-double-digit';
  382. if (count > 99) {
  383. countClass = 'count-overflow';
  384. }
  385. $(countEl).closest('.dropdown-notifications').addClass(countClass);
  386. }
  387. $(countEl).html(countHtml).removeClass("d-none");
  388. }
  389. else {
  390. $(countEl).empty().addClass("d-none");
  391. }
  392. }
  393. loadTasks(tabView) {
  394. return __awaiter(this, void 0, void 0, function* () {
  395. let instance = this;
  396. $('#settingsPanelBodyWrap').removeClass('d-none');
  397. $('#chatPanelBodyWrap').addClass('d-none');
  398. $('#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');
  399. $(".biz-settings-panel").css("background", "#fff9f9");
  400. $('.settings-panel-head').removeClass('py-2 mobileChat-view d-none');
  401. $('#settings-panel-body').removeClass('px-3').addClass("biz-body-height");
  402. let remindertype = Unibase.Platform.Communications.Enums.ReminderType.Task;
  403. Unibase.Themes.Compact.Components.Notification.Instance().GetUnreadRemindersCount(false);
  404. return yield Unibase.Platform.Communications.Managers.ReminderManager.Instance().getReminders(remindertype, 20).then(function (response) {
  405. let html = "";
  406. for (let i = 0; i < response.length; i++) {
  407. let createformid = 0, installedappid = 0, refid = 0;
  408. if (response[i].RedirectOptions == null || response[i].RedirectOptions == undefined) {
  409. installedappid = response[i].InstalledAppId;
  410. refid = response[i].RefId;
  411. }
  412. else {
  413. createformid = response[i].RedirectOptions.CreateFormId;
  414. installedappid = response[i].RedirectOptions.InstalledAppId;
  415. refid = response[i].RedirectOptions.RefId;
  416. }
  417. let ReminderUrl = response[i].ReminderUrl;
  418. let IconUrl = response[i].IconUrl;
  419. if (IconUrl == "" || IconUrl == null) {
  420. IconUrl = "tenants/themes/compact/imgs/task.png";
  421. }
  422. let ReminderId = response[i].ReminderId;
  423. if (ReminderUrl == "") {
  424. ReminderUrl = null;
  425. }
  426. html += '<div id="Taskmedia_' + ReminderId + '" data-refid="' + response[i].RefGuid + '" class="task-list-item TaskLi_' + response[i].TaskId + '">' +
  427. '<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)">' +
  428. `<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>
  429. <div class="notifications-text flex-grow-1 overflow-hide word-break">
  430. <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>
  431. <p class="font-12 text-dark notifi_message_overflow"> ${response[i].Message}</p>
  432. <div class="d-flex align-items-center justify-content-between my-2">
  433. <div class="notifications-time font-12">${Unibase.Platform.Helpers.DateTimeHelper.Instance().formatLocal(response[i].ReminderDate)}</div>` +
  434. '<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>' +
  435. `</a></div></div></div></div>
  436. <div class="box collaps" id="collapseManageBtn_${ReminderId}">
  437. </div>
  438. </div>`;
  439. if (i != response.length - 1)
  440. html += '<div class="dropdown-divider mx-3 m-0 p-0"></div>';
  441. }
  442. $('.biz-settings-panel #tasks_count').text(Unibase.Themes.Compact.Components.Notification.UnReadTasksCount);
  443. var checkcount = Number(`${response.length}`);
  444. var noreminders = Unibase.Themes.Compact.Components.Notification.Instance().notaskshtml();
  445. 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>`;
  446. if (tabView == 'tab-view') {
  447. if (checkcount == 0) {
  448. instance.loadNotificationsTask(noreminders, 'task', 1);
  449. $(".notification-footer").addClass("d-none");
  450. }
  451. else {
  452. instance.loadNotificationsTask(html, 'task', 1);
  453. $(".notification-footer").removeClass("d-none").html(viewallbtntask);
  454. }
  455. }
  456. else {
  457. $(".biz-settings-panel").toggleClass("show");
  458. if (checkcount == 0) {
  459. $("#settings-panel-body").html(noreminders).addClass('no-data');
  460. $(".notification-footer").addClass("d-none");
  461. }
  462. else {
  463. $("#settings-panel-body").html(html).removeClass('no-data');
  464. $(".notification-footer").removeClass("d-none").html(viewallbtntask);
  465. }
  466. }
  467. $('.biz-settings-panel .task-subject').each(function (i, e) {
  468. if ($(e).prop('scrollWidth') < $(e).outerWidth() + 2) {
  469. $(e).removeAttr('title');
  470. }
  471. });
  472. if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 1) {
  473. $('.biz-settings-panel').addClass('layout-1');
  474. }
  475. if (Unibase.Themes.Compact.Components.Index.Instance().layoutIndex == 2) {
  476. $('.biz-settings-panel').addClass('layout-2');
  477. }
  478. $('.biz-settings-panel').addClass('notifications-tasks-panel');
  479. $('.clear-all-checkbox').addClass('d-none');
  480. });
  481. });
  482. }
  483. LoadApprovals(RefId, ReminderId, TaskId) {
  484. var html = "";
  485. if ($(`#manageBtnWrap_${ReminderId}`).length) {
  486. $("#collapseManageBtn_" + ReminderId).collapse('toggle');
  487. return;
  488. }
  489. Unibase.Platform.Communications.Managers.TaskManager.Instance().getTaskByRefId(RefId, TaskId).then(function (response) {
  490. if (response.result != null) {
  491. var Approvedbtn = "Approve";
  492. var Rejectbtn = "Reject";
  493. var rejectonclick = 'Unibase.Themes.Compact.Components.Notification.Instance().SaveTaskReason(\'' + ReminderId + '\',' + response.result.TaskId + ',\'Reject\');';
  494. if (response.result.ConfirmKeyText != null && response.result.ConfirmKeyText != undefined && response.result.ConfirmKeyText != "") {
  495. Approvedbtn = response.result.ConfirmKeyText;
  496. }
  497. if (response.result.RejectKeyText != null && response.result.RejectKeyText != undefined && response.result.RejectKeyText != "") {
  498. Rejectbtn = response.result.RejectKeyText;
  499. }
  500. if (Number(response.result.RejectFormId) != 0) {
  501. rejectonclick = 'Unibase.Themes.Compact.Components.Notification.Instance().ChangeApprovalStatus(\'' + ReminderId + '\',' + response.result.TaskId + ',\'Reject\',' + response.result.RejectFormId + ',' + response.result.RejectFormPkId + ')';
  502. }
  503. html += `<div class="d-flex justify-content-center align-items-center mb-2 mt-1 ml-3 accordion-header" id="manageBtnWrap_${ReminderId}">` +
  504. '<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>' +
  505. '<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>' +
  506. '<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>' +
  507. '</div>' +
  508. '<div class="collapse py-1" id="collapseReject_' + ReminderId + '" data-parent="#collapseManageBtn_' + ReminderId + '">' +
  509. '<div class="d-flex justify-content-start mt-1 px-3">' +
  510. '<input type="text" id="Reason_' + TaskId + '" class="form-control focus_blue border-0 w-75 p-0 pl-1 mr-2" placeholder="Add Comment">' +
  511. '<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 + '">' +
  512. '<i class="fa fa-send-o font-11"></i>' +
  513. '</a>' +
  514. '</div>' +
  515. '</div>';
  516. $("#collapseManageBtn_" + ReminderId).html(html).collapse('show');
  517. }
  518. });
  519. }
  520. ChangeApprovalStatus(reminderid, taskid, status, formid, formpkid) {
  521. var reason = status == "Reject" ? $("#Reason_" + taskid).val().toString() : "Accepted";
  522. var obj = {
  523. TaskId: taskid, Reason: reason, Status: status
  524. };
  525. if (formid != 0) {
  526. Unibase.Themes.Compact.Components.Notification.TaskId = taskid;
  527. Unibase.Themes.Compact.Components.Notification.TaskReminderId = reminderid;
  528. Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(formid, formpkid, 0, 0, function (response) {
  529. if (response != null) {
  530. Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
  531. Unibase.Themes.Compact.Components.Notification.TaskId = 0;
  532. Unibase.Themes.Compact.Components.Notification.TaskReminderId = '';
  533. Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
  534. var refguid = $('.TaskLi_' + taskid).attr('data-refid');
  535. Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refguid);
  536. Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
  537. });
  538. }
  539. });
  540. }
  541. else {
  542. Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
  543. Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
  544. var refguid = $('.TaskLi_' + taskid).attr('data-refid');
  545. Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refguid);
  546. Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
  547. });
  548. }
  549. }
  550. SaveTaskReason(reminderid, taskid, status) {
  551. let reason = $("#Reason_" + taskid).val().toString();
  552. var obj = { TaskId: taskid, Reason: reason, Status: status };
  553. Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
  554. Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
  555. var refguid = $('.TaskLi_' + taskid).attr('data-refid');
  556. Unibase.Themes.Compact.Components.Notification.Instance().reloadPage(refguid);
  557. Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
  558. });
  559. }
  560. GetRunnningProcess() {
  561. $(".notifications-nicescroll-bar").html("");
  562. }
  563. loadReminderDetails(id, installedappid, urltype, reminderurl, remindertype, CreateFormId, callback) {
  564. let reminderid = $(event.currentTarget).attr('id').split('-')[2], instance = this;
  565. let status = "Read";
  566. if (remindertype != Number(Unibase.Platform.Communications.Enums.ReminderType.Task)) {
  567. Unibase.Platform.Communications.Managers.ReminderManager.Instance().changeReminderStatus(reminderid, status).then(function (response) {
  568. $(".Reminders").remove();
  569. if (remindertype == Number(Unibase.Platform.Communications.Enums.ReminderType.Notification)) {
  570. Unibase.Themes.Compact.Components.Notification.Instance().loadReminders();
  571. }
  572. else if (remindertype == Number(Unibase.Platform.Communications.Enums.ReminderType.Task)) {
  573. Unibase.Themes.Compact.Components.Notification.Instance().loadTasks();
  574. }
  575. else if (remindertype == Number(Unibase.Platform.Communications.Enums.ReminderType.Process)) {
  576. Unibase.Themes.Compact.Components.Notification.Instance().GetRunnningProcess();
  577. }
  578. });
  579. }
  580. if (urltype == "List") {
  581. Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(installedappid, null);
  582. }
  583. else if (urltype == "Details") {
  584. Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(id, installedappid, null);
  585. }
  586. else if (urltype == "FileDownload") {
  587. Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(reminderurl);
  588. }
  589. else if (urltype == "FilePreview") {
  590. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
  591. Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFilePreview(id);
  592. });
  593. }
  594. else if (urltype == "FolderPreview") {
  595. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
  596. Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFolderPreview(id, installedappid);
  597. });
  598. }
  599. else if (urltype == "Create") {
  600. this.fileCacheHelper.loadJsFile("platform/forms/managers/formmanager.js", function () {
  601. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormRoleByAppConfiguration(Number(CreateFormId)).then(function (response) {
  602. if (response.result != null) {
  603. Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(response.result.FormId, 0, Number(CreateFormId), 0, null);
  604. }
  605. });
  606. });
  607. }
  608. else if (urltype == "Link") {
  609. Unibase.Themes.Compact.Components.Notification.Instance().openLink(reminderurl);
  610. }
  611. instance.closeClickEvent();
  612. }
  613. closeClickEvent() {
  614. $('.settings-panel-head').find('.notification-viewall').html("");
  615. $(".biz-wrapper").removeClass("biz-settings-toggle");
  616. $(".hk-wrapper").removeClass("biz-settings-toggle");
  617. $('.hk-settings-panel').removeClass('show');
  618. $('.right-side-menu-content-wrap').find('.nav-item').removeClass('right-sunbnav-active');
  619. $('.biz-nav-fullwidth').addClass('hidden');
  620. }
  621. loadReminder_mobile(params) {
  622. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFiles(['platform/communications/enums/reminders/remindertype.js', 'platform/communications/managers/reminders/remindermanager.js'], function () {
  623. let id = 0;
  624. let installedappid = 0;
  625. let createformid = 0;
  626. if (params.RedirectOptions == null || params.RedirectOptions == undefined) {
  627. installedappid = Number(params.installedappid);
  628. id = Number(params.recordid);
  629. }
  630. else {
  631. var redirectoption = params.RedirectOptions;
  632. if (typeof (params.RedirectOptions) == 'string') {
  633. if (redirectoption.includes('CreateFormId'))
  634. params.RedirectOptions = JSON.parse(params.RedirectOptions);
  635. }
  636. installedappid = Number(params.RedirectOptions.InstalledAppId);
  637. createformid = Number(params.RedirectOptions.CreateFormId);
  638. id = Number(params.RedirectOptions.RefId);
  639. }
  640. let urltype = params.urltype;
  641. let reminderurl = params.reminderurl;
  642. let remindertype = Number(params.remindertype);
  643. let reminderid = params.reminderid;
  644. let status = "Read";
  645. if (urltype == "List") {
  646. Unibase.Platform.Helpers.NavigationHelper.Instance().closeAllModals();
  647. Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(installedappid, null);
  648. }
  649. else if (urltype == "Details") {
  650. Unibase.Platform.Helpers.NavigationHelper.Instance().closeAllModals();
  651. Unibase.Platform.Helpers.NavigationHelper.Instance().loadDetail(id, installedappid, null);
  652. }
  653. else if (urltype == "FileDownload") {
  654. Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(reminderurl);
  655. }
  656. else if (urltype == "FilePreview") {
  657. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
  658. Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFilePreview(id);
  659. });
  660. }
  661. else if (urltype == "FolderPreview") {
  662. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/components/unicloud.js", function () {
  663. Unibase.Apps.Collaboration.Components.UniCloud.Instance().notificationFolderPreview(id, installedappid);
  664. });
  665. }
  666. else if (urltype == "Create") {
  667. this.fileCacheHelper.loadJsFile("platform/forms/managers/formmanager.js", function () {
  668. Unibase.Platform.Forms.Managers.FormManager.Instance().getFormRoleByAppConfiguration(createformid).then(function (response) {
  669. if (response.result != null) {
  670. Unibase.Platform.Helpers.NavigationHelper.Instance().loadForm(response.result.FormId, 0, Number(createformid), 0, null);
  671. }
  672. });
  673. });
  674. }
  675. else if (urltype == "Link") {
  676. Unibase.Themes.Compact.Components.Notification.Instance().openLink(reminderurl);
  677. }
  678. });
  679. }
  680. confirmclosetask(taskid, reminderid) {
  681. bootbox.confirm({
  682. title: "<span class='dstry' style='color:red'>Close Task?</span>",
  683. message: "Are you sure? If you are deleting this task.Then work flow will override",
  684. buttons: {
  685. cancel: {
  686. label: '<i class="fa fa-times"></i> Cancel'
  687. },
  688. confirm: {
  689. label: '<i class="fa fa-check"></i> Confirm'
  690. }
  691. },
  692. callback: function (result) {
  693. if (result) {
  694. Unibase.Themes.Compact.Components.Notification.Instance().CloseTask(taskid, reminderid, "Completed");
  695. }
  696. else {
  697. return;
  698. }
  699. }
  700. });
  701. }
  702. CloseTask(taskid, reminderid, status) {
  703. var username = Unibase.Platform.Membership.Infos.Identity.currentUser.name;
  704. let reason = "Task is Closed by " + username;
  705. var obj = { TaskId: taskid, Reason: reason, Status: status };
  706. Unibase.Platform.Communications.Managers.TaskManager.Instance().changeApprovalStatus(obj).then(function (response) {
  707. Unibase.Themes.Compact.Components.Notification.UnReadTasksCount = Unibase.Themes.Compact.Components.Notification.UnReadTasksCount - 1;
  708. Unibase.Themes.Compact.Components.Notification.Instance().removetask(taskid);
  709. });
  710. }
  711. UpdateReminderStatus(reminderid, status) {
  712. Unibase.Platform.Communications.Managers.ReminderManager.Instance().changeReminderStatus(reminderid, status).then(function (response) {
  713. var tab = undefined;
  714. if (isMobileApp()) {
  715. tab = 'tab-view';
  716. }
  717. Unibase.Themes.Compact.Components.Notification.Instance().loadReminders(tab, null);
  718. });
  719. }
  720. Downloadfile(url) {
  721. Unibase.Platform.Helpers.AssetHelper.Instance().download(url);
  722. }
  723. ViewAll(Type) {
  724. let installedappid = 0, instance = this;
  725. if (Type === Number(Unibase.Platform.Communications.Enums.ReminderType.Notification)) {
  726. installedappid = Unibase.Themes.Compact.Components.Notification.ReminderAppid;
  727. }
  728. else {
  729. installedappid = Unibase.Themes.Compact.Components.Notification.TaskReminderAppid;
  730. }
  731. if (installedappid != 0) {
  732. Unibase.Platform.Helpers.NavigationHelper.Instance().loadList(installedappid, null);
  733. }
  734. instance.closeClickEvent();
  735. }
  736. GetInstalledAppId(uniqueid) {
  737. return __awaiter(this, void 0, void 0, function* () {
  738. let result;
  739. Unibase.Platform.Apps.Managers.AppManager.Instance().getInstallAppId(uniqueid).then(function (response) {
  740. result = response;
  741. });
  742. return yield result;
  743. });
  744. }
  745. notaskshtml() {
  746. 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>`;
  747. }
  748. noremaindershtml() {
  749. 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>`;
  750. }
  751. reloadPage(refguid) {
  752. if (Unibase.Themes.Providers.DetailHelper.installedAppId != 0) {
  753. var versionguid = Unibase.Themes.Providers.Detail_Settings.Instance().InputParameters.find(x => x.Key == "hf_" + Unibase.Themes.Providers.DetailHelper.installedAppId + "_versionguid").Value;
  754. if (refguid == versionguid) {
  755. var obj = Unibase.Themes.Compact.Components.Details.Instance();
  756. obj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
  757. obj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  758. Unibase.Themes.Compact.Components.Details.Instance().loadPortlets(obj);
  759. }
  760. }
  761. }
  762. removetask(taskid) {
  763. var count = 0;
  764. var html = Unibase.Themes.Compact.Components.Notification.Instance().notaskshtml();
  765. if (isMobileApp()) {
  766. count = Number($('#notificatonIconBadge').text()) - 1;
  767. $('#notificatonIconBadge').text(count);
  768. if (count == 0) {
  769. $('#notificatonIconBadge').addClass('d-none');
  770. $('#taskTabView').html(html);
  771. $(".notification-footer").addClass("d-none");
  772. }
  773. }
  774. else {
  775. count = Number($('#taskIconBadge').text()) - 1;
  776. $('#taskIconBadge').text(count);
  777. if (count == 0) {
  778. $('#taskIconBadge').addClass('d-none');
  779. $("#settings-panel-body").html(html).addClass('no-data');
  780. $(".notification-footer").addClass("d-none");
  781. }
  782. }
  783. $('#tasks_count').text(count);
  784. $('#notification_list_' + taskid).remove();
  785. $('.TaskLi_' + taskid).remove();
  786. }
  787. openLink(link) {
  788. var linkelement = document.createElement('a');
  789. linkelement.href = link;
  790. $(linkelement).attr("target", "_blank");
  791. linkelement.click();
  792. }
  793. }
  794. Notification.Status = "Accept";
  795. Notification.Reason = "Accepted";
  796. Notification.TaskId = 0;
  797. Notification.TaskReminderId = '';
  798. Notification.UnReadNotificationsCount = 0;
  799. Notification.UnReadTasksCount = 0;
  800. Components.Notification = Notification;
  801. })(Components = Compact.Components || (Compact.Components = {}));
  802. })(Compact = Themes.Compact || (Themes.Compact = {}));
  803. })(Themes = Unibase.Themes || (Unibase.Themes = {}));
  804. })(Unibase || (Unibase = {}));