[REV] mail: open partner/employee form on chat header click

This reverts commit c3c01633ce.

task-2252924

closes odoo/odoo#65001

X-original-commit: 3a32fd92b81d889072884097bb936d4a4e8a89cf
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2021-01-25 12:56:26 +00:00
parent 419337782f
commit 196ca9ea3a
4 changed files with 1 additions and 81 deletions
@@ -24,13 +24,11 @@ class ChatWindowHeader extends Component {
useStore(props => {
const chatWindow = this.env.models['mail.chat_window'].get(props.chatWindowLocalId);
const thread = chatWindow && chatWindow.thread;
const correspondent = thread && thread.correspondent;
return {
chatWindow,
chatWindowHasShiftNext: chatWindow && chatWindow.hasShiftNext,
chatWindowHasShiftPrev: chatWindow && chatWindow.hasShiftPrev,
chatWindowName: chatWindow && chatWindow.name,
correspondent,
isDeviceMobile: this.env.messaging.device.isMobile,
thread,
threadLocalMessageUnreadCounter: thread && thread.localMessageUnreadCounter,
@@ -79,9 +77,6 @@ class ChatWindowHeader extends Component {
* @param {MouseEvent} ev
*/
_onClick(ev) {
if (isEventHandled(ev, 'ChatWindowHeader.openProfile')) {
return;
}
if (isEventHandled(ev, 'ChatWindowHeader.ClickShiftNext')) {
return;
}
@@ -92,17 +87,6 @@ class ChatWindowHeader extends Component {
this.trigger('o-clicked', { chatWindow });
}
/**
* @private
* @param {MouseEvent} ev
*/
_onClickName(ev) {
if (this.chatWindow.thread && this.chatWindow.thread.correspondent) {
markEventHandled(ev, 'ChatWindowHeader.openProfile');
this.chatWindow.thread.correspondent.openProfile();
}
}
/**
* @private
* @param {MouseEvent} ev
@@ -52,11 +52,6 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
&.o-clickable:hover {
font-weight: $font-weight-bold;
text-decoration: $link-hover-decoration;
}
}
.o_ChatWindowHeader_rightArea {
@@ -15,7 +15,7 @@
threadLocalId="chatWindow.thread.localId"
/>
</t>
<div class="o_ChatWindowHeader_item o_ChatWindowHeader_name" t-att-title="chatWindow.name" t-att-class="{'o-clickable': chatWindow.thread and chatWindow.thread.correspondent}" t-on-click="_onClickName">
<div class="o_ChatWindowHeader_item o_ChatWindowHeader_name" t-att-title="chatWindow.name">
<t t-esc="chatWindow.name"/>
</div>
<t t-if="chatWindow.thread and chatWindow.thread.mass_mailing">
@@ -10,12 +10,9 @@ const {
start,
} = require('mail/static/src/utils/test_utils.js');
const Bus = require('web.Bus');
const core = require('web.core');
const {
file: { createFile, inputFiles },
dom: { triggerEvent },
makeTestPromise,
} = require('web.test_utils');
QUnit.module('mail', {}, function () {
@@ -2138,62 +2135,6 @@ QUnit.test('focusing a chat window of a chat should make new message separator d
);
});
QUnit.test('chat window: click on correspondent name in chat header redirects to user form', async function (assert) {
assert.expect(4);
this.data['res.partner'].records.push({ id: 7, name: "Demo" });
this.data['mail.channel'].records.push({
channel_type: "chat",
is_minimized: true,
members: [this.data.currentPartnerId, 7],
});
const partnerFormDeferred = makeTestPromise();
const bus = new Bus();
bus.on('do-action', null, payload => {
assert.step('action_open_partner_form');
assert.deepEqual(payload.action, {
res_id: 7,
res_model: "res.partner",
type: "ir.actions.act_window",
views: [[false, "form"]]
}, "opened form view should be the form view displaying the clicked correspondent (partner 7)");
partnerFormDeferred.resolve();
});
await this.start({ env: { bus } });
const chatWindowHeaderName = document.querySelector('.o_ChatWindowHeader_name');
assert.hasClass(
chatWindowHeaderName,
'o-clickable',
"name of thread in header part of chat window should be clickable when thread has a single correspondent"
);
await chatWindowHeaderName.click();
await partnerFormDeferred;
assert.verifySteps(
['action_open_partner_form'],
"should open partner form on click of chat header name when the thread has single correspondent"
);
});
QUnit.test('chat window: chat header should not be clickable when thread has multiple correspondents', async function (assert) {
assert.expect(1);
this.data['res.partner'].records.push({ id: 7, name: "Demo" }, { id: 8, name: "Portal" });
this.data['mail.channel'].records.push({
channel_type: "channel",
is_minimized: true,
members: [this.data.currentPartnerId, 7, 8],
});
await this.start();
const chatWindowHeader = document.querySelector('.o_ChatWindowHeader_name');
assert.doesNotHaveClass(
chatWindowHeader,
'o-clickable',
"name of thread in header part of chat window should not be clickable when thread has multiple correspondents"
);
});
QUnit.test('Textual representations of shift previous/next operations are correctly mapped to left/right in LTR locale', async function (assert) {
assert.expect(2);