Skip to content
Permalink
Browse files

[IMP]Improve title attribute, make it translatable

  • Loading branch information...
msh-odoo committed Apr 12, 2019
1 parent f992b18 commit 0e0a25c9d1aae9127cf227873890b784c4a442a2
@@ -1965,6 +1965,9 @@ var FieldMany2ManyTags = AbstractField.extend({
}

this.colorField = this.nodeOptions.color_field;
this.colornames = [_t('No color'), _t('Red'), _t('Orange'), _t('Yellow'), _t('Light blue'),
_t('Dark purple'), _t('Salmon pink'), _t('Medium blue'), _t('Dark blue'), _t('Fushia'),
_t('Green'), _t('Purple')];
this.hasDropdown = false;
},

@@ -2033,6 +2036,7 @@ var FieldMany2ManyTags = AbstractField.extend({
var elements = this.value ? _.pluck(this.value.data, 'data') : [];
return {
colorField: this.colorField,
colornames: this.colornames,
elements: elements,
hasDropdown: this.hasDropdown,
readonly: this.mode === "readonly",
@@ -845,7 +845,6 @@
<t t-name="FieldMany2ManyTag">
<t t-foreach="elements" t-as="el">
<t t-set="color" t-value="el[colorField] || 0"/>
<t t-set="colornames" t-value="['No color', 'Red', 'Orange', 'Yellow', 'Light blue', 'Dark purple', 'Salmon pink', 'Medium blue', 'Dark blue', 'Fushia', 'Green', 'Purple']"/>
<div t-attf-class="badge badge-pill #{hasDropdown ? 'dropdown' : ''} o_tag_color_#{color}" t-att-data-color="color" t-att-data-index="el_index" t-att-data-id="el.id" t-attf-title="#{title} #{colornames[color]}">
<t t-set="_badge_text">
<span class="o_badge_text" t-att-title="el.display_name"><span role="img" t-attf-aria-label="#{title} #{colornames[color]}"/><t t-esc="el.display_name"/></span>
@@ -52,7 +52,7 @@ QUnit.module('Services', {
await testUtils.nextMicrotaskTick();
var $notification = $('body .o_notification_manager .o_notification');
assert.strictEqual(_.str.trim($notification.html().replace(/\s+/g, ' ')),
"<div class=\"o_notification_title\"> <span role=\"img\" aria-label=\"Notification undefined\" class=\"o_icon fa fa-3x fa-lightbulb-o\" title=\"Notification undefined\"></span> a </div> <div class=\"o_notification_content\">b</div>",
"<div class=\"o_notification_title\"> <span aria-label=\"Notification\" role=\"img\" class=\"o_icon fa fa-3x fa-lightbulb-o\" title=\"Notification\"></span> a </div> <div class=\"o_notification_content\">b</div>",
"should display notification");
assert.containsNone($notification, '.o_close', "should not display the close button in ");
await testUtils.nextTick();
@@ -73,7 +73,7 @@ QUnit.module('Services', {
await testUtils.nextMicrotaskTick();
var $notification = $('body .o_notification_manager .o_notification');
assert.strictEqual(_.str.trim($notification.html().replace(/\s+/g, ' ')),
"<div class=\"o_notification_title\"> <span role=\"img\" aria-label=\"Notification undefined\" class=\"o_icon fa fa-3x fa-exclamation\" title=\"Notification undefined\"></span> a </div> <div class=\"o_notification_content\">b</div>",
"<div class=\"o_notification_title\"> <span aria-label=\"Notification\" role=\"img\" class=\"o_icon fa fa-3x fa-exclamation\" title=\"Notification\"></span> a </div> <div class=\"o_notification_content\">b</div>",
"should display notification");
view.destroy();
});
@@ -180,7 +180,7 @@ QUnit.module('Services', {
assert.containsOnce($notification.eq(0), '.o_close',
"should display the close button in notification");
assert.strictEqual(_.str.trim($notification.eq(0).html().replace(/\s+/g, ' ')),
"<a aria-label=\"Close\" class=\"fa fa-times o_close\" href=\"#\" title=\"Close\"></a> <div class=\"o_notification_title\"> <span role=\"img\" aria-label=\"Notification undefined\" class=\"o_icon fa fa-3x fa-question-circle-o\" title=\"Notification undefined\"></span> a0 </div> <div class=\"o_notification_content\">b0</div> <div class=\"o_buttons\"> <button class=\"btn btn-primary\" type=\"button\"> <span>accept0</span> </button><button class=\"btn btn-secondary\" type=\"button\"> <span>refuse0</span> </button> </div>",
"<a aria-label=\"Close\" class=\"fa fa-times o_close\" href=\"#\" title=\"Close\"></a> <div class=\"o_notification_title\"> <span aria-label=\"Notification\" role=\"img\" class=\"o_icon fa fa-3x fa-question-circle-o\" title=\"Notification\"></span> a0 </div> <div class=\"o_notification_content\">b0</div> <div class=\"o_buttons\"> <button class=\"btn btn-primary\" type=\"button\"> <span>accept0</span> </button><button class=\"btn btn-secondary\" type=\"button\"> <span>refuse0</span> </button> </div>",
"should display notification");

testUtils.dom.click($notification.find('.o_buttons button:contains(accept0)'));

0 comments on commit 0e0a25c

Please sign in to comment.
You can’t perform that action at this time.