Skip to content

EspoCRM – Open Source CRM Application

Mark all read reamoving mark group read

Yurii8186eaf29288
diff --git a/client/src/views/notification/fields/container.js b/client/src/views/notification/fields/container.js
index bc01a6123f..5263993814 100644
--- a/client/src/views/notification/fields/container.js
+++ b/client/src/views/notification/fields/container.js
@@ -101,6 +101,26 @@ class NotificationContainerFieldView extends BaseFieldView {
this.addActionHandler('showGrouped', () => this.showGrouped());
this.addActionHandler('markGroupRead', () => this.markGroupRead());
+
+ if (this.model.collection) {
+ this.listenTo(this.model.collection, 'all-read', () => {
+ this.removeMarkGroupRead();
+ });
+ }
+ }
+
+ /**
+ * @private
+ */
+ removeMarkGroupRead() {
+ console.log(1);
+ if (!this.isRendered()) {
+ return;
+ }
+
+ const element = this.element?.querySelector('[data-action="markGroupRead"]');
+
+ element?.remove()
}
process() {
@@ -284,7 +304,6 @@ class NotificationContainerFieldView extends BaseFieldView {
this.triggerUpdateRead();
}
-
/**
* @private
*/
diff --git a/client/src/views/notification/list.js b/client/src/views/notification/list.js
index 9051e3718f..0bc2ee012c 100644
--- a/client/src/views/notification/list.js
+++ b/client/src/views/notification/list.js
@@ -34,11 +34,19 @@ class NotificationListView extends View {
template = 'notification/list'
+ /**
+ * @private
+ * @type {boolean}
+ */
+ groupingEnabled
+
setup() {
this.addActionHandler('refresh', () => this.actionRefresh());
this.addActionHandler('markAllNotificationsRead', () => this.actionMarkAllRead());
+ this.groupingEnabled = this.getPreferences().get('notificationGrouping') === true;
+
const promise =
this.getCollectionFactory().create('Notification')
.then(collection => {
@@ -91,6 +99,7 @@ class NotificationListView extends View {
view: 'views/notification/fields/container',
options: {
containerSelector: this.getSelector(),
+ groupingEnabled: this.groupingEnabled,
},
},
],
@@ -108,6 +117,8 @@ class NotificationListView extends View {
}
actionMarkAllRead() {
+ this.collection.trigger('all-read');
+
Ui.notifyWait();
const $link = this.$el.find('[data-action="markAllNotificationsRead"]');
diff --git a/client/src/views/notification/panel.js b/client/src/views/notification/panel.js
index c30841f0c8..a330784eb7 100644
--- a/client/src/views/notification/panel.js
+++ b/client/src/views/notification/panel.js
@@ -112,9 +112,12 @@ class NotificationPanelView extends View {
});
}
- actionMarkAllRead() {
- Espo.Ajax.postRequest('Notification/action/markAllRead')
- .then(() => this.trigger('all-read'));
+ async actionMarkAllRead() {
+ this.collection.trigger('all-read');
+
+ await Espo.Ajax.postRequest('Notification/action/markAllRead');
+
+ this.trigger('all-read')
}
close() {