From 09da30fbcd2de3d136d6eb3feb5c1ae08f23390e Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 27 Sep 2021 13:00:04 +0000 Subject: [PATCH] [REF] board,web: namespace legacy view root classnames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pivot and graph views have been rewrote in owl in [1]. However, the former implemention has been kept as it is still used in some cases (e.g. board application, studio, PieChart widget), but they are lazy loaded [2]. Before this commit, both the new and former implementations mostly shared the same DOM (in particular, their root element had the same classnames). It means that the scss rules of an implementation might interfer with the other, and vice versa. This commit adds the "legacy" keyword in the root classnames of those views, and properly namespaces the scss rules of legacy views to properly dissociate the style of new and legacy views. For the pivot view, we re-used the same scss file, so in this commit, we duplicate it (one for the new view, the other, lazy loaded, for the legacy view). [1] 0134495ba55bea16c2d11d5eb5d832edad575694 [2] bd3cf85c841168dfd87f7166b545dd00d9b38bf4 closes odoo/odoo#77323 X-original-commit: 3862d5aae1df72d3585f915e8a2a2626322e74ad Related: odoo/enterprise#21223 Signed-off-by: Géry Debongnie (ged) --- addons/board/static/tests/dashboard_tests.js | 4 +- addons/web/__manifest__.py | 3 +- .../static/src/legacy/scss/graph_view.scss | 2 +- .../static/src/legacy/scss/pivot_view.scss | 104 ++++++++++++++++++ addons/web/static/src/legacy/xml/graph.xml | 2 +- addons/web/static/src/legacy/xml/pivot.xml | 2 +- .../static/src/views/pivot/pivot_view.scss | 7 -- .../static/tests/legacy/views/graph_tests.js | 2 +- .../static/tests/legacy/views/pivot_tests.js | 22 ++-- .../tests/legacy/views/search_panel_tests.js | 4 +- 10 files changed, 124 insertions(+), 28 deletions(-) create mode 100644 addons/web/static/src/legacy/scss/pivot_view.scss diff --git a/addons/board/static/tests/dashboard_tests.js b/addons/board/static/tests/dashboard_tests.js index 5a39289331f..b8b4466279a 100644 --- a/addons/board/static/tests/dashboard_tests.js +++ b/addons/board/static/tests/dashboard_tests.js @@ -1061,7 +1061,7 @@ QUnit.test('click on a cell of pivot view inside dashboard', async function (ass assert.verifySteps([]); - await testUtils.dom.click(form.$('.o_pivot .o_pivot_cell_value')); + await testUtils.dom.click(form.$('.o_legacy_pivot .o_pivot_cell_value')); assert.verifySteps(['do action']); @@ -1183,7 +1183,7 @@ QUnit.test('correctly display the time range descriptions of a reporting view in }); assert.deepEqual( - [...form.el.querySelectorAll('div.o_pivot th.o_pivot_origin_row')].map(el => el.innerText), + [...form.el.querySelectorAll('div.o_legacy_pivot th.o_pivot_origin_row')].map(el => el.innerText), ['June 2020', 'July 2020', 'Variation'] ); diff --git a/addons/web/__manifest__.py b/addons/web/__manifest__.py index d22b72dd3b2..0cc3535cd75 100644 --- a/addons/web/__manifest__.py +++ b/addons/web/__manifest__.py @@ -116,7 +116,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/scss/fields.scss', 'web/static/src/legacy/scss/file_upload.scss', 'web/static/src/legacy/scss/views.scss', - 'web/static/src/legacy/scss/graph_view.scss', 'web/static/src/legacy/scss/form_view.scss', 'web/static/src/legacy/scss/list_view.scss', 'web/static/src/legacy/scss/kanban_dashboard.scss', @@ -186,7 +185,6 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/js/model.js', 'web/static/src/legacy/js/owl_compatibility.js', ("remove", 'web/static/src/legacy/js/views/graph/**/*'), - ("remove", 'web/static/src/legacy/scss/graph_view.scss'), ("remove", 'web/static/src/legacy/js/views/pivot/**/*'), ], "web.assets_backend_legacy_lazy": [ @@ -198,6 +196,7 @@ This module provides the core of the Odoo Web Client. 'web/static/src/legacy/scss/graph_view.scss', # pivot 'web/static/src/legacy/js/views/pivot/**/*', + 'web/static/src/legacy/scss/pivot_view.scss', ], 'web.assets_frontend_minimal': [ 'web/static/src/legacy/js/public/lazyloader.js', diff --git a/addons/web/static/src/legacy/scss/graph_view.scss b/addons/web/static/src/legacy/scss/graph_view.scss index ddf841c4989..82c0ce39d5f 100644 --- a/addons/web/static/src/legacy/scss/graph_view.scss +++ b/addons/web/static/src/legacy/scss/graph_view.scss @@ -1,4 +1,4 @@ -.o_graph_renderer { +.o_legacy_graph_renderer { height: 100%; .o_graph_canvas_container { padding-top: 5px; diff --git a/addons/web/static/src/legacy/scss/pivot_view.scss b/addons/web/static/src/legacy/scss/pivot_view.scss new file mode 100644 index 00000000000..66b23ecdfdc --- /dev/null +++ b/addons/web/static/src/legacy/scss/pivot_view.scss @@ -0,0 +1,104 @@ +.o_legacy_pivot { + + .o_pivot_cell_value { + font-size: 1em; + .o_comparison { + font-size: 0.61em; + } + .o_variation { + &.o_positive { + color: green; + } + &.o_negative { + color: red; + } + } + } + + table { + background-color: $o-view-background-color; + width: auto; // bootstrap override + + // Inform the user that he may click on a cell to be redirected to a list view of the + // items corresponding to the clicked cell + &.o_enable_linking { + .o_pivot_cell_value:not(.o_empty):hover { + color: $o-brand-primary; + cursor: pointer; + + } + } + + thead th:not(.o_pivot_header_cell_closed):not(.o_pivot_header_cell_opened):not(.o_pivot_header_cell) { + text-align: center; + } + + th { + font-weight: normal; // bootstrap override + background-color: lighten($o-brand-secondary, 40%); + } + + @mixin o-pivot-header-cell { + background-color: lighten($o-brand-secondary, 40%); + cursor: pointer; + white-space: nowrap; + user-select: none; + &:hover { + background-color: lighten($o-brand-secondary, 30%); + } + } + + .o_pivot_measure_row { + @include o-pivot-header-cell; + } + + .o_pivot_header_cell { + white-space: nowrap; + user-select: none; + } + + .o_pivot_header_cell_closed { + @include o-pivot-header-cell; + &::before { + font-family: FontAwesome; + content: ""; + margin-right: 8px; + } + } + + .o_pivot_header_cell_opened { + @include o-pivot-header-cell; + &::before { + font-family: FontAwesome; + content: ""; + margin-right: 8px; + } + } + + .o_pivot_sort_order_asc::after { + @include o-caret-up; + margin-left: 5px; + } + + .o_pivot_sort_order_desc::after { + @include o-caret-down; + margin-left: 5px; + } + + .o_pivot_cell_value.o_cell_hover { + background-color: $table-hover-bg; + } + } + + .o_pivot_field_selection::after { + @include o-caret-right; + position: absolute; + right: 6px; + top: 9px; + } + + .o_pivot_field_menu .dropdown-item.disabled { + color: $text-muted; + cursor: default; + } +} diff --git a/addons/web/static/src/legacy/xml/graph.xml b/addons/web/static/src/legacy/xml/graph.xml index d194f10dba7..cd8a6d4d9d2 100644 --- a/addons/web/static/src/legacy/xml/graph.xml +++ b/addons/web/static/src/legacy/xml/graph.xml @@ -2,7 +2,7 @@ -
+