[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>
This commit is contained in:
mgh-odoo
2019-11-29 08:56:15 +00:00
committed by Alexandre Kühn
co-authored by Mohammed Shekha
parent bf18802c1d
commit 5c004c2e83
11 changed files with 99 additions and 60 deletions
+1
View File
@@ -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',
+8
View File
@@ -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(),
@@ -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.
@@ -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
@@ -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 {
@@ -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;
@@ -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;
}
}
@@ -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>
+8 -13
View File
@@ -6,25 +6,20 @@
-->
<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>
</t>
</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)
-->
+39
View File
@@ -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();
});
});
});
+1
View File
@@ -91,6 +91,7 @@
<link rel="stylesheet" type="text/scss" href="/mail/static/src/scss/composer.scss"/>
<link rel="stylesheet" type="text/scss" href="/mail/static/src/scss/chatter.scss"/>
<link rel="stylesheet" type="text/scss" href="/mail/static/src/scss/followers.scss"/>
<link rel="stylesheet" type="text/scss" href="/mail/static/src/scss/out_of_office.scss"/>
<link rel="stylesheet" type="text/scss" href="/mail/static/src/scss/thread.scss"/>
<link rel="stylesheet" type="text/scss" href="/mail/static/src/scss/systray.scss"/>
<link rel="stylesheet" type="text/scss" href="/mail/static/src/scss/mail_activity.scss"/>