diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-07-04 15:57:03 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-07-19 13:58:34 +0200 |
| commit | 915da49d173e9ab8d0c6d94cbeec124c83d23fc7 (patch) | |
| tree | d7fe30d4a4c7f1a6923b88c91ac98582ee6500f4 /addons/mail/static/src/js/thread_windows/abstract_thread_window.js | |
| parent | ec8c505bc1c9ec21939e9ffef53a9cc6f63f30c7 (diff) | |
[IMP] mail, *: template rendering with abstract thread, adapt thread instantiation, thread `getMessages`/`fetchMessages`, and create mode document thread.
* = im_livechat, im_support
- thread widget now uses abstract thread in `render` method
- thread models have their `init` parameters changed, so that the parent may be optional
- reworked 'creating a new record...' in chatter in create mode:
> new model CreateModeDocumentThread, which basically is a fake document thread
with a fake message for its rendering in create mode of the chatter
> special rendering method of thread_widget for such case: `renderChatterCreateMode`
- renamed thread methods previously named `getMessages` to `fetchMessages`:
> in order to not conflict with `getMessages`, used for rendering
> now, `getMessages` always get messages that are locally,
while `fetchMessages` may fetch messages.
TODO:
- special thread model for im_livechat (rendering is broken ATM)
Diffstat (limited to 'addons/mail/static/src/js/thread_windows/abstract_thread_window.js')
| -rw-r--r-- | addons/mail/static/src/js/thread_windows/abstract_thread_window.js | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/addons/mail/static/src/js/thread_windows/abstract_thread_window.js b/addons/mail/static/src/js/thread_windows/abstract_thread_window.js index ae756b6f624..3325cd8be43 100644 --- a/addons/mail/static/src/js/thread_windows/abstract_thread_window.js +++ b/addons/mail/static/src/js/thread_windows/abstract_thread_window.js @@ -46,12 +46,14 @@ var AbstractThreadWindow = Widget.extend({ * * @abstract * @param {Widget} parent - * @param {Object} thread + * @param {Object} thread the thread that this thread window is linked to. * @param {Object} [options={}] */ init: function (parent, thread, options) { this._super(parent); + this._thread = thread; + this.options = _.defaults(options || {}, { autofocus: true, displayStars: true, @@ -174,15 +176,11 @@ var AbstractThreadWindow = Widget.extend({ return this._hidden; }, /** - * Render the thread window, using the provided list of messages - * - * TODO: use messages in thread, instead of providing list of messages - * - * @param {mail.model.AbstractMessage[]} messages + * Render the thread window */ - render: function (messages) { + render: function () { this._renderHeader(); - this.threadWidget.render(messages, { displayLoadMore: false }); + this.threadWidget.render(this._thread, { displayLoadMore: false }); }, /** * Toggle the fold state of this thread window. Also update the fold state @@ -256,12 +254,19 @@ var AbstractThreadWindow = Widget.extend({ }, /** * Get the ID of the related thread. + * If this window is not related to a thread, it means this is the "blank" + * thread window, therefore it returns "_blank" as its ID. * - * @abstract * @private - * @return {integer} + * @returns {integer|string} the threadID, or '_blank' for the window that + * is not related to any thread. */ - _getThreadID: function () {}, + _getThreadID: function () { + if (!this.hasThread()) { + return '_blank'; + } + return this._thread.getID(); + }, /** * Post a message on this thread window * |
