Skip to content
Permalink
Browse files

[IMP] mail: improve document chat window

1. In the systray messaging menu, when hovering on a notification
linked to a document chat, it now shows an "expand" icon. Clicking
on icon opens the corresponding form view with the chatter.

2. Messages in a document chat window no longer show linked document
in their header, as this is redundant with title of chat window.

3. Font size of words "on" and "from" in header of message in chat
windows have been reduced in order to closely match font size of
document link.

Task-ID 1929169
  • Loading branch information...
ppr-odoo authored and alexkuhn committed Feb 22, 2019
1 parent 0a09a4d commit 7c277041611756e4e30040896fe749a539fd99f8
@@ -260,6 +260,7 @@ var Message = AbstractMessage.extend(Mixins.EventDispatcherMixin, ServicesMixin
messageID: this.getID(),
status: this.status,
title: title,
isLinkedToDocumentThread: this.isLinkedToDocumentThread(),
};
},
/**
@@ -24,6 +24,7 @@ var MessagingMenu = Widget.extend({
'click .o_filter_button': '_onClickFilterButton',
'click .o_new_message': '_onClickNewMessage',
'click .o_mail_preview_mark_as_read': '_onClickPreviewMarkAsRead',
'click .o_thread_window_expand': '_onClickExpand',
'show.bs.dropdown': '_onShowDropdown',
},
/**
@@ -246,6 +247,19 @@ var MessagingMenu = Widget.extend({
_onShowDropdown: function () {
this._updatePreviews();
},
/**
* Opens the related document
*
* @private
* @param {MouseEvent} ev
*/
_onClickExpand: function (ev) {
ev.stopPropagation();
var $preview = $(ev.currentTarget).closest('.o_mail_preview');
var documentModel = $preview.data('document-model');
var documentID = $preview.data('document-id');
this._openDocument(documentModel, documentID);
},
/**
* @private
* @param {MouseEvent} ev
@@ -77,11 +77,14 @@ var AbstractThreadWindow = Widget.extend({
var self = this;
this.$input = this.$('.o_composer_text_field');
this.$header = this.$('.o_thread_window_header');

this._threadWidget = new ThreadWidget(this, {
displayMarkAsRead: false,
displayStars: this.options.displayStars,
});
var options = {
displayMarkAsRead: false,
displayStars: this.options.displayStars,
};
if (this._thread && this._thread._type === 'document_thread') {
options.displayDocumentLinks = false;
}
this._threadWidget = new ThreadWidget(this, options);

// animate the (un)folding of thread windows
this.$el.css({transition: 'height ' + this.FOLD_ANIMATION_DURATION + 'ms linear'});
@@ -362,6 +362,7 @@
flex: 1 1 100%;
overflow: hidden;
.o_preview_title {
align-items: center;
display: flex;
.o_preview_name {
flex: 0 1 auto;
@@ -378,7 +379,10 @@
padding-right: 0px;
}
.o_preview_counter {
flex: 1 1 auto;
flex: 0 1 auto;
}
.o_thread_window_expand {
margin: 0px 6px;
}
.o_last_message_date {
flex: 0 0 auto;
@@ -316,7 +316,8 @@
<span class="o_preview_counter">
<t t-if="preview.unreadCounter &gt; 0">&amp;nbsp;(<t t-esc="preview.unreadCounter"/>)</t>
</span>
<span class="o_last_message_date"> <t t-esc="preview.date ? preview.date.fromNow() : ''"/> </span>
<span t-if="preview.isLinkedToDocumentThread" class="o_discuss_icon o_thread_window_expand fa fa-expand"/>
<span class="o_last_message_date ml-auto mr-2"> <t t-esc="preview.date ? preview.date.fromNow() : ''"/> </span>
</div>
<div class="o_last_message_preview">
<t t-if="preview.body">
@@ -308,10 +308,10 @@

- <small class="o_mail_timestamp" t-att-title="message.getDate().format(dateFormat)"><t t-esc="message.getTimeElapsed()"/></small>
<t t-if="message.isLinkedToDocumentThread() and options.displayDocumentLinks">
on <a t-att-href="message.getURL()" t-att-data-oe-model="message.getDocumentModel()" t-att-data-oe-id="message.getDocumentID()" class="o_document_link"><t t-esc="message.getDocumentName()"/></a>
<small>on</small> <a t-att-href="message.getURL()" t-att-data-oe-model="message.getDocumentModel()" t-att-data-oe-id="message.getDocumentID()" class="o_document_link"><t t-esc="message.getDocumentName()"/></a>
</t>
<t t-if="message.originatesFromChannel() and (message.getOriginChannelID() !== thread.getID())">
(from <a t-att-data-oe-id="message.getOriginChannelID()" href="#">#<t t-esc="message.getOriginChannelName()"/></a>)
(<small>from</small> <a t-att-data-oe-id="message.getOriginChannelID()" href="#">#<t t-esc="message.getOriginChannelName()"/></a>)
</t>
<span t-if="options.displayEmailIcons and (message.hasCustomerEmailData() or ['exception', 'bounce'].indexOf(message._customerEmailStatus) > -1)" class="o_thread_tooltip_container">

@@ -881,5 +881,44 @@ QUnit.test('messaging menu widget: do not open chat window twice on preview clic
messagingMenu.destroy();
});

QUnit.test('messaging menu widget: expand on thread preview', async function (assert) {
assert.expect(4);

this.data['mail.message'].records.push({
author_id: [1, "Demo"],
body: "<p>Office Design Project</p>",
res_id: 123,
model: 'some.res.model',
needaction: true,
needaction_partner_ids: [44],
});

var messagingMenu = new MessagingMenu();
testUtils.mock.addMockEnvironment(messagingMenu, {
services: this.services,
data: this.data,
session: { partner_id: 44 },
intercepts: {
do_action: function (ev) {
const { res_model, res_id } = ev.data.action;
if (res_model === 'some.res.model' && res_id === 123) {
assert.step('open_document');
}
},
},
});
await messagingMenu.appendTo($('#qunit-fixture'));

await testUtils.dom.click(messagingMenu.$('.dropdown-toggle'));
var $preview = messagingMenu.$('.o_mail_preview');
assert.containsOnce(messagingMenu, '.o_thread_window_expand', "should display one preview");
assert.strictEqual($preview.data('document-model'), "some.res.model", "preview should be from some.res.model");

await testUtils.dom.click($preview.find('.o_thread_window_expand'));
assert.verifySteps(['open_document']);

messagingMenu.destroy();
});

});
});

0 comments on commit 7c27704

Please sign in to comment.
You can’t perform that action at this time.