[IMP] mail: composer / chatter new followers email address tooltips
Before this commit, many2many email tags showed the recipient's name and email address. Most of the time, the text was cut off in order to fit in the maximum length of a many2many tag, so the email address was usually not visible. With this commit, many2many email tags now show only the recipient's name. The recipient's email address is displayed when hovering on the tag. Task-ID 36677
This commit is contained in:
committed by
Alexandre Kühn
parent
71de0c47f8
commit
78d681d14f
@@ -21,9 +21,9 @@ BasicModel.include({
|
||||
* @param {Object} record - an element from the localData
|
||||
* @param {string} fieldName
|
||||
* @return {Deferred<Object>} the deferred is resolved with the
|
||||
* invalidPartnerIds and partnerNames
|
||||
* invalidPartnerIds
|
||||
*/
|
||||
_fetchSpecialMany2ManyTagsEmail: function (record, fieldName) {
|
||||
_setInvalidMany2ManyTagsEmail: function (record, fieldName) {
|
||||
var self = this;
|
||||
var localID = (record._changes && fieldName in record._changes) ?
|
||||
record._changes[fieldName] :
|
||||
@@ -43,30 +43,19 @@ BasicModel.include({
|
||||
def = this._applyX2ManyChange(record, fieldName, changes);
|
||||
}
|
||||
return $.when(def).then(function () {
|
||||
list = self._applyX2ManyOperations(self.localData[localID]);
|
||||
if (list.res_ids.length) {
|
||||
def = self._rpc({
|
||||
model: list.model,
|
||||
method: 'name_get',
|
||||
args: [list.res_ids],
|
||||
context: record.getContext({fieldName: fieldName}),
|
||||
});
|
||||
}
|
||||
return $.when(def).then(function (names) {
|
||||
return $.when({
|
||||
invalidPartnerIds: _.pluck(invalidPartnerIds, 'res_id'),
|
||||
partnerNames: _.object(names),
|
||||
});
|
||||
return $.when({
|
||||
invalidPartnerIds: _.pluck(invalidPartnerIds, 'res_id'),
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
var FieldMany2ManyTagsEmail = M2MTags.extend({
|
||||
tag_template: "FieldMany2ManyTagsEmail",
|
||||
fieldsToFetch: _.extend({}, M2MTags.prototype.fieldsToFetch, {
|
||||
email: {type: 'char'},
|
||||
}),
|
||||
specialData: "_fetchSpecialMany2ManyTagsEmail",
|
||||
specialData: "_setInvalidMany2ManyTagsEmail",
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
@@ -139,24 +128,6 @@ var FieldMany2ManyTagsEmail = M2MTags.extend({
|
||||
return _super.apply(self, arguments);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Override for res.partner
|
||||
* name_get is dynamic (based on context) while display_name is static
|
||||
* (stored)
|
||||
*
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
_getRenderTagsContext: function () {
|
||||
var result = this._super.apply(this, arguments);
|
||||
var partnerNames = this.record.specialData[this.name].partnerNames;
|
||||
_.each(result.elements, function (partner) {
|
||||
partner.display_name = partnerNames[partner.id];
|
||||
});
|
||||
return result;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
field_registry.add('many2many_tags_email', FieldMany2ManyTagsEmail);
|
||||
|
||||
@@ -76,4 +76,9 @@
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-name="FieldMany2ManyTagsEmail" t-extend="FieldMany2ManyTag">
|
||||
<t t-jquery=".o_badge_text" t-operation="replace">
|
||||
<span class="o_badge_text" t-attf-title="#{el.email}"><t t-esc="el.display_name"/></span>
|
||||
</t>
|
||||
</t>
|
||||
</templates>
|
||||
|
||||
@@ -1336,7 +1336,6 @@ QUnit.module('FieldMany2ManyTagsEmail', {
|
||||
QUnit.test('fieldmany2many tags email', function (assert) {
|
||||
assert.expect(13);
|
||||
var done = assert.async();
|
||||
var nameGottenIds = [[12], [12, 14]];
|
||||
|
||||
this.data.partner.records[0].timmy = [12, 14];
|
||||
|
||||
@@ -1356,11 +1355,7 @@ QUnit.test('fieldmany2many tags email', function (assert) {
|
||||
mode: 'edit',
|
||||
},
|
||||
mockRPC: function (route, args) {
|
||||
if (route === "/web/dataset/call_kw/partner_type/name_get") {
|
||||
assert.deepEqual(args.args[0], nameGottenIds.shift(),
|
||||
"partner with email should be name_get'ed");
|
||||
}
|
||||
else if (args.method ==='read' && args.model === 'partner_type') {
|
||||
if (args.method ==='read' && args.model === 'partner_type') {
|
||||
assert.step(args.args[0]);
|
||||
assert.deepEqual(args.args[1] , ['display_name', 'email'], "should read the email");
|
||||
}
|
||||
@@ -1373,8 +1368,12 @@ QUnit.test('fieldmany2many tags email', function (assert) {
|
||||
// should read it 3 times (1 with the form view, one with the form dialog and one after save)
|
||||
assert.verifySteps([[12, 14], [14], [14]]);
|
||||
assert.strictEqual(form.$('.o_field_many2manytags[name="timmy"] span.o_tag_color_0').length, 2,
|
||||
"the second tag should be present");
|
||||
|
||||
"two tags should be present");
|
||||
var firstTag = form.$('.o_field_many2manytags[name="timmy"] span.o_tag_color_0').first();
|
||||
assert.strictEqual(firstTag.find('.o_badge_text').text(), "gold",
|
||||
"tag should only show display_name");
|
||||
assert.strictEqual(firstTag.find('.o_badge_text').attr('title'), "coucou@petite.perruche",
|
||||
"tag should show email address on mouse hover");
|
||||
form.destroy();
|
||||
done();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user