diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-07-04 14:40:59 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-07-19 13:58:34 +0200 |
| commit | ec8c505bc1c9ec21939e9ffef53a9cc6f63f30c7 (patch) | |
| tree | d02d961c7fb09ec13ee02b7be83bb359e9e47db3 /addons/mail/static/src/js/thread_widget.js | |
| parent | ac14bcb7309c4a74221bb4ce5914382c8cc56584 (diff) | |
[IMP] mail: abstract thread in thread template
With this commit, the template for thread uses a {mail.model.AbstractThread}
object, instead of a list of {mail.model.AbstractMessage[]}.
Diffstat (limited to 'addons/mail/static/src/js/thread_widget.js')
| -rw-r--r-- | addons/mail/static/src/js/thread_widget.js | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/addons/mail/static/src/js/thread_widget.js b/addons/mail/static/src/js/thread_widget.js index 7d4833e81cd..78efdcde707 100644 --- a/addons/mail/static/src/js/thread_widget.js +++ b/addons/mail/static/src/js/thread_widget.js @@ -20,7 +20,9 @@ var READ_MORE = _t("read more"); var READ_LESS = _t("read less"); /** - * This is a generic widget to render a chat thread + * This is a generic widget to render a thread. + * Any thread that extends mail.model.AbstractThread can be used with this + * widget. */ var ThreadWidget = Widget.extend({ className: 'o_mail_thread', @@ -89,6 +91,7 @@ var ThreadWidget = Widget.extend({ * @param {mail.model.AbstractMessage[]} messages list of messages of the * thread, ordered by increasing IDs (a higher ID means a more recent * message). + * @param {} * @param {Object} [options] * @param {integer} [options.displayOrder=ORDER.ASC] order of displaying * messages in the thread: @@ -98,11 +101,11 @@ var ThreadWidget = Widget.extend({ * @param {boolean} [options.isCreateMode] * @param {boolean} [options.squashCloseMessages] */ - render: function (messages, options) { + render: function (thread, options) { var self = this; // copy so that reverse do not alter order in the thread object - messages = _.clone(messages); + var messages = _.clone(thread.getMessages()); var modeOptions = options.isCreateMode ? this._disabledOptions : this._enabledOptions; @@ -119,6 +122,10 @@ var ThreadWidget = Widget.extend({ selectedMessageID: this._selectedMessageID, }); + // dict where key is message ID, and value is whether it should hide + // the author of message or not visually + var hideAuthorMessages = {}; + // Hide avatar and info of a message if that message and the previous // one are both comments wrote by the same author at the same minute // and in the same document (users can now post message in documents @@ -147,14 +154,16 @@ var ThreadWidget = Widget.extend({ ) ) ) { - message.displayAuthor(true); + hideAuthorMessages[message.getID()] = false; } else { - message.displayAuthor(!options.squashCloseMessages); + hideAuthorMessages[message.getID()] = options.squashCloseMessages; } prevMessage = message; }); this.$el.html(QWeb.render('mail.widget.Thread', { - messages: messages, + thread: thread, + hideAuthorMessages: hideAuthorMessages, + // messages: messages, options: options, ORDER: ORDER, dateFormat: time.getLangDatetimeFormat(), |
