diff options
| author | Christophe Matthieu <chm@odoo.com> | 2015-09-24 12:02:01 +0200 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-09-24 14:13:55 +0200 |
| commit | 19dfde855841cce17b86322c92abd78359ba6a0f (patch) | |
| tree | 9132ad0329a0e969b28659767aeb33a67b37b043 /addons/web/static/src | |
| parent | 7a465bf7c773d20aed3a24a6a6bc04445a5c1a57 (diff) | |
[FIX] web: don't trigger remove then add the record to re-order list view
To re-order the list view remove the record and add the same record after.
(If an onchange is called, the user can have a message to avoid remove a one2many item)
Add an silent option on remove function of collection, the trigger is already call when write the sequence.
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/list_common.js | 7 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/list_view.js | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/addons/web/static/src/js/views/list_common.js b/addons/web/static/src/js/views/list_common.js index f93625e8edd..0d96b251ec2 100644 --- a/addons/web/static/src/js/views/list_common.js +++ b/addons/web/static/src/js/views/list_common.js @@ -270,9 +270,10 @@ var Collection = Class.extend(/** @lends Collection# */{ * Removes the provided record from the collection * * @param {Record} record + * @param {Boolean} [options.silent=false] * @returns this */ - remove: function (record) { + remove: function (record, options) { var index = this.indexOf(record); if (index === -1) { _(this._proxies).each(function (proxy) { @@ -285,7 +286,9 @@ var Collection = Class.extend(/** @lends Collection# */{ this.records.splice(index, 1); delete this._byId[record.get('id')]; this.length--; - this.trigger('remove', record, this); + if (!options || !options.silent) { + this.trigger('remove', record, this); + } return this; }, diff --git a/addons/web/static/src/js/views/list_view.js b/addons/web/static/src/js/views/list_view.js index 63fe3591b99..095e79eb6ee 100644 --- a/addons/web/static/src/js/views/list_view.js +++ b/addons/web/static/src/js/views/list_view.js @@ -1633,9 +1633,9 @@ ListView.Groups = Class.extend( /** @lends instance.web.ListView.Groups# */{ return; } - list.records.remove(to_move); + list.records.remove(to_move, {silent: true}); var to = target_id ? list.records.indexOf(target) + 1 : 0; - list.records.add(to_move, { at: to }); + list.records.add(to_move, { at: to, silent: true }); // resequencing time! var record, index = to, |
