diff --git a/addons/mail/__manifest__.py b/addons/mail/__manifest__.py index e8b8fa765f7..632771a25ff 100644 --- a/addons/mail/__manifest__.py +++ b/addons/mail/__manifest__.py @@ -55,6 +55,7 @@ 'static/src/xml/discuss.xml', 'static/src/xml/followers.xml', 'static/src/xml/systray.xml', + 'static/src/xml/out_of_office.xml', 'static/src/xml/thread.xml', 'static/src/xml/abstract_thread_window.xml', 'static/src/xml/thread_window.xml', diff --git a/addons/mail/static/src/js/discuss.js b/addons/mail/static/src/js/discuss.js index 44a915955da..3d8eda911be 100644 --- a/addons/mail/static/src/js/discuss.js +++ b/addons/mail/static/src/js/discuss.js @@ -940,6 +940,7 @@ var Discuss = AbstractAction.extend({ _setThread: function (threadID) { var self = this; + this.$('.o_out_of_office').remove(); // Store scroll position and composer state of the previous thread this._storeThreadState(); @@ -978,6 +979,13 @@ var Discuss = AbstractAction.extend({ // message self._unselectMessage(); + if (self._thread.hasOutOfOffice()) { + const $outOfOffice = $(QWeb.render('mail.thread.OutOfOffice', { + thread: self._thread + })); + $outOfOffice.prependTo(self.$('.o_mail_discuss_content')); + } + self.action_manager.do_push_state({ action: self.action.id, active_id: self._thread.getID(), diff --git a/addons/mail/static/src/js/models/threads/abstract_thread.js b/addons/mail/static/src/js/models/threads/abstract_thread.js index 192d0e58c93..6961ba48175 100644 --- a/addons/mail/static/src/js/models/threads/abstract_thread.js +++ b/addons/mail/static/src/js/models/threads/abstract_thread.js @@ -118,6 +118,12 @@ var AbstractThread = Class.extend(Mixins.EventDispatcherMixin, { hasMessages: function () { return !_.isEmpty(this.getMessages()); }, + /** + * @return {boolean} + */ + hasOutOfOffice() { + return !!(this.getOutOfOfficeMessage() || this.getOutOfOfficeInfo()); + }, /** * States whether this thread is compatible with the 'seen' feature. * By default, threads do not have thsi feature active. 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 d6a637a0552..27cb97e1f65 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 @@ -147,33 +147,11 @@ var AbstractThreadWindow = Widget.extend({ * @returns {mail.model.Thread|undefined} */ getThread: function () { - if (!this.hasThread) { + if (!this.hasThread()) { return undefined; } return this._thread; }, - /** - *Get out of office info - * - * @returns {string|undefined} - */ - getOutOfOfficeInfo: function () { - if (!this.hasThread()) { - return undefined; - } - return this._thread.getOutOfOfficeInfo(); - }, - /** - * Get out of office user text - * - * @returns {string|undefined} - */ - getOutOfOfficeMessage: function () { - if (!this.hasThread()) { - return undefined; - } - return this._thread.getOutOfOfficeMessage(); - }, /** * Get the status of the thread, such as the im status of a DM chat * ('online', 'offline', etc.). If this window has no thread, returns diff --git a/addons/mail/static/src/js/thread_windows/thread_window.js b/addons/mail/static/src/js/thread_windows/thread_window.js index 08671354a3e..8b4eb03d9db 100644 --- a/addons/mail/static/src/js/thread_windows/thread_window.js +++ b/addons/mail/static/src/js/thread_windows/thread_window.js @@ -148,15 +148,14 @@ var ThreadWindow = AbstractThreadWindow.extend({ }, renderOutOfOffice: function () { var $outOfOffice = this.$('.o_out_of_office'); - if (!this.getOutOfOfficeInfo() && !this.getOutOfOfficeMessage()) { + const thread = this.getThread(); + if (!thread.hasOutOfOffice()) { if ($outOfOffice.length) { $outOfOffice.remove(); } return; } - var $newOutOfOffice = $(QWeb.render('mail.thread_window.OutOfOffice', { - widget: this, - })); + const $newOutOfOffice = $(QWeb.render('mail.thread.OutOfOffice', { thread })); if ($outOfOffice.length) { $outOfOffice.replaceWith($newOutOfOffice); } else { diff --git a/addons/mail/static/src/scss/abstract_thread_window.scss b/addons/mail/static/src/scss/abstract_thread_window.scss index ab868b5dc18..ed001ab3562 100644 --- a/addons/mail/static/src/scss/abstract_thread_window.scss +++ b/addons/mail/static/src/scss/abstract_thread_window.scss @@ -82,26 +82,6 @@ $o-mail-thread-window-zindex: $zindex-modal + 1 !default; } - .o_out_of_office { - background-color: #9dd0e8; - padding:8px; - - .o_out_of_office_info { - font-weight: bold; - } - .o_out_of_office_text { - word-wrap: break-word; - overflow: hidden; - text-overflow: ellipsis; - } - .o_text_wrap { - white-space: nowrap; - } - .o_out_of_office_read_more_less_button { - display: none; - } - } - .o_mail_thread { flex: 1 1 100%; overflow: auto; diff --git a/addons/mail/static/src/scss/out_of_office.scss b/addons/mail/static/src/scss/out_of_office.scss new file mode 100644 index 00000000000..7ddbdd5d355 --- /dev/null +++ b/addons/mail/static/src/scss/out_of_office.scss @@ -0,0 +1,19 @@ +.o_out_of_office { + background-color: #9dd0e8; + padding:8px; + + .o_out_of_office_info { + font-weight: bold; + } + .o_out_of_office_text { + word-wrap: break-word; + overflow: hidden; + text-overflow: ellipsis; + } + .o_text_wrap { + white-space: nowrap; + } + .o_out_of_office_read_more_less_button { + display: none; + } +} diff --git a/addons/mail/static/src/xml/out_of_office.xml b/addons/mail/static/src/xml/out_of_office.xml new file mode 100644 index 00000000000..89723daf5dc --- /dev/null +++ b/addons/mail/static/src/xml/out_of_office.xml @@ -0,0 +1,13 @@ + + + +
+
+
+ + Read more +
+
+ diff --git a/addons/mail/static/src/xml/thread_window.xml b/addons/mail/static/src/xml/thread_window.xml index 3b2cd46f6f5..55d63a0f601 100644 --- a/addons/mail/static/src/xml/thread_window.xml +++ b/addons/mail/static/src/xml/thread_window.xml @@ -6,25 +6,20 @@ --> - -
+ + + + + + + +
To:
- -
-
-
- - Read more -
-
- diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js index 4261f1a5461..bc31013ce52 100644 --- a/addons/mail/static/tests/discuss_tests.js +++ b/addons/mail/static/tests/discuss_tests.js @@ -2024,5 +2024,44 @@ QUnit.test('save filter discuss', async function (assert) { discuss.destroy(); }); +QUnit.test('out-of-office info on discuss', async function (assert) { + assert.expect(3); + + this.data.initMessaging = { + channel_slots: { + channel_direct_message: [{ + id: 1, + channel_type: "chat", + direct_partner: [{ + id: 2, + name: "Someone", + im_status: "", + out_of_office_message: "I'm busy doing nothing", + out_of_office_date_end: false + }], + name: "DM", + }], + }, + }; + const discuss = await createDiscuss({ + context: {}, + params: {}, + data: this.data, + services: this.services, + }); + + const $dmChat = discuss.$('.o_mail_discuss_item[data-thread-id=1]'); + await testUtils.dom.click($dmChat); + assert.containsOnce(discuss, '.o_out_of_office', + 'should contain out of office section on discuss'); + assert.containsOnce(discuss, '.o_out_of_office_text', + 'should contain out of office text on discuss'); + assert.ok( + discuss.$('.o_out_of_office_text').text().trim().includes("I'm busy doing nothing"), + 'should have content of provided out of office text'); + + discuss.destroy(); +}); + }); }); diff --git a/addons/mail/views/mail_templates.xml b/addons/mail/views/mail_templates.xml index 8c67b479df0..90af177ee99 100644 --- a/addons/mail/views/mail_templates.xml +++ b/addons/mail/views/mail_templates.xml @@ -91,6 +91,7 @@ +