From 6f700b2973d90885eb4ebd0b1e27a2437a73fe1e Mon Sep 17 00:00:00 2001 From: Pierre Paridans Date: Tue, 14 Feb 2023 09:32:47 +0000 Subject: [PATCH] [FIX] web,purchase: no content helper position in modal on small screen This commit fixes an issue where the "No records found" helper text is wrongly positioned below the sample data's records (i.e. not visible) instead of over them. This is basically a revert of 9407383a569711651182a3d0bebd2f990677e53f due to the changes in the DOM and styling made in the meantime. But actually we can go further and ensure we always have the ListView's table present in the DOM. This change allows to simplify the positioning of the helper and the implementation of the Purchase's dashboard. Steps to reproduce: - create a new database **without demo data** - install "Planning" and "Sales" apps - with a mobile-like screen size, open Planning - switch to Gantt view - in a cell, click/tap on the magnifier button (which is on hover...) - the many2x view doesn't contain data => action helper "No records found" isn"t visible (scroll to bottom to find it) closes odoo/odoo#112878 X-original-commit: 766498a36b322ffe9c647616f56f3ba04cc51d96 Signed-off-by: Aaron Bohy (aab) Signed-off-by: Pierre Paridans (app) --- addons/purchase/__manifest__.py | 1 - .../static/src/views/purchase_listview.scss | 3 -- .../static/src/views/purchase_listview.xml | 16 +------- addons/web/static/src/legacy/scss/modal.scss | 4 -- .../static/src/views/list/list_renderer.js | 12 +----- .../static/src/views/list/list_renderer.xml | 5 +-- .../web/static/tests/views/list_view_tests.js | 38 ++++++++----------- .../webclient/actions/window_action_tests.js | 3 +- 8 files changed, 21 insertions(+), 61 deletions(-) delete mode 100644 addons/purchase/static/src/views/purchase_listview.scss diff --git a/addons/purchase/__manifest__.py b/addons/purchase/__manifest__.py index 5d144d44f1e..1d8311943bd 100644 --- a/addons/purchase/__manifest__.py +++ b/addons/purchase/__manifest__.py @@ -40,7 +40,6 @@ 'web.assets_backend': [ 'purchase/static/src/toaster_button/*', 'purchase/static/src/views/*.js', - 'purchase/static/src/views/*.scss', 'purchase/static/src/js/tours/purchase.js', 'purchase/static/src/**/*.xml', ], diff --git a/addons/purchase/static/src/views/purchase_listview.scss b/addons/purchase/static/src/views/purchase_listview.scss deleted file mode 100644 index cc3c00556ad..00000000000 --- a/addons/purchase/static/src/views/purchase_listview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.o_rfq_no_content { - position: relative; -} \ No newline at end of file diff --git a/addons/purchase/static/src/views/purchase_listview.xml b/addons/purchase/static/src/views/purchase_listview.xml index 383d2a13489..d9ba48f0e75 100644 --- a/addons/purchase/static/src/views/purchase_listview.xml +++ b/addons/purchase/static/src/views/purchase_listview.xml @@ -1,21 +1,7 @@ - - - - - - - + - - - - - - - - diff --git a/addons/web/static/src/legacy/scss/modal.scss b/addons/web/static/src/legacy/scss/modal.scss index d2a411ab3d0..1d21ec56cc7 100644 --- a/addons/web/static/src/legacy/scss/modal.scss +++ b/addons/web/static/src/legacy/scss/modal.scss @@ -36,10 +36,6 @@ } } - > :not(.o_legacy_view_sample_data) .o_view_nocontent { - position: unset; - } - .o_modal_changes td { &:first-child { padding-right: 10px; diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index 2bf7e1477c0..2829c5906a7 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -140,7 +140,7 @@ export class ListRenderer extends Component { if (this.env.searchModel) { useBus(this.env.searchModel, "focus-view", () => { - if (this.props.list.model.useSampleModel || !this.showTable) { + if (this.props.list.model.useSampleModel) { return; } @@ -180,7 +180,7 @@ export class ListRenderer extends Component { () => { this.freezeColumnWidths(); }, - () => [this.state.columns, this.isEmpty, this.showTable] + () => [this.state.columns, this.isEmpty] ); useExternalListener(window, "resize", () => { this.columnWidths = null; @@ -224,9 +224,6 @@ export class ListRenderer extends Component { // The following code manipulates the DOM directly to avoid having to wait for a // render + patch which would occur on the next frame and cause flickering. freezeColumnWidths() { - if (!this.showTable) { - return; - } if (!this.keepColumnWidths) { this.columnWidths = null; } @@ -1586,11 +1583,6 @@ export class ListRenderer extends Component { return !group.isFolded && group.list.limit < group.list.count; } - get showTable() { - const { model } = this.props.list; - return model.hasData() || !this.props.noContentHelp; - } - toggleGroup(group) { group.toggle(); } diff --git a/addons/web/static/src/views/list/list_renderer.xml b/addons/web/static/src/views/list/list_renderer.xml index ced2c91d4b3..5dfca43a226 100644 --- a/addons/web/static/src/views/list/list_renderer.xml +++ b/addons/web/static/src/views/list/list_renderer.xml @@ -3,8 +3,7 @@
- +
diff --git a/addons/web/static/tests/views/list_view_tests.js b/addons/web/static/tests/views/list_view_tests.js index 809eabf59ed..d09de3b8697 100644 --- a/addons/web/static/tests/views/list_view_tests.js +++ b/addons/web/static/tests/views/list_view_tests.js @@ -4257,32 +4257,26 @@ QUnit.module("Views", (hooks) => { noContentHelp: '

click to add a foo

', }); - // as help is being provided in the action, table won't be rendered until a record exists - assert.containsNone( - target, - ".o_list_table", - " there should not be any records in the view." - ); assert.containsOnce(target, ".o_view_nocontent", "should have no content help"); // click on create button await click(target.querySelector(".o_list_button_add")); - const handleWidgetMinWidth = "33px"; + const handleWidgetWidth = "33px"; const handleWidgetHeader = target.querySelector("thead > tr > th.o_handle_cell"); assert.strictEqual( - window.getComputedStyle(handleWidgetHeader).minWidth, - handleWidgetMinWidth, - "While creating first record, min-width should be applied to handle widget." + window.getComputedStyle(handleWidgetHeader).width, + handleWidgetWidth, + "While creating first record, width should be applied to handle widget." ); // creating one record await editInput(target, ".o_selected_row [name='foo'] input", "test_foo"); await clickSave(target); assert.strictEqual( - window.getComputedStyle(handleWidgetHeader).minWidth, - handleWidgetMinWidth, - "After creation of the first record, min-width of the handle widget should remain as it is" + window.getComputedStyle(handleWidgetHeader).width, + handleWidgetWidth, + "After creation of the first record, width of the handle widget should remain as it is" ); } ); @@ -6581,7 +6575,7 @@ QUnit.module("Views", (hooks) => { noContentHelp: "click to add a partner", }); assert.containsOnce(target, ".o_view_nocontent", "should display the no content helper"); - assert.containsNone(target, ".o_list_view table", "should not have a table in the dom"); + assert.containsOnce(target, ".o_list_view table", "should have a table in the dom"); assert.deepEqual( [...target.querySelectorAll(".o_view_nocontent")].map((el) => el.textContent), ["click to add a partner"] @@ -6595,7 +6589,6 @@ QUnit.module("Views", (hooks) => { ".o_view_nocontent", "should not display the no content helper" ); - assert.containsOnce(target, ".o_list_view table", "should have a table in the dom"); }); QUnit.test("no nocontent helper when no data and no help", async function (assert) { @@ -6678,7 +6671,7 @@ QUnit.module("Views", (hooks) => { target.querySelector(".o_list_view .o_content"), "o_view_sample_data" ); - assert.containsNone(target, ".o_list_table"); + assert.containsOnce(target, ".o_list_table"); assert.containsOnce(target, ".o_nocontent_help"); await toggleMenuItem(target, "False Domain"); @@ -6923,7 +6916,7 @@ QUnit.module("Views", (hooks) => { target.querySelector(".o_list_view .o_content"), "o_view_sample_data" ); - assert.containsNone(target, ".o_list_table"); + assert.containsOnce(target, ".o_list_table"); assert.containsOnce(target, ".o_nocontent_help"); } ); @@ -6967,7 +6960,7 @@ QUnit.module("Views", (hooks) => { target.querySelector(".o_list_view .o_content"), "o_view_sample_data" ); - assert.containsNone(target, ".o_list_table"); + assert.containsOnce(target, ".o_list_table"); assert.containsOnce(target, ".o_nocontent_help"); } ); @@ -7025,7 +7018,7 @@ QUnit.module("Views", (hooks) => { target.querySelector(".o_list_view .o_content"), "o_view_sample_data" ); - assert.containsNone(target, ".o_list_table"); + assert.containsOnce(target, ".o_list_table"); assert.containsOnce(target, ".o_nocontent_help"); } ); @@ -7340,12 +7333,12 @@ QUnit.module("Views", (hooks) => { ".o_view_nocontent", "should have a no content helper displayed" ); - assert.containsNone( + assert.containsOnce( target, "div.table-responsive", - "should not have a div.table-responsive" + "should have a div.table-responsive" ); - assert.containsNone(target, "table", "should not have rendered a table"); + assert.containsOnce(target, "table", "should have rendered a table"); await click(target.querySelector(".o_list_button_add")); assert.containsNone( @@ -7353,7 +7346,6 @@ QUnit.module("Views", (hooks) => { ".o_view_nocontent", "should not have a no content helper displayed" ); - assert.containsOnce(target, "table", "should have rendered a table"); assert.hasClass( target.querySelector("tbody tr"), "o_selected_row", diff --git a/addons/web/static/tests/webclient/actions/window_action_tests.js b/addons/web/static/tests/webclient/actions/window_action_tests.js index 2a6d0fe9118..69e2322104a 100644 --- a/addons/web/static/tests/webclient/actions/window_action_tests.js +++ b/addons/web/static/tests/webclient/actions/window_action_tests.js @@ -2501,12 +2501,11 @@ QUnit.module("ActionManager", (hooks) => { assert.containsOnce(target, ".o_list_view"); assert.containsOnce(target, ".o_view_nocontent"); assert.strictEqual(target.querySelector(".o_view_nocontent").innerText, "Hello"); - assert.containsNone(target, "table"); + assert.containsOnce(target, "table"); await doAction(webClient, 4); assert.containsOnce(target, ".o_list_view"); assert.containsNone(target, ".o_view_nocontent"); - assert.containsOnce(target, "table"); }); QUnit.test("process context.form_view_initial_mode", async function (assert) {