From 21d090bf0410d352b12b26d0feeb3dd6187bf5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Wed, 25 Jan 2023 12:24:33 +0000 Subject: [PATCH] [FIX] mail, im_livechat: open profile on click livechat correspondent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, clicking on message author opens chat with author, including in a livechat conversation. This feature is not useful in livechat, as there's already a way to communicate with the visitor. In earlier versions, click on author opens profile, which is quite useful. This commit puts back this feature of opening profile from author click in livechat. closes odoo/odoo#111799 X-original-commit: 2b43fb452c28554d5b3659e8531ad4de11686153 Signed-off-by: Alexandre Kühn (aku) Signed-off-by: Sébastien Theys (seb) --- .../static/src/models/message_view.js | 22 +++++++++++++++++++ addons/mail/i18n/mail.pot | 7 ++++++ .../static/src/components/message/message.xml | 4 ++-- addons/mail/static/src/models/message_view.js | 21 ++++++++++++++++-- 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 addons/im_livechat/static/src/models/message_view.js diff --git a/addons/im_livechat/static/src/models/message_view.js b/addons/im_livechat/static/src/models/message_view.js new file mode 100644 index 00000000000..beacd7071ef --- /dev/null +++ b/addons/im_livechat/static/src/models/message_view.js @@ -0,0 +1,22 @@ +/** @odoo-module **/ + +import { Patch } from '@mail/model'; + +Patch({ + name: "MessageView", + fields: { + hasAuthorClickable: { + compute() { + if ( + this.message && + this.message.originThread && + this.message.originThread.channel && + this.message.originThread.channel.channel_type === "livechat" + ) { + return this.message.author === this.message.originThread.channel.correspondent; + } + return this._super(); + }, + }, + }, +}); diff --git a/addons/mail/i18n/mail.pot b/addons/mail/i18n/mail.pot index 67be94ccc2c..07fca3a8c52 100644 --- a/addons/mail/i18n/mail.pot +++ b/addons/mail/i18n/mail.pot @@ -6665,6 +6665,13 @@ msgstr "" msgid "Open chat" msgstr "" +#. module: mail +#. odoo-javascript +#: code:addons/mail/static/src/models/message_view.js:0 +#, python-format +msgid "Open profile" +msgstr "" + #. module: mail #. odoo-javascript #: code:addons/mail/static/src/models/call_systray_menu.js:0 diff --git a/addons/mail/static/src/components/message/message.xml b/addons/mail/static/src/components/message/message.xml index e96eef8fa04..bc691942c06 100644 --- a/addons/mail/static/src/components/message/message.xml +++ b/addons/mail/static/src/components/message/message.xml @@ -30,7 +30,7 @@
- +
- + diff --git a/addons/mail/static/src/models/message_view.js b/addons/mail/static/src/models/message_view.js index b685547f642..e2e1e5f2ecf 100644 --- a/addons/mail/static/src/models/message_view.js +++ b/addons/mail/static/src/models/message_view.js @@ -79,7 +79,11 @@ Model({ */ onClickAuthorAvatar(ev) { markEventHandled(ev, "Message.ClickAuthorAvatar"); + if (!this.message.author || !this.hasAuthorClickable) { + return; + } if (!this.hasAuthorOpenChat) { + this.message.author.openProfile(); return; } this.message.author.openChat(); @@ -89,7 +93,11 @@ Model({ */ onClickAuthorName(ev) { markEventHandled(ev, "Message.ClickAuthorName"); - if (!this.message.author) { + if (!this.message.author || !this.hasAuthorClickable) { + return; + } + if (!this.hasAuthorOpenChat) { + this.message.author.openProfile(); return; } this.message.author.openChat(); @@ -342,7 +350,11 @@ Model({ }), authorTitleText: attr({ compute() { - return this.hasAuthorOpenChat ? this.env._t("Open chat") : ""; + return this.hasAuthorOpenChat + ? this.env._t("Open chat") + : this.hasAuthorClickable + ? this.env._t("Open profile") + : ""; }, }), clockWatcher: one("ClockWatcher", { @@ -447,6 +459,11 @@ Model({ return true; }, }), + hasAuthorClickable: attr({ + compute() { + return this.hasAuthorOpenChat; + }, + }), /** * Current timer that will reset isHighlighted to false. */