EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
Popup notifications rerender fix
Yurii491a844e580e
diff --git a/client/src/views/notification/badge.js b/client/src/views/notification/badge.jsindex 32434d34ed..6b8b7fe829 100644--- a/client/src/views/notification/badge.js+++ b/client/src/views/notification/badge.js@@ -104,6 +104,24 @@ class NotificationBadgeView extends View {@inject(ModalBarProvider)modalBarProvider+ /**+ * @private+ * @type {HTMLDivElement}+ */+ popupNotificationsContainer++ /**+ * @private+ * @type {string[]}+ */+ shownNotificationIds++ /**+ * @private+ * @type {string[]}+ */+ closedNotificationIds+setup() {this.addActionHandler('showNotifications', () => this.showNotifications());@@ -157,14 +175,7 @@ class NotificationBadgeView extends View {this.runCheckUpdates(true);- this.$popupContainer = $('#popup-notifications-container');-- if (!$(this.$popupContainer).length) {- this.$popupContainer = $('<div>')- .attr('id', 'popup-notifications-container')- .addClass('hidden')- .appendTo('body');- }+ this.preparePopupNotificationContainer();const popupNotificationsData = this.popupNotificationsData =this.getMetadata().get('app.popupNotifications') || {};@@ -178,6 +189,23 @@ class NotificationBadgeView extends View {}}+ /**+ * @private+ */+ preparePopupNotificationContainer() {+ let popupNotificationsContainer = document.querySelector('#popup-notifications-container');++ if (!popupNotificationsContainer) {+ popupNotificationsContainer = document.createElement('div');+ popupNotificationsContainer.id = 'popup-notifications-container';+ popupNotificationsContainer.className = 'hidden';++ document.body.append(popupNotificationsContainer);+ }++ this.popupNotificationsContainer = popupNotificationsContainer;+ }+/*** @private* @param {StorageEvent} e@@ -556,7 +584,7 @@ class NotificationBadgeView extends View {},});- this.$popupContainer.removeClass('hidden');+ this.popupNotificationsContainer.classList.remove('hidden');this.listenTo(view, 'remove', () => {this.markPopupRemoved(id);@@ -658,8 +686,8 @@ class NotificationBadgeView extends View {this.shownNotificationIds.splice(index, 1);}- if (this.shownNotificationIds.length === 0) {- this.$popupContainer.addClass('hidden');+ if (this.shownNotificationIds.length === 0 && this.popupNotificationsContainer) {+ this.popupNotificationsContainer.classList.add('hidden')}this.closedNotificationIds.push(id);diff --git a/client/src/views/popup-notification.js b/client/src/views/popup-notification.jsindex 8156227ce8..26c645c1d3 100644--- a/client/src/views/popup-notification.js+++ b/client/src/views/popup-notification.js@@ -113,11 +113,11 @@ class PopupNotificationView extends View {});});- this.once('after:render', () => {+ this.on('after:render', () => {this.onShow();});- this.once('remove', function () {+ this.on('remove', function () {$(containerSelector).remove();});diff --git a/client/src/views/site/navbar.js b/client/src/views/site/navbar.jsindex c6f9f8ff16..145f15eefd 100644--- a/client/src/views/site/navbar.js+++ b/client/src/views/site/navbar.js@@ -454,8 +454,11 @@ class NavbarSiteView extends View {.all(this.itemList.map(item => this.createItemView(item)));};- const update = () => {- setup().then(() => this.reRender());+ const update = async () => {+ await setup();+ await this.reRender({+ keep: [this.composeItemKey('notificationBadge')],+ });};setup();@@ -511,7 +514,7 @@ class NavbarSiteView extends View {return false;}- const view = this.getView(name + 'Item');+ const view = this.getView(this.composeItemKey(name));if ('isAvailable' in view) {return view.isAvailable();@@ -521,13 +524,22 @@ class NavbarSiteView extends View {}).map(name => {return {- key: name + 'Item',+ key: this.composeItemKey(name),name: name,class: defsMap[name].class || '',};});}+ /**+ * @private+ * @param {string} name+ * @return {string}+ */+ composeItemKey(name) {+ return name + 'Item';+ }+/**** @param {string} name@@ -552,7 +564,11 @@ class NavbarSiteView extends View {return Promise.resolve();}- const key = name + 'Item';+ const key = this.composeItemKey(name);++ if (defs.view === 'views/notification/badge' && this.hasView(key)) {+ return Promise.resolve();+ }return this.createView(key, defs.view, {selector: `[data-item="${name}"]`});}