From 8608a5ed8dc7d14432556d2c4c469e3f8deda7f1 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 27 Mar 2020 09:56:50 +0000 Subject: [IMP] web: adapt (un)archive feature to list selection changes Following the new selection feature in list views, this commit adapts the archive and unarchive actions. Part of task 2185145 --- .../static/src/js/views/basic/basic_controller.js | 2 +- .../web/static/src/js/views/basic/basic_model.js | 23 ++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'addons/web/static/src/js/views/basic') 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 f5944ffe253..f0fd3cc8c75 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -242,7 +242,7 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { * Archive the current selection * * @private - * @param {string[]} ids + * @param {number[]} ids * @param {boolean} archive * @returns {Promise} */ diff --git a/addons/web/static/src/js/views/basic/basic_model.js b/addons/web/static/src/js/views/basic/basic_model.js index a69f6878023..8dc540a8861 100644 --- a/addons/web/static/src/js/views/basic/basic_model.js +++ b/addons/web/static/src/js/views/basic/basic_model.js @@ -811,6 +811,15 @@ var BasicModel = AbstractModel.extend({ return dataPoint.id; }); }, + /** + * Returns the list of res_ids for a given list of local ids. + * + * @param {string[]} localIds + * @returns {integer[]} + */ + localIdsToResIds: function (localIds) { + return localIds.map(localId => this.localData[localId].res_id); + }, /** * This helper method is designed to help developpers that want to use a * field widget outside of a view. In that case, we want a way to create @@ -1286,16 +1295,13 @@ var BasicModel = AbstractModel.extend({ /** * Archive the given records * - * @param {Array} recordIDs local ids of the records to (un)archive + * @param {integer[]} resIDs ids of the records to archive * @param {string} parentID id of the parent resource to reload * @returns {Promise} resolves to the parent id */ - actionArchive: function (recordIDs, parentID) { + actionArchive: function (resIDs, parentID) { var self = this; var parent = this.localData[parentID]; - var resIDs = _.map(recordIDs, function (recordID) { - return self.localData[recordID].res_id; - }); return this._rpc({ model: parent.model, method: 'action_archive', @@ -1318,16 +1324,13 @@ var BasicModel = AbstractModel.extend({ /** * Unarchive the given records * - * @param {Array} recordIDs local ids of the records to (un)archive + * @param {integer[]} resIDs ids of the records to unarchive * @param {string} parentID id of the parent resource to reload * @returns {Promise} resolves to the parent id */ - actionUnarchive: function (recordIDs, parentID) { + actionUnarchive: function (resIDs, parentID) { var self = this; var parent = this.localData[parentID]; - var resIDs = _.map(recordIDs, function (recordID) { - return self.localData[recordID].res_id; - }); return this._rpc({ model: parent.model, method: 'action_unarchive', -- cgit v1.2.3