summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authormgh-odoo <mgh@odoo.com>2019-10-23 11:43:29 +0000
committerAlexandre Kühn <aku@odoo.com>2019-11-29 08:56:15 +0000
commit5c004c2e832a9ca6efbe1df1160051ed2cd44c5d (patch)
treeb8ed62b2f83a7cf6a1922f2a141634b6230fea22 /addons/mail/static/src
parentbf18802c1dd00fb9b8b82cd6a884ce6b96eb1f09 (diff)
[IMP] mail: show out of office ribbon on discuss
This commit adds the out-of-office ribbon at the top of the conversation in the discuss app. Task-2066672 closes odoo/odoo#39362 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/js/discuss.js8
-rw-r--r--addons/mail/static/src/js/models/threads/abstract_thread.js6
-rw-r--r--addons/mail/static/src/js/thread_windows/abstract_thread_window.js24
-rw-r--r--addons/mail/static/src/js/thread_windows/thread_window.js7
-rw-r--r--addons/mail/static/src/scss/abstract_thread_window.scss20
-rw-r--r--addons/mail/static/src/scss/out_of_office.scss19
-rw-r--r--addons/mail/static/src/xml/out_of_office.xml13
-rw-r--r--addons/mail/static/src/xml/thread_window.xml21
8 files changed, 58 insertions, 60 deletions
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
@@ -119,6 +119,12 @@ var AbstractThread = Class.extend(Mixins.EventDispatcherMixin, {
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.
* @see {mail.model.ThreadSeenMixin} to enable this feature on a thread.
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,32 +147,10 @@ var AbstractThreadWindow = Widget.extend({
* @returns {mail.model.Thread|undefined}
*/
getThread: function () {
- 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();
+ return this._thread;
},
/**
* Get the status of the thread, such as the im status of a DM chat
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 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<templates xml:space="preserve">
+ <!--
+ @param {mail.model.AbstractThread} thread
+ -->
+ <div class="o_out_of_office" t-name="mail.thread.OutOfOffice">
+ <div class="o_out_of_office_info" t-if="thread.getOutOfOfficeInfo()" t-esc="thread.getOutOfOfficeInfo()"/>
+ <div class="o_out_of_office_text o_text_wrap" t-if="thread.getOutOfOfficeMessage()">
+ <t t-esc="thread.getOutOfOfficeMessage()"/>
+ <a href="#" class="o_out_of_office_read_more_less_button">Read more</a>
+ </div>
+ </div>
+</templates>
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,8 +6,14 @@
-->
<t t-name="mail.ThreadWindow" t-extend="mail.AbstractThreadWindow">
<t t-jquery=".o_thread_window_header" t-operation="after">
- <t t-call="mail.thread_window.OutOfOffice" t-if="widget.getOutOfOfficeInfo() or widget.getOutOfOfficeMessage()"/>
- <div t-if="!widget.hasThread()" class="o_thread_search_input">
+ <t t-if="widget.hasThread()">
+ <t t-if="widget.getThread().hasOutOfOffice()">
+ <t t-call="mail.thread.OutOfOffice">
+ <t t-set="thread" t-value="widget.getThread()"/>
+ </t>
+ </t>
+ </t>
+ <div t-else="" class="o_thread_search_input">
<span> To: </span>
<input type="text" placeholder="User name"/>
</div>
@@ -15,17 +21,6 @@
</t>
<!--
- @param {mail.ThreadWindow} widget
- -->
- <div class="o_out_of_office" t-name="mail.thread_window.OutOfOffice">
- <div class="o_out_of_office_info" t-if="widget.getOutOfOfficeInfo()" t-esc="widget.getOutOfOfficeInfo()"/>
- <div class="o_out_of_office_text o_text_wrap" t-if="widget.getOutOfOfficeMessage()">
- <t t-esc="widget.getOutOfOfficeMessage()"/>
- <a href="#" class="o_out_of_office_read_more_less_button">Read more</a>
- </div>
- </div>
-
- <!--
@param {string} expandTitle text to display on mouse hover (title attribute)
-->
<t t-extend="mail.AbstractThreadWindow.HeaderContent">