capture add, update, delete errors while offline via EDITS_ENQUEUED_ERROR

This commit is contained in:
Andy Gup 2015-03-16 12:33:48 -06:00
parent de0356c9f1
commit 4cc0cbf536

View File

@ -279,6 +279,8 @@ define([
* @param callback Called when the operation is complete.
* @param errback An error object is returned if an error occurs
* @returns {*} deferred
* @throws EDITS_ENQUEUED if all edits successfully stored while offline
* @throws EDITS_ENQUEUED_ERROR if there was an error while storing an edit while offline
*/
layer.applyEdits = function(adds,updates,deletes,callback,errback)
{
@ -400,13 +402,18 @@ define([
all(promises).then( function(r)
{
//TO-DO - handle information related to any failed edits that didn't get stored
// Make sure all edits were successful. If not throw an error.
var success = true;
var length = r.length;
for(var v = 0;v < length;v++){
if(r[v] == false) success = false;
}
/* we already pushed the edits into the database, now we let the FeatureLayer to do the local updating of the layer graphics */
setTimeout(function()
{
this._editHandler(results, adds, updatesMap, callback, errback, deferred);
self.emit(self.events.EDITS_ENQUEUED, results);
success == true ? self.emit(self.events.EDITS_ENQUEUED, results) : self.emit(self.events.EDITS_ENQUEUED_ERROR, results);
}.bind(this),0);
return deferred;
}.bind(this));