[FIX]Refixed the issue of resequence, added id at specified index in dataset.
bzr revid: msh@openerp.com-20130606065630-r536yqlcq0wihs8l
This commit is contained in:
commit
2b65ba1f64
|
@ -625,6 +625,10 @@ instance.web.DataSet = instance.web.Class.extend(instance.web.PropertiesMixin,
|
||||||
remove_ids: function (ids) {
|
remove_ids: function (ids) {
|
||||||
this.alter_ids(_(this.ids).difference(ids));
|
this.alter_ids(_(this.ids).difference(ids));
|
||||||
},
|
},
|
||||||
|
add_ids: function(ids, at) {
|
||||||
|
var self = this;
|
||||||
|
_.each(ids, function(id){ self.ids.splice(at, 0, id); });
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Resequence records.
|
* Resequence records.
|
||||||
*
|
*
|
||||||
|
|
|
@ -896,7 +896,7 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
|
||||||
this.record_callbacks = {
|
this.record_callbacks = {
|
||||||
'remove': function (event, record) {
|
'remove': function (event, record) {
|
||||||
var id = record.get('id');
|
var id = record.get('id');
|
||||||
self.dataset.remove_ids([id])
|
self.dataset.remove_ids([id]);
|
||||||
var $row = self.$current.children('[data-id=' + id + ']');
|
var $row = self.$current.children('[data-id=' + id + ']');
|
||||||
var index = $row.data('index');
|
var index = $row.data('index');
|
||||||
$row.remove();
|
$row.remove();
|
||||||
|
@ -925,6 +925,8 @@ instance.web.ListView.List = instance.web.Class.extend( /** @lends instance.web.
|
||||||
},
|
},
|
||||||
'add': function (ev, records, record, index) {
|
'add': function (ev, records, record, index) {
|
||||||
var $new_row = $(self.render_record(record));
|
var $new_row = $(self.render_record(record));
|
||||||
|
var id = record.get('id');
|
||||||
|
self.dataset.add_ids([id], index);
|
||||||
|
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
$new_row.prependTo(self.$current);
|
$new_row.prependTo(self.$current);
|
||||||
|
|
Loading…
Reference in New Issue