From 696e31d3077c0bc418cac3537ba98cadb3029ef2 Mon Sep 17 00:00:00 2001 From: Anshuman Sharma Date: Wed, 19 Dec 2018 06:49:11 +0000 Subject: [PATCH] [FIX] web: highlight clickable pivot cells on hover After a recent reorganization of the web client's components tree, the class 'o_enable_linking' was added on the wrong element. This made the css rule responsible of the highlighting of the clickable pivot cells impossible to satisfy. This commit fixes the issue by adding the class directly in the template 'PivotView'. Additionally, this commit also makes visually clear when a field selection menu-items is disabled (because it is already used) using a 'not-allowed' cursor (which was removed in bs4). It is now again possible to open a list view by clicking on a cell with zero value (like in Odoo 11). task-1916889 closes odoo/odoo#34165 Signed-off-by: VincentSchippefilt --- addons/web/static/src/js/views/pivot/pivot_controller.js | 1 - addons/web/static/src/js/views/pivot/pivot_renderer.js | 2 +- addons/web/static/src/scss/pivot_view.scss | 5 +++++ addons/web/static/src/xml/base.xml | 2 +- addons/web/static/tests/views/pivot_tests.js | 6 +++--- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/web/static/src/js/views/pivot/pivot_controller.js b/addons/web/static/src/js/views/pivot/pivot_controller.js index ac48ab769ff..fbc08e93b1e 100644 --- a/addons/web/static/src/js/views/pivot/pivot_controller.js +++ b/addons/web/static/src/js/views/pivot/pivot_controller.js @@ -53,7 +53,6 @@ var PivotController = AbstractController.extend({ * @override */ start: function () { - this.$el.toggleClass('o_enable_linking', this.enableLinking); this.$fieldSelection = this.$('.o_field_selection'); core.bus.on('click', this, function () { this.$fieldSelection.empty(); diff --git a/addons/web/static/src/js/views/pivot/pivot_renderer.js b/addons/web/static/src/js/views/pivot/pivot_renderer.js index 1a3c451f064..33f7f2e2fbf 100644 --- a/addons/web/static/src/js/views/pivot/pivot_renderer.js +++ b/addons/web/static/src/js/views/pivot/pivot_renderer.js @@ -283,7 +283,7 @@ var PivotRenderer = AbstractRenderer.extend({ $cell = $('') .data('id', rows[i].id) .data('col_id', rows[i].col_ids[Math.floor(j / nbrMeasures)]) - .toggleClass('o_empty', !value) + .toggleClass('o_empty', _.isUndefined(value)) .addClass('o_pivot_cell_value text-right'); if (value !== undefined) { $cell.append($('
', {class: 'o_value'}).html(formatter(value, measure))); diff --git a/addons/web/static/src/scss/pivot_view.scss b/addons/web/static/src/scss/pivot_view.scss index 83f8fbc58e7..6bc25ee114e 100644 --- a/addons/web/static/src/scss/pivot_view.scss +++ b/addons/web/static/src/scss/pivot_view.scss @@ -87,4 +87,9 @@ right: 6px; top: 9px; } + + .o_pivot_field_menu .dropdown-item.disabled { + color: $text-muted; + cursor: default; + } } diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 19d9078ce17..46e05a5d352 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -529,7 +529,7 @@
-
+
diff --git a/addons/web/static/tests/views/pivot_tests.js b/addons/web/static/tests/views/pivot_tests.js index 5dbc03e1a2b..d2d3d487885 100644 --- a/addons/web/static/tests/views/pivot_tests.js +++ b/addons/web/static/tests/views/pivot_tests.js @@ -106,7 +106,7 @@ QUnit.module('Views', { }, }); - assert.hasClass(pivot.$el,'o_enable_linking', + assert.hasClass(pivot.$('.o_pivot'),'o_enable_linking', "root node should have classname 'o_enable_linking'"); assert.strictEqual(pivot.$('td.o_pivot_cell_value:contains(32)').length, 1, "should contain a pivot cell with the sum of all records"); @@ -269,7 +269,7 @@ QUnit.module('Views', { } }); - assert.hasClass(pivot.$el,'o_enable_linking', + assert.hasClass(pivot.$('.o_pivot'),'o_enable_linking', "root node should have classname 'o_enable_linking'"); testUtils.dom.click(pivot.$('.o_pivot_cell_value:contains(12)')); // should trigger a do_action @@ -293,7 +293,7 @@ QUnit.module('Views', { }, }); - assert.doesNotHaveClass(pivot.$el, 'o_enable_linking', + assert.doesNotHaveClass(pivot.$('.o_pivot'), 'o_enable_linking', "root node should not have classname 'o_enable_linking'"); assert.containsOnce(pivot, '.o_pivot_cell_value', "should have one cell");