From 9be9a75e67ac0727e2d5a0f7584f350f4ee638fb Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 27 Mar 2020 09:39:13 +0000 Subject: [PATCH] [REF] web: move _archive function to BasicController --- .../src/js/views/basic/basic_controller.js | 19 +++++++++++++++ .../src/js/views/form/form_controller.js | 24 ------------------- .../src/js/views/list/list_controller.js | 22 ----------------- 3 files changed, 19 insertions(+), 46 deletions(-) diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 8b4672bc291..f5944ffe253 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -238,6 +238,25 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { return _super(dataPointID, changes, event); }); }, + /** + * Archive the current selection + * + * @private + * @param {string[]} ids + * @param {boolean} archive + * @returns {Promise} + */ + _archive: async function (ids, archive) { + if (ids.length === 0) { + return Promise.resolve(); + } + if (archive) { + await this.model.actionArchive(ids, this.handle); + } else { + await this.model.actionUnarchive(ids, this.handle); + } + return this.update({}, {reload: false}); + }, /** * When the user clicks on a 'action button', this function determines what * should happen. diff --git a/addons/web/static/src/js/views/form/form_controller.js b/addons/web/static/src/js/views/form/form_controller.js index 5c54afb7e41..8af47e4cd4f 100644 --- a/addons/web/static/src/js/views/form/form_controller.js +++ b/addons/web/static/src/js/views/form/form_controller.js @@ -305,30 +305,6 @@ var FormController = BasicController.extend({ core.bus.trigger('DOM_updated'); return result; }, - - /** - * Archive the current selection - * - * @private - * @param {string[]} ids - * @param {boolean} archive - * @returns {Promise} - */ - _archive: function (ids, archive) { - if (ids.length === 0) { - return Promise.resolve(); - } - if (archive) { - return this.model - .actionArchive(ids, this.handle) - .then(this.update.bind(this, {}, {reload: false})); - } else { - return this.model - .actionUnarchive(ids, this.handle) - .then(this.update.bind(this, {}, {reload: false})); - } - }, - /** * Assign on the buttons save and discard additionnal behavior to facilitate * the work of the users doing input only using the keyboard 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 41dfa18c8bc..a2096a59f34 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -234,28 +234,6 @@ var ListController = BasicController.extend({ }); }).then(this._enableButtons.bind(this)).guardedCatch(this._enableButtons.bind(this)); }, - /** - * Archive the current selection - * - * @private - * @param {string[]} ids - * @param {boolean} archive - * @returns {Promise} - */ - _archive: function (ids, archive) { - if (ids.length === 0) { - return Promise.resolve(); - } - if (archive) { - return this.model - .actionArchive(ids, this.handle) - .then(this.update.bind(this, {}, {reload: false})); - } else { - return this.model - .actionUnarchive(ids, this.handle) - .then(this.update.bind(this, {}, {reload: false})); - } - }, /** * Assign on the buttons create additionnal behavior to facilitate the work of the users doing input only using the keyboard *