summaryrefslogtreecommitdiff
path: root/addons/mail/static/src
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-07-13 12:56:55 +0000
committerXavier Dubuc <xdu@odoo.com>2020-07-16 15:53:02 +0000
commitdecf5147d1fb5569c3036d2ff45aa9350f28aa00 (patch)
treefe3de3760fdbb1ba92b5f1b8ba5322f9cc8ec01c /addons/mail/static/src
parent9afee4f2eb4a0c421d2e0eaffd1e968ca7f84dfb (diff)
[FIX] mail: show subject of the message in inbox if set
task-2280146 closes odoo/odoo#54599 X-original-commit: 3114c7dab3c7f0f63e59f01fd06237fdc109203a Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src')
-rw-r--r--addons/mail/static/src/components/discuss/tests/discuss_inbox_tests.js93
-rw-r--r--addons/mail/static/src/components/message/message.xml3
-rw-r--r--addons/mail/static/src/components/thread_viewer/thread_viewer_tests.js46
3 files changed, 142 insertions, 0 deletions
diff --git a/addons/mail/static/src/components/discuss/tests/discuss_inbox_tests.js b/addons/mail/static/src/components/discuss/tests/discuss_inbox_tests.js
index 7cb962c1b27..4cd20d7632b 100644
--- a/addons/mail/static/src/components/discuss/tests/discuss_inbox_tests.js
+++ b/addons/mail/static/src/components/discuss/tests/discuss_inbox_tests.js
@@ -411,6 +411,99 @@ QUnit.test('"reply to" composer should send message if message replied to is not
assert.verifySteps(['message_post']);
});
+QUnit.test('show subject of message in inbox', async function (assert) {
+ assert.expect(3);
+
+ this.data['mail.message'].records = [{
+ author_id: [7, "Demo"],
+ body: "<p>Test</p>",
+ date: "2019-04-20 11:00:00",
+ id: 100,
+ is_discussion: false,
+ is_notification: false,
+ message_type: 'comment',
+ needaction: true,
+ needaction_partner_ids: [3],
+ model: 'mail.channel',
+ res_id: 20,
+ subject: "Salutations, voyageur",
+ }];
+
+ await this.start({
+ env: {
+ session: {
+ name: 'Admin',
+ partner_display_name: 'Your Company, Admin',
+ partner_id: 3,
+ uid: 2,
+ },
+ },
+ });
+ assert.containsOnce(
+ document.body,
+ '.o_Message',
+ "should display a single message"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message_subject',
+ "should display subject of the message"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_Message_subject').textContent,
+ "Subject: Salutations, voyageur",
+ "Subject of the message should be 'Salutations, voyageur'"
+ )
+});
+
+QUnit.test('show subject of message in history', async function (assert) {
+ assert.expect(3);
+
+ this.data['mail.message'].records = [{
+ author_id: [7, "Demo"],
+ body: "<p>Test</p>",
+ date: "2019-04-20 11:00:00",
+ history_partner_ids: [3],
+ id: 100,
+ message_type: 'comment',
+ model: 'project.task',
+ record_name: "Refactoring",
+ res_id: 20,
+ subject: "Salutations, voyageur",
+ }];
+
+ await this.start({
+ discuss: {
+ params: {
+ default_active_id: 'mail.box_history',
+ },
+ },
+ env: {
+ session: {
+ name: 'Admin',
+ partner_display_name: 'Your Company, Admin',
+ partner_id: 3,
+ uid: 2,
+ },
+ },
+ });
+ assert.containsOnce(
+ document.body,
+ '.o_Message',
+ "should display a single message"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message_subject',
+ "should display subject of the message"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_Message_subject').textContent,
+ "Subject: Salutations, voyageur",
+ "Subject of the message should be 'Salutations, voyageur'"
+ )
+});
+
});
});
});
diff --git a/addons/mail/static/src/components/message/message.xml b/addons/mail/static/src/components/message/message.xml
index 787a34c9006..fecc16d4be4 100644
--- a/addons/mail/static/src/components/message/message.xml
+++ b/addons/mail/static/src/components/message/message.xml
@@ -180,6 +180,9 @@
</ul>
</t>
</div>
+ <t t-if="message.subject and threadViewer and threadViewer.thread and (threadViewer.thread.mass_mailing or [env.messaging.inbox, env.messaging.history].includes(threadViewer.thread))">
+ <p class="o_Message_subject">Subject: <t t-esc="message.subject"/></p>
+ </t>
<t t-if="message.attachments and message.attachments.length > 0">
<div class="o_Message_footer">
<!-- TODO XDU This does not allow to preview all attachments at once, find somethind else -->
diff --git a/addons/mail/static/src/components/thread_viewer/thread_viewer_tests.js b/addons/mail/static/src/components/thread_viewer/thread_viewer_tests.js
index 6276cf11ca5..0242785795e 100644
--- a/addons/mail/static/src/components/thread_viewer/thread_viewer_tests.js
+++ b/addons/mail/static/src/components/thread_viewer/thread_viewer_tests.js
@@ -430,6 +430,52 @@ QUnit.test('mark channel as fetched and seen when a new message is loaded if com
"Channel should have been mark as seen directly"
);
});
+
+QUnit.test('show message subject if thread is mailing channel', async function (assert) {
+ assert.expect(3);
+
+ this.data['mail.message'].records = [{
+ author_id: [7, "Demo"],
+ body: "<p>Test</p>",
+ channel_ids: [100],
+ date: "2019-04-20 11:00:00",
+ id: 100,
+ is_discussion: false,
+ is_notification: false,
+ message_type: 'comment',
+ model: 'mail.channel',
+ res_id: 20,
+ subject: "Salutations, voyageur",
+ }];
+ await this.start();
+ const thread = this.env.models['mail.thread'].create({
+ channel_type: 'channel',
+ id: 100,
+ mass_mailing: true,
+ model: 'mail.channel',
+ name: "General",
+ public: 'public',
+ });
+ const threadViewer = this.env.models['mail.thread_viewer'].create({ thread: [['link', thread]] });
+ await this.createThreadViewerComponent(threadViewer);
+
+ assert.containsOnce(
+ document.body,
+ '.o_Message',
+ "should display a single message"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Message_subject',
+ "should display subject of the message"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_Message_subject').textContent,
+ "Subject: Salutations, voyageur",
+ "Subject of the message should be 'Salutations, voyageur'"
+ )
+});
+
});
});
});