|
@ -204,10 +204,11 @@ DataSet.prototype.add = function (data, senderId) { |
|
|
* @return {Array} updatedIds The ids of the added or updated items |
|
|
* @return {Array} updatedIds The ids of the added or updated items |
|
|
*/ |
|
|
*/ |
|
|
DataSet.prototype.update = function (data, senderId) { |
|
|
DataSet.prototype.update = function (data, senderId) { |
|
|
var addedIds = [], |
|
|
|
|
|
updatedIds = [], |
|
|
|
|
|
me = this, |
|
|
|
|
|
fieldId = me._fieldId; |
|
|
|
|
|
|
|
|
var addedIds = []; |
|
|
|
|
|
var updatedIds = []; |
|
|
|
|
|
var updatedData = []; |
|
|
|
|
|
var me = this; |
|
|
|
|
|
var fieldId = me._fieldId; |
|
|
|
|
|
|
|
|
var addOrUpdate = function (item) { |
|
|
var addOrUpdate = function (item) { |
|
|
var id = item[fieldId]; |
|
|
var id = item[fieldId]; |
|
@ -215,6 +216,7 @@ DataSet.prototype.update = function (data, senderId) { |
|
|
// update item
|
|
|
// update item
|
|
|
id = me._updateItem(item); |
|
|
id = me._updateItem(item); |
|
|
updatedIds.push(id); |
|
|
updatedIds.push(id); |
|
|
|
|
|
updatedData.push(item); |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
// add new item
|
|
|
// add new item
|
|
@ -254,7 +256,7 @@ DataSet.prototype.update = function (data, senderId) { |
|
|
this._trigger('add', {items: addedIds}, senderId); |
|
|
this._trigger('add', {items: addedIds}, senderId); |
|
|
} |
|
|
} |
|
|
if (updatedIds.length) { |
|
|
if (updatedIds.length) { |
|
|
this._trigger('update', {items: updatedIds}, senderId); |
|
|
|
|
|
|
|
|
this._trigger('update', {items: updatedIds, data: updatedData}, senderId); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return addedIds.concat(updatedIds); |
|
|
return addedIds.concat(updatedIds); |
|
|