[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.
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user