summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2020-03-27 09:39:13 +0000
committerAaron Bohy <aab@odoo.com>2020-03-30 09:06:17 +0000
commit9be9a75e67ac0727e2d5a0f7584f350f4ee638fb (patch)
tree6d3dddf32ee14ffe7ca677c85255f8d24037a776
parent63047c1c335b635026e81d2616e55c088e5ae233 (diff)
[REF] web: move _archive function to BasicController
-rw-r--r--addons/web/static/src/js/views/basic/basic_controller.js19
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js24
-rw-r--r--addons/web/static/src/js/views/list/list_controller.js22
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
@@ -239,6 +239,25 @@ var BasicController = AbstractController.extend(FieldManagerMixin, {
});
},
/**
+ * 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
@@ -235,28 +235,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
*
* @param {jQueryElement} $createButton The create button itself