[REV] project,mail: disable click on avatar

This reverts commit 0e1961b1dd because the
`no_open_chat` option is removed, this commit becomes useless, that's
why the commit is revert.

task-2633229

Closes #82379
This commit is contained in:
Xavier BOL (xbo)
2022-02-14 13:22:54 +01:00
parent 94153e9765
commit 4099571e24
3 changed files with 4 additions and 112 deletions
+3 -7
View File
@@ -31,7 +31,6 @@ const M2XAvatarMixin = {
throw new Error(`This widget is only supported on many2one and many2many fields pointing to ${JSON.stringify(this.supportedModels)}`);
}
this.className = `${this.className || ''} o_clickable_m2x_avatar`.trim();
this.noOpenChat = this.nodeOptions.no_open_chat || false;
},
//--------------------------------------------------------------------------
@@ -46,11 +45,8 @@ const M2XAvatarMixin = {
* @returns {Promise}
*/
async _openChat(params) {
if (!this.noOpenChat) {
const messaging = await Component.env.services.messaging.get();
return messaging.openChat(params);
}
return Promise.resolve();
const messaging = await Component.env.services.messaging.get();
return messaging.openChat(params);
},
};
@@ -189,7 +185,7 @@ export const Many2OneAvatarUser = Many2OneAvatar.extend(M2XAvatarMixin, {
_onAvatarClicked(ev) {
ev.stopPropagation(); // in list view, prevent from opening the record
this._openChat({ userId: this.value.res_id });
},
}
});
export const KanbanMany2OneAvatarUser = Many2OneAvatarUser.extend({
@@ -313,110 +313,6 @@ QUnit.module('mail', {}, function () {
kanban.destroy();
});
QUnit.test('many2one_avatar_user widget in list view with no_open_chat set to true', async function (assert) {
assert.expect(3);
const { widget: list } = await start({
hasView: true,
View: ListView,
model: 'foo',
data: this.data,
arch: `<tree><field name="user_id" widget="many2one_avatar_user" options="{'no_open_chat': 1}"/></tree>`,
mockRPC(route, args) {
if (args.method === 'read') {
assert.step(`read ${args.model} ${args.args[0]}`);
}
return this._super(...arguments);
},
});
mock.intercept(list, 'open_record', () => {
assert.step('open record');
});
assert.strictEqual(list.$('.o_data_cell span').text(), 'MarioLuigiMarioYoshi');
// sanity check: later on, we'll check that clicking on the avatar doesn't open the record
await dom.click(list.$('.o_data_row:first span'));
await dom.click(list.$('.o_data_cell:nth(0) .o_m2o_avatar > img'));
await dom.click(list.$('.o_data_cell:nth(1) .o_m2o_avatar > img'));
await dom.click(list.$('.o_data_cell:nth(2) .o_m2o_avatar > img'));
assert.verifySteps([
'open record',
]);
list.destroy();
});
QUnit.test('many2one_avatar_user widget in kanban view', async function (assert) {
assert.expect(3);
const { widget: kanban } = await start({
hasView: true,
View: KanbanView,
model: 'foo',
data: this.data,
arch: `
<kanban>
<templates>
<t t-name="kanban-box">
<div>
<field name="user_id" widget="many2one_avatar_user" options="{'no_open_chat': 1}"/>
</div>
</t>
</templates>
</kanban>`,
});
assert.strictEqual(kanban.$('.o_kanban_record').text().trim(), '');
assert.containsN(kanban, '.o_m2o_avatar', 4);
dom.click(kanban.$('.o_m2o_avatar:nth(0) > img'));
dom.click(kanban.$('.o_m2o_avatar:nth(1) > img'));
dom.click(kanban.$('.o_m2o_avatar:nth(2) > img'));
dom.click(kanban.$('.o_m2o_avatar:nth(3) > img'));
assert.verifySteps([], "no read res.user should be done since we don't want to open chat when the user clicks on avatar.");
kanban.destroy();
});
QUnit.test('many2many_avatar_user widget in form view', async function (assert) {
assert.expect(5);
const { widget: form } = await start({
hasView: true,
View: FormView,
model: 'foo',
data: this.data,
arch: `<form><field name="user_ids" widget="many2many_avatar_user" options="{'no_open_chat': 1}"/></form>`,
mockRPC(route, args) {
if (args.method === 'read') {
assert.step(`read ${args.model} ${args.args[0]}`);
}
return this._super(...arguments);
},
res_id: 1,
});
assert.containsN(form, '.o_field_many2manytags.avatar.o_field_widget .badge', 2,
"should have 2 records");
assert.strictEqual(form.$('.o_field_many2manytags.avatar.o_field_widget .badge:first img').data('src'), '/web/image/res.users/11/avatar_128',
"should have correct avatar image");
await dom.click(form.$('.o_field_many2manytags.avatar .badge:first .o_m2m_avatar'));
await dom.click(form.$('.o_field_many2manytags.avatar .badge:nth(1) .o_m2m_avatar'));
assert.verifySteps([
"read foo 1",
'read res.users 11,23',
]);
form.destroy();
});
QUnit.test('many2one_avatar_user widget edited by the smart action "Assign to..."', async function (assert) {
assert.expect(4);
@@ -103,7 +103,7 @@
</span>
<field name="kanban_state" widget="state_selection"/>
<!-- TODO: [XBO] remove me in master -->
<field name="user_ids" string="Assignees" widget="many2many_avatar_user" options="{'no_open_chat': True}" invisible="1"/>
<field name="user_ids" string="Assignees" widget="many2many_avatar_user" invisible="1"/>
</div>
</div>
</div>