[IMP] mail: display white background for user notifications in chatter

User notifications are defined as
 * notes;
 * pushed to user Inbox or email through classic notification process;
 * not linked to any document, meaning model and res_id are void;

When pushed in user's Inbox they are currently displayed with a gray
background like all notes. However UX experts think it should use a white
background to be easier to spot in chatter. This commit makes it work.
From now on discussion and user's notifications are displayed using a white
background. This commit is related to task ID 1829872.
This commit is contained in:
Thibault Delavallée
2018-04-10 17:15:26 +02:00
parent 07ae0ccc4e
commit 3f7c75ef1f
6 changed files with 10 additions and 2 deletions
@@ -237,6 +237,7 @@ var LivechatButton = Widget.extend({
is_needaction: false,
is_note: data.is_note,
is_discussion: data.is_discussion,
is_notification: data.is_notification,
customer_email_data: []
};
+3 -1
View File
@@ -392,8 +392,9 @@ class Message(models.Model):
'message_type': u'comment',
'id': 59,
'subject': False
'is_note': True # only if the subtype is internal
'is_note': True # only if the message is a note (subtype == note)
'is_discussion': False # only if the message is a discussion (subtype == discussion)
'is_notification': False # only if the message is a note but is a notification aka not linked to a document like assignation
}
"""
message_values = self.read([
@@ -419,6 +420,7 @@ class Message(models.Model):
for message in message_values:
message['is_note'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['id'] == note_id
message['is_discussion'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['id'] == com_id
message['is_notification'] = message['is_note'] and not message['model'] and not message['res_id']
message['subtype_description'] = message['subtype_id'] and subtypes_dict[message['subtype_id'][0]]['description']
if message['model'] and self.env[message['model']]._original_module:
message['module_icon'] = modules.module.get_module_icon(self.env[message['model']]._original_module)
@@ -1314,6 +1314,7 @@ var ChatManager = AbstractService.extend({
* @param {string} [data.info]
* @param {boolean} data.is_discussion
* @param {boolean} data.is_note
* @param {boolean} data.is_notification
* @param {string} data.message_type
* @param {string} [data.model]
* @param {boolean} data.module_icon src url of the module icon
@@ -1336,6 +1337,7 @@ var ChatManager = AbstractService.extend({
is_author: data.author_id && data.author_id[0] === session.partner_id,
is_note: data.is_note,
is_discussion: data.is_discussion,
is_notification: data.is_notification,
is_system_notification: (data.message_type === 'notification' && data.model === 'mail.channel')
|| data.info === 'transient_message',
attachment_ids: data.attachment_ids || [],
+1 -1
View File
@@ -121,7 +121,7 @@
</t>
<t t-name="mail.ChatThread.Message">
<div t-att-class="'o_thread_message' + (message.expanded ? ' o_message_expanded ' : ' ') + (message.is_selected ? 'o_thread_selected_message' : '') + (message.is_discussion ? ' o_mail_discussion' : ' o_mail_not_discussion')" t-att-data-message-id="message.id">
<div t-att-class="'o_thread_message' + (message.expanded ? ' o_message_expanded ' : ' ') + (message.is_selected ? 'o_thread_selected_message' : '') + (message.is_discussion or message.is_notification ? ' o_mail_discussion' : ' o_mail_not_discussion')" t-att-data-message-id="message.id">
<div t-if="options.display_avatar" class="o_thread_message_sidebar">
<t t-if="!message.mailto and message.author_id[0]">
<img t-if="message.avatar_src and message.display_author"
@@ -37,6 +37,7 @@ QUnit.module('mail', {
id: 1,
is_note: false,
is_discussion: true,
is_notification: false,
is_starred: false,
model: 'partner',
res_id: 2
@@ -389,6 +389,7 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
id: 1,
is_note: false,
is_discussion: true,
is_notification: false,
is_starred: false,
model: 'partner',
res_id: 2,
@@ -433,6 +434,7 @@ QUnit.test('chatter: post, receive and star messages', function (assert) {
id: msg_id,
is_note: args.kwargs.subtype === 'mail.mt_note',
is_discussion: args.kwargs.subtype === 'mail.mt_comment',
is_notification: false,
is_starred: false,
model: 'partner',
res_id: 2,