From 4fd30ecbc1207fc370688c32798dd78eb5cef0e8 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 30 Mar 2020 13:31:05 +0000 Subject: [PATCH] [IMP] web: adapt multi edit feature to list selection changes We don't change the multi edit mechanism for now: it still only applies to the selected records, limited to the current page. However, we add the information in the confirm dialog to make it clear for the user. Part of task 2185145 --- .../src/js/views/list/list_confirm_dialog.js | 2 ++ .../src/js/views/list/list_controller.js | 1 + addons/web/static/src/xml/base.xml | 1 + addons/web/static/tests/views/list_tests.js | 27 +++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/addons/web/static/src/js/views/list/list_confirm_dialog.js b/addons/web/static/src/js/views/list/list_confirm_dialog.js index ea0a3191f9e..a499a5debb7 100644 --- a/addons/web/static/src/js/views/list/list_confirm_dialog.js +++ b/addons/web/static/src/js/views/list/list_confirm_dialog.js @@ -22,6 +22,8 @@ const ListConfirmDialog = Dialog.extend({ * @param {Widget} parent * @param {Object} record edited record with updated value * @param {Object} changes changes registered by the list controller + * @param {Object} changes isDomainSelected true iff the user selected the + * whole domain * @param {string} changes.fieldLabel label of the changed field * @param {string} changes.fieldName technical name of the changed field * @param {number} changes.nbRecords number of records (total) diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index c41e253c583..4a3972d50eb 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -464,6 +464,7 @@ var ListController = BasicController.extend({ }; const record = this.model.get(recordId); const dialogChanges = { + isDomainSelected: this.isDomainSelected, fieldLabel: node.attrs.string || record.fields[fieldName].string, fieldName: node.attrs.name, nbRecords: recordIds.length, diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index ee72f282337..2b0ff6f31dd 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -874,6 +874,7 @@

+ This update will only consider the records of the current page.

Among the selected records, are valid for this update.
diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 235cffda702..f2a49f5c339 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -6340,6 +6340,33 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('editable list view: multi edition when the domain is selected', async function (assert) { + assert.expect(1); + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: ` + + + + `, + }); + + // select all records, and then select all domain + await testUtils.dom.click(list.$('th.o_list_record_selector input')); + await testUtils.dom.click(list.$('.o_list_selection_box .o_list_select_domain')); + + // edit a field + await testUtils.dom.click(list.$('.o_data_row:eq(0) .o_data_cell:eq(1)')); + await testUtils.fields.editInput(list.$('.o_field_widget[name=int_field]'), 666); + + assert.ok($('.modal-body').text().includes('This update will only consider the records of the current page.')); + + list.destroy(); + }); + QUnit.test('editable list view: many2one with readonly modifier', async function (assert) { assert.expect(2);