[FIX] mail, im_livechat: open profile on click livechat correspondent

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) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-02-03 11:45:46 +01:00
committed by Sébastien Theys
parent d2a9ef8297
commit 21d090bf04
4 changed files with 50 additions and 4 deletions
@@ -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();
},
},
},
});
+7
View File
@@ -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
@@ -30,7 +30,7 @@
<div class="position-relative d-flex flex-shrink-0" t-att-class="{ 'flex-row-reverse': isInChatWindowAndIsAlignedRight }">
<div class="o_MessageView_sidebar d-flex flex-shrink-0" t-att-class="{ 'o-message-squashed align-items-start': isSquashed, 'justify-content-center': isInChatWindow }">
<div t-if="!isSquashed" class="o_MessageView_authorAvatarContainer o_MessageView_sidebarItem position-relative">
<img class="o_MessageView_authorAvatar w-100 h-100 rounded-circle o_object_fit_cover" t-att-class="{ 'cursor-pointer': hasAuthorOpenChat, o_redirect: hasAuthorOpenChat }" t-att-src="message.avatarUrl" t-att-role="hasAuthorOpenChat ? 'button' : ''" t-att-tabindex="hasAuthorOpenChat ? '0' : ''" t-on-click="onClickAuthorAvatar" t-att-title="authorTitleText" t-att-alt="authorTitleText"/>
<img class="o_MessageView_authorAvatar w-100 h-100 rounded-circle o_object_fit_cover" t-att-class="{ 'cursor-pointer': hasAuthorClickable, o_redirect: hasAuthorClickable }" t-att-src="message.avatarUrl" t-att-role="hasAuthorClickable ? 'button' : ''" t-att-tabindex="hasAuthorClickable ? '0' : ''" t-on-click="onClickAuthorAvatar" t-att-title="authorTitleText" t-att-alt="authorTitleText"/>
<PersonaImStatusIconView t-if="personaImStatusIconView"
className="'o_MessageView_personaImStatusIcon position-absolute bottom-0 end-0 d-flex align-items-center justify-content-center text-white'"
classNameObj="{
@@ -52,7 +52,7 @@
<div class="o_MessageView_core flex-grow-1">
<div t-if="!isSquashed" class="o_MessageView_header d-flex flex-wrap align-items-baseline" t-att-class="{ 'justify-content-end': isInChatWindowAndIsAlignedRight }">
<t t-if="message.author">
<strong t-if="isShowingAuthorName" class="o_MessageView_authorName o_redirect me-1 text-truncate" t-att-class="{ 'cursor-pointer': hasAuthorOpenChat }" t-att-role="hasAuthorOpenChat ? 'button' : ''" t-att-tabindex="hasAuthorOpenChat ? '0' : ''" t-on-click="onClickAuthorName" t-att-title="authorTitleText">
<strong t-if="isShowingAuthorName" class="o_MessageView_authorName o_redirect me-1 text-truncate" t-att-class="{ 'cursor-pointer': hasAuthorClickable }" t-att-role="hasAuthorClickable ? 'button' : ''" t-att-tabindex="hasAuthorClickable ? '0' : ''" t-on-click="onClickAuthorName" t-att-title="authorTitleText">
<t t-if="message.originThread" t-esc="message.originThread.getMemberName(message.author.persona)"/>
<t t-else="" t-esc="message.author.nameOrDisplayName"/>
</strong>
+19 -2
View File
@@ -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.
*/