From ef573c692da515f3a174d0b6db0e1829de0dc16f Mon Sep 17 00:00:00 2001 From: Zelong Lin Date: Thu, 2 Jun 2022 12:22:46 +0000 Subject: [PATCH] [IMP] mail: tracking_val changed display on systray MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Display the content of the tracked changes that generate a notification under the systray task-2369610 closes odoo/odoo#86437 Signed-off-by: Alexandre Kühn (aku) --- .../thread_needaction_preview.xml | 11 +++++--- .../thread_preview/thread_preview.xml | 11 +++++--- addons/mail/static/src/models/message.js | 26 +++++++++++++++++++ .../models/thread_needaction_preview_view.js | 18 +++++++++++-- .../static/src/models/thread_preview_view.js | 18 +++++++++++-- 5 files changed, 74 insertions(+), 10 deletions(-) diff --git a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml index e174c06f4a4..09da4b6e65b 100644 --- a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml +++ b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml @@ -42,10 +42,15 @@
- - + + + + + + + + - diff --git a/addons/mail/static/src/components/thread_preview/thread_preview.xml b/addons/mail/static/src/components/thread_preview/thread_preview.xml index 866c21afe27..d1f52a63612 100644 --- a/addons/mail/static/src/components/thread_preview/thread_preview.xml +++ b/addons/mail/static/src/components/thread_preview/thread_preview.xml @@ -46,10 +46,15 @@
- - + + + + + + + + - diff --git a/addons/mail/static/src/models/message.js b/addons/mail/static/src/models/message.js index fab793a800f..7d6daf3f786 100644 --- a/addons/mail/static/src/models/message.js +++ b/addons/mail/static/src/models/message.js @@ -523,6 +523,20 @@ registerModel({ } return false; }, + /** + * @private + * @returns {FieldCommand} + */ + _computeLastTrackingValue() { + const { + length: l, + [l - 1]: lastTrackingValue, + } = this.trackingValues; + if (lastTrackingValue) { + return replace(lastTrackingValue); + } + return clear(); + }, /** * This value is meant to be based on field body which is * returned by the server (and has been sanitized before stored into db). @@ -597,6 +611,11 @@ registerModel({ } return replace(threads); }, + _sortTrackingValues() { + return [ + ['smaller-first', 'id'], + ]; + } }, fields: { authorName: attr({ @@ -778,6 +797,12 @@ registerModel({ isStarred: attr({ default: false, }), + /** + * Last tracking value of the message. + */ + lastTrackingValue: one('TrackingValue', { + compute: '_computeLastTrackingValue', + }), /** * Groups of reactions per content allowing to know the number of * reactions for each. @@ -841,6 +866,7 @@ registerModel({ trackingValues: many('TrackingValue', { inverse: 'messageOwner', isCausal: true, + sort: '_sortTrackingValues', }), }, }); diff --git a/addons/mail/static/src/models/thread_needaction_preview_view.js b/addons/mail/static/src/models/thread_needaction_preview_view.js index a3145dfaedc..a66ad3fcdad 100644 --- a/addons/mail/static/src/models/thread_needaction_preview_view.js +++ b/addons/mail/static/src/models/thread_needaction_preview_view.js @@ -2,7 +2,7 @@ import { registerModel } from '@mail/model/model_core'; import { attr, one } from '@mail/model/model_field'; -import { clear, insertAndReplace } from '@mail/model/model_field_command'; +import { clear, insertAndReplace, replace } from '@mail/model/model_field_command'; import { htmlToTextContentInline } from '@mail/js/utils'; registerModel({ @@ -50,7 +50,17 @@ registerModel({ * @returns {boolean} */ _computeIsEmpty() { - return !this.inlineLastNeedactionMessageAsOriginThreadBody; + return !this.inlineLastNeedactionMessageAsOriginThreadBody && !this.lastTrackingValue; + }, + /** + * @private + * @returns {FieldCommand} + */ + _computeLastTrackingValue() { + if (this.thread.lastMessage && this.thread.lastMessage.lastTrackingValue) { + return replace(this.thread.lastMessage.lastTrackingValue); + } + return clear(); }, /** * @private @@ -76,6 +86,10 @@ registerModel({ compute: '_computeIsEmpty', readonly: true, }), + lastTrackingValue: one('TrackingValue', { + compute:'_computeLastTrackingValue', + readonly: true, + }), /** * Reference of the "mark as read" button. Useful to disable the * top-level click handler when clicking on this specific button. diff --git a/addons/mail/static/src/models/thread_preview_view.js b/addons/mail/static/src/models/thread_preview_view.js index 9906b894c20..eb12c6e7e1e 100644 --- a/addons/mail/static/src/models/thread_preview_view.js +++ b/addons/mail/static/src/models/thread_preview_view.js @@ -2,7 +2,7 @@ import { registerModel } from '@mail/model/model_core'; import { attr, one } from '@mail/model/model_field'; -import { clear, insertAndReplace } from '@mail/model/model_field_command'; +import { clear, insertAndReplace, replace } from '@mail/model/model_field_command'; import { htmlToTextContentInline } from '@mail/js/utils'; registerModel({ @@ -49,7 +49,17 @@ registerModel({ * @returns {boolean} */ _computeIsEmpty() { - return !this.inlineLastMessageBody; + return !this.inlineLastMessageBody && !this.lastTrackingValue; + }, + /** + * @private + * @returns {FieldCommand} + */ + _computeLastTrackingValue() { + if (this.thread.lastMessage && this.thread.lastMessage.lastTrackingValue) { + return replace(this.thread.lastMessage.lastTrackingValue); + } + return clear(); }, /** * @private @@ -75,6 +85,10 @@ registerModel({ compute: '_computeIsEmpty', readonly: true, }), + lastTrackingValue: one('TrackingValue', { + compute:'_computeLastTrackingValue', + readonly: true, + }), /** * Reference of the "mark as read" button. Useful to disable the * top-level click handler when clicking on this specific button.