From c7fd509f9cbf46a50e9320a306583eaca58a009f Mon Sep 17 00:00:00 2001 From: Mitul Shah Date: Thu, 2 Dec 2021 12:28:28 +0000 Subject: [PATCH] [IMP] web: improve tooltip for priority widget's star icons Prior to this commit, when we hover on any star icon (from a priority widget field), we only get the label of a selection value linked with particular icon. For example, if a 'Priority field is having a selection values 'Low' and 'High', on hover of the start, we see 'Low' and 'High' (in the same sequence as selection values). But sometimes (for example in kanban view, where we don't display the field label), it is not very clear what they indicate. This commit improves the behavior by adding a field label also in the title attribute of the star icons so that users can get a better understanding of what each selection means. In our example, it will now display the tooltip as 'Priority: Low' and 'Priority: High'. Task-2691338 closes odoo/odoo#80213 Signed-off-by: Thibault Delavallee (tde) --- .../src/legacy/js/fields/basic_fields.js | 2 +- .../tests/legacy/fields/basic_fields_tests.js | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/legacy/js/fields/basic_fields.js b/addons/web/static/src/legacy/js/fields/basic_fields.js index 5e79aec3d91..e0f8ac5e6ea 100644 --- a/addons/web/static/src/legacy/js/fields/basic_fields.js +++ b/addons/web/static/src/legacy/js/fields/basic_fields.js @@ -2555,7 +2555,7 @@ var PriorityWidget = AbstractField.extend({ const isReadonly = this.record.evalModifiers(this.attrs.modifiers).readonly; _.each(this.field.selection.slice(1), function (choice, index) { const tag = isReadonly ? '' : ''; - self.$el.append(self._renderStar(tag, index_value >= index + 1, index + 1, choice[1], index_value)); + self.$el.append(self._renderStar(tag, index_value >= index + 1, index + 1, `${self.string}: ${choice[1]}`, index_value)); }); }, diff --git a/addons/web/static/tests/legacy/fields/basic_fields_tests.js b/addons/web/static/tests/legacy/fields/basic_fields_tests.js index 5b584c5fcc9..b912007b6eb 100644 --- a/addons/web/static/tests/legacy/fields/basic_fields_tests.js +++ b/addons/web/static/tests/legacy/fields/basic_fields_tests.js @@ -6409,6 +6409,33 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('priority widget tooltip', async function (assert) { + assert.expect(2); + + const form = await createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: `
+ + + + + +
`, + res_id: 1, + }); + + // check title attribute (for basic html tooltip on all the stars) + const $stars = form.$('.o_field_widget.o_priority').find('a.o_priority_star'); + assert.strictEqual($stars[0].title, 'Selection: Blocked', + "Should set field label and correct selection label as title attribute (tooltip)"); + assert.strictEqual($stars[1].title, 'Selection: Done', + "Should set field label and correct selection label as title attribute (tooltip)"); + + form.destroy(); + }); + QUnit.test('priority widget in form view', async function (assert) { assert.expect(22);