From 159e58286eee00267805213e61dcecb8443e0ca1 Mon Sep 17 00:00:00 2001 From: Mohammed Shekha Date: Mon, 23 Aug 2021 14:29:14 +0000 Subject: [PATCH] [FIX] web: render buttons after list selection box With this commit we display list selection box after all list header buttons, previously buttons were displayed before header buttons. task-2628038 closes odoo/odoo#78057 X-original-commit: 09c5e178c61feb69d6fd27e4bb9df979fa480f41 Signed-off-by: FrancoisGe --- .../legacy/js/views/list/list_controller.js | 2 +- .../static/tests/legacy/views/list_tests.js | 34 ++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/legacy/js/views/list/list_controller.js b/addons/web/static/src/legacy/js/views/list/list_controller.js index 0679f86d25f..703c6c121ca 100644 --- a/addons/web/static/src/legacy/js/views/list/list_controller.js +++ b/addons/web/static/src/legacy/js/views/list/list_controller.js @@ -659,6 +659,7 @@ var ListController = BasicController.extend({ * @private */ _updateSelectionBox() { + this._renderHeaderButtons(); if (this.$selectionBox) { this.$selectionBox.remove(); this.$selectionBox = null; @@ -674,7 +675,6 @@ var ListController = BasicController.extend({ })); this.$selectionBox.appendTo(this.$buttons); } - this._renderHeaderButtons(); }, //-------------------------------------------------------------------------- diff --git a/addons/web/static/tests/legacy/views/list_tests.js b/addons/web/static/tests/legacy/views/list_tests.js index ab1356f30a1..069bc17f448 100644 --- a/addons/web/static/tests/legacy/views/list_tests.js +++ b/addons/web/static/tests/legacy/views/list_tests.js @@ -557,7 +557,7 @@ QUnit.module('Views', { assert.hasClass(cpButtons[0].querySelector('button[name="x"]'), 'btn btn-secondary'); assert.containsOnce(cpButtons[0], '.o_list_selection_box'); assert.strictEqual( - cpButtons[0].querySelector('button[name="x"]').previousElementSibling, + cpButtons[0].querySelector('button[name="x"]').nextElementSibling, cpButtons[0].querySelector('.o_list_selection_box') ); assert.containsNone(cpButtons[0], 'button[name="y"]'); @@ -2234,6 +2234,38 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('selection box is displayed after header buttons', async function (assert) { + assert.expect(5); + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: + ` +
+
+ + +
`, + }); + + assert.containsN(list, '.o_data_row', 4); + assert.containsNone(list.$('.o_cp_buttons'), '.o_list_selection_box'); + + // select a record + await testUtils.dom.click(list.$('.o_data_row:first .o_list_record_selector input')); + assert.containsOnce(list.$('.o_cp_buttons'), '.o_list_selection_box'); + const lastElement = list.$('.o_cp_buttons .o_list_buttons').children(":last")[0]; + assert.strictEqual(lastElement, list.$('.o_cp_buttons .o_list_selection_box')[0], + "last element should selection box"); + assert.strictEqual(list.$('.o_list_selection_box').text().trim(), '1 selected'); + + list.destroy(); + }); + QUnit.test('selection box is removed after multi record edition', async function (assert) { assert.expect(6);