EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
email list detail sync
Yuri Kuznetsovffbe6f5efae9
diff --git a/client/src/views/email/record/detail.js b/client/src/views/email/record/detail.jsindex 60fbb6114f..25cdf1c4b6 100644--- a/client/src/views/email/record/detail.js+++ b/client/src/views/email/record/detail.js@@ -101,12 +101,12 @@ class EmailDetailRecordView extends DetailRecordView {this.listenTo(this.model, 'change:status', () => this.controlSendButton());if (this.model.get('status') !== 'Draft' && this.model.has('isRead') && !this.model.get('isRead')) {- this.model.set('isRead', true);+ this.model.set('isRead', true, {sync: true});}this.listenTo(this.model, 'sync', () => {if (!this.model.get('isRead') && this.model.get('status') !== 'Draft') {- this.model.set('isRead', true);+ this.model.set('isRead', true, {sync: true});}});@@ -303,13 +303,13 @@ class EmailDetailRecordView extends DetailRecordView {actionMarkAsImportant() {Espo.Ajax.postRequest('Email/inbox/important', {id: this.model.id});- this.model.set('isImportant', true);+ this.model.set('isImportant', true, {sync: true});}actionMarkAsNotImportant() {Espo.Ajax.deleteRequest('Email/inbox/important', {id: this.model.id});- this.model.set('isImportant', false);+ this.model.set('isImportant', false, {sync: true});}actionMoveToTrash() {@@ -318,9 +318,9 @@ class EmailDetailRecordView extends DetailRecordView {});if (this.model.attributes.groupFolderId) {- this.model.set('groupStatusFolder', 'Trash');+ this.model.set('groupStatusFolder', 'Trash', {sync: true});} else {- this.model.set('inTrash', true);+ this.model.set('inTrash', true, {sync: true});}if (this.model.collection) {@@ -334,10 +334,10 @@ class EmailDetailRecordView extends DetailRecordView {Espo.Ui.warning(this.translate('Retrieved from Trash', 'labels', 'Email'));});- this.model.set('inTrash', false);+ this.model.set('inTrash', false, {sync: true});if (this.model.attributes.groupFolderId) {- this.model.set('groupStatusFolder', null);+ this.model.set('groupStatusFolder', null, {sync: true});}if (this.model.collection) {@@ -406,8 +406,8 @@ class EmailDetailRecordView extends DetailRecordView {Espo.Ajax.postRequest(`Email/inbox/folders/archive`, {id: this.model.id}).then(() => {this.model.attributes.groupFolderId ?- this.model.set('groupStatusFolder', 'Archive') :- this.model.set('inArchive', true);+ this.model.set('groupStatusFolder', 'Archive', {sync: true}) :+ this.model.set('inArchive', true, {sync: true});Espo.Ui.info(this.translate('Moved to Archive', 'labels', 'Email'));@@ -576,7 +576,7 @@ class EmailDetailRecordView extends DetailRecordView {actionSend() {this.send().then(() => {- this.model.set('status', 'Sent');+ this.model.set('status', 'Sent', {sync: true});if (this.mode !== this.MODE_DETAIL) {this.setDetailMode();diff --git a/client/src/views/email/record/list.js b/client/src/views/email/record/list.jsindex 61a69eba75..52ceac30e2 100644--- a/client/src/views/email/record/list.js+++ b/client/src/views/email/record/list.js@@ -46,6 +46,12 @@ class EmailListRecordView extends ListRecordView {*/toRemoveIdList+ collectionEventSyncList = [+ 'moving-to-trash',+ 'retrieving-from-trash',+ 'moving-to-archive',+ ]+setup() {super.setup();diff --git a/client/src/views/record/list.js b/client/src/views/record/list.jsindex 027e4462f8..96efea1bb9 100644--- a/client/src/views/record/list.js+++ b/client/src/views/record/list.js@@ -599,6 +599,13 @@ class ListRecordView extends View {*/_columnResizeHelper+ /**+ * @protected+ * @type {string[]}+ * @since 9.1.1+ */+ collectionEventSyncList+/** @inheritDoc */events = {/**@@ -1046,6 +1053,12 @@ class ListRecordView extends View {this.headerDisabled = this.options.headerDisabled || this.headerDisabled;this.noDataDisabled = this.options.noDataDisabled || this.noDataDisabled;+ if (!this.collectionEventSyncList) {+ this.collectionEventSyncList = [];+ } else {+ this.collectionEventSyncList = [...this.collectionEventSyncList];+ }+if (!this.headerDisabled) {this.header = _.isUndefined(this.options.header) ? this.header : this.options.header;} else {@@ -2177,6 +2190,14 @@ class ListRecordView extends View {model: collection.get(id),};+ if (this.collectionEventSyncList) {+ this.listenTo(collection, 'all', (event, ...parameters) => {+ if (this.collectionEventSyncList.includes(event)) {+ this.collection.trigger(event, ...parameters);+ }+ });+ }+this.listenTo(collection, 'model-sync', (/** Model */m, /** Record */o) => {if (o.action === 'destroy') {this.removeRecordFromList(m.id);