diff options
| author | Alexandre Kühn <aku@odoo.com> | 2018-08-24 00:33:10 +0200 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2018-08-27 18:32:58 +0200 |
| commit | eee49f13f00d7e934d399a023ad8d1b4b8ffa6b4 (patch) | |
| tree | 985588b07317f47c0faa129e3eaa81ef0001f0e1 /addons/mail/static/src/js/thread_windows/abstract_thread_window.js | |
| parent | d5786447567b05e85edd43dbefe8e82f22dc2129 (diff) | |
[FIX][REF] mail: several thread windows fixes
This commit fixes some bugs on thread windows, and make some
improvements on tests related to thread windows.
Fixes:
1. Correctly position last visible thread window when there are more
open thread windows than available slots.
2. Closing a thread window now marks it as read.
3. Can now fold/unfold the blank thread window (aka 'New' thread window).
Tests cleaning:
1. Removed unnecessary 'before assertions' in thread window tests.
> Solved with this: https://github.com/odoo/odoo/commit/9b1daa1218f7adf9d741afba607ef5b55b16e3e6
1. Added basic rendering test for a (non-blank) thread window.
2. Cleaned thread window tests
> Split in different files.
> Grouped in 'Thread Window' QUnit module.
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, 19 insertions, 8 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 8d02db587a8..eb8a7da3634 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 @@ -10,9 +10,6 @@ var Widget = require('web.Widget'); var QWeb = core.qweb; var _t = core._t; -var HEIGHT_OPEN = '400px'; -var HEIGHT_FOLDED = '34px'; - /** * This is an abstract widget for rendering thread windows. * @@ -38,6 +35,9 @@ var AbstractThreadWindow = Widget.extend({ 'keydown .o_composer_text_field': '_onKeydown', 'keypress .o_composer_text_field': '_onKeypress', }, + FOLD_ANIMATION_DURATION: 200, // duration in ms for (un)fold transition + HEIGHT_OPEN: '400px', // height in px of thread window when open + HEIGHT_FOLDED: '34px', // height, in px, of thread window when folded /** * Children of this class must make use of `thread`, which is an object that * represent the thread that is linked to this thread window. @@ -85,7 +85,7 @@ var AbstractThreadWindow = Widget.extend({ }); if (this.isFolded()) { - this.$el.css('height', HEIGHT_FOLDED); + this.$el.css('height', this.HEIGHT_FOLDED); } else if (this.options.autofocus) { this._focusInput(); } @@ -301,8 +301,8 @@ var AbstractThreadWindow = Widget.extend({ */ _animateFold: function () { this.$el.animate({ - height: this.isFolded() ? HEIGHT_FOLDED : HEIGHT_OPEN - }, 200); + height: this.isFolded() ? this.HEIGHT_FOLDED : this.HEIGHT_OPEN + }, this.FOLD_ANIMATION_DURATION); }, /** * Set the focus on the composer of the thread window. This operation is @@ -368,6 +368,7 @@ var AbstractThreadWindow = Widget.extend({ }, /** * Update the fold state of the thread. + * * This function is called when toggling the fold state of this window. * If there is no thread linked to this window, it means this is the * "blank" thread window, therefore we use the internal state 'folded' @@ -380,6 +381,7 @@ var AbstractThreadWindow = Widget.extend({ this._thread.fold(folded); } else { this._folded = folded; + this.updateVisualFoldState(); } }, /** @@ -395,7 +397,8 @@ var AbstractThreadWindow = Widget.extend({ //-------------------------------------------------------------------------- /** - * Close the thread + * Close the thread window. + * Mark the thread as read if the thread window was open. * * @private * @param {MouseEvent} ev @@ -403,10 +406,18 @@ var AbstractThreadWindow = Widget.extend({ _onClickClose: function (ev) { ev.stopPropagation(); ev.preventDefault(); + if ( + this.hasThread() && + this._thread.getUnreadCounter() > 0 && + !this.isFolded() + ) { + this._thread.markAsRead(); + } this.close(); }, /** - * Fold/unfold the thread window + * Fold/unfold the thread window. + * Also mark the thread as read. * * @private */ |
