summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views
diff options
context:
space:
mode:
Diffstat (limited to 'addons/web/static/src/js/views')
-rw-r--r--addons/web/static/src/js/views/basic/basic_model.js54
-rw-r--r--addons/web/static/src/js/views/form/form_controller.js12
-rw-r--r--addons/web/static/src/js/views/kanban/kanban_controller.js3
-rw-r--r--addons/web/static/src/js/views/list/list_controller.js12
4 files changed, 70 insertions, 11 deletions
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 60c2f6a3314..311b0ee6947 100644
--- a/addons/web/static/src/js/views/basic/basic_model.js
+++ b/addons/web/static/src/js/views/basic/basic_model.js
@@ -1176,7 +1176,7 @@ var BasicModel = AbstractModel.extend({
* @param {string} parentID id of the parent resource to reload
* @returns {Promise<string>} resolves to the parent id
*/
- toggleActive: function (recordIDs, value, parentID) {
+ toggleActive: function (recordIDs, parentID) {
var self = this;
var parent = this.localData[parentID];
var resIDs = _.map(recordIDs, function (recordID) {
@@ -1184,8 +1184,56 @@ var BasicModel = AbstractModel.extend({
});
return this._rpc({
model: parent.model,
- method: 'write',
- args: [resIDs, { active: value }],
+ method: 'toggle_active',
+ args: [resIDs],
+ })
+ .then(function () {
+ // optionally clear the DataManager's cache
+ self._invalidateCache(parent);
+ return self.reload(parentID);
+ });
+ },
+ /**
+ * Archive the given records
+ *
+ * @param {Array} recordIDs local ids of the records to (un)archive
+ * @param {string} parentID id of the parent resource to reload
+ * @returns {Promise<string>} resolves to the parent id
+ */
+ actionArchive: function (recordIDs, 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',
+ args: [resIDs],
+ })
+ .then(function () {
+ // optionally clear the DataManager's cache
+ self._invalidateCache(parent);
+ return self.reload(parentID);
+ });
+ },
+ /**
+ * Unarchive the given records
+ *
+ * @param {Array} recordIDs local ids of the records to (un)archive
+ * @param {string} parentID id of the parent resource to reload
+ * @returns {Promise<string>} resolves to the parent id
+ */
+ actionUnarchive: function (recordIDs, 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',
+ args: [resIDs],
})
.then(function () {
// optionally clear the DataManager's cache
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 67d1a6aa130..b3a65cc2bde 100644
--- a/addons/web/static/src/js/views/form/form_controller.js
+++ b/addons/web/static/src/js/views/form/form_controller.js
@@ -293,9 +293,15 @@ var FormController = BasicController.extend({
if (ids.length === 0) {
return Promise.resolve();
}
- return this.model
- .toggleActive(ids, !archive, this.handle)
- .then(this.update.bind(this, {}, {reload: false}));
+ 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}));
+ }
},
/**
diff --git a/addons/web/static/src/js/views/kanban/kanban_controller.js b/addons/web/static/src/js/views/kanban/kanban_controller.js
index 4ea823ed062..bf39906b8e5 100644
--- a/addons/web/static/src/js/views/kanban/kanban_controller.js
+++ b/addons/web/static/src/js/views/kanban/kanban_controller.js
@@ -569,12 +569,11 @@ var KanbanController = BasicController.extend({
*/
_onToggleActiveRecords: function (ev) {
var self = this;
- var active = !ev.data.archive;
var column = ev.target;
var recordIds = _.pluck(column.records, 'db_id');
if (recordIds.length) {
this.model
- .toggleActive(recordIds, active, column.db_id)
+ .toggleActive(recordIds, column.db_id)
.then(function (dbID) {
var data = self.model.get(dbID);
self.renderer.updateColumn(dbID, data);
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 ffeef454716..bbc1a2cd6ba 100644
--- a/addons/web/static/src/js/views/list/list_controller.js
+++ b/addons/web/static/src/js/views/list/list_controller.js
@@ -265,9 +265,15 @@ var ListController = BasicController.extend({
if (ids.length === 0) {
return Promise.resolve();
}
- return this.model
- .toggleActive(ids, !archive, this.handle)
- .then(this.update.bind(this, {}, {reload: false}));
+ 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