diff --git a/lib/edit/OfflineStore.js b/lib/edit/OfflineStore.js index 84cafbc..d14431b 100755 --- a/lib/edit/OfflineStore.js +++ b/lib/edit/OfflineStore.js @@ -399,24 +399,6 @@ var OfflineStore = function(/* Map */ map) { * @private */ this._reestablishedInternet = function(){ -// var graphicsArr = this.getStore(); -// if(graphicsArr != null && this.layers != null){ -// var length = graphicsArr.length; -// for(var i = 0; i < length; i++){ -// var graphic = graphicsArr[i]; -// var layer = this.getGraphicsLayerById(graphic.layer); -// this._layerEditManager(graphic.graphic,layer,graphic.enumValue,this.enum(),i,function(/* Number */ num, /* boolean */ success, /* String */ id,error){ -// var date = new Date(); -// var indexObject = new this._indexObject(graphic.layer,id,graphic.enumValue,success,graphic.graphic.geometry.type,date) ; -// var serializeGraphic = this._serializeGraphic(graphic.graphic,graphic.layer,graphic.enumValue); -// var deleteTempItem = this._deleteItemInLocalStore(serializeGraphic); -// this._setItemLocalStoreIndexObject(indexObject); -// }.bind(this)); -// } -// } -// else{ -// console.log("_reestablishedInternet: graphicsArray was null."); -// } var data = localStorage.getItem(this._localEnum().STORAGE_KEY); if(data != null){ @@ -426,10 +408,11 @@ var OfflineStore = function(/* Map */ map) { if(typeof item !== "undefined" && item.length > 0 && item !== null && item != ""){ var graphic = this._deserializeGraphic(item); var layer = this.getGraphicsLayerById(graphic.layer); + var valueToDelete = item; this._layerEditManager(graphic.graphic,layer,graphic.enumValue,this.enum(),function(/* Number */ num, /* boolean */ success, /* String */ id,error){ var date = new Date(); var indexObject = new this._indexObject(graphic.layer,id,graphic.enumValue,success,graphic.graphic.geometry.type,date) ; - var deleteTempItem = this._deleteItemInLocalStore(item); + var deleteTempItem = this._deleteItemTempLocalStore(valueToDelete); this._setItemLocalStoreIndexObject(indexObject); }.bind(this)); } @@ -534,7 +517,7 @@ var OfflineStore = function(/* Map */ map) { * @param callback * @private */ - this._deleteObjectIdInLocalStore = function(/* String */ objectId,callback){ + this._deleteObjectIdTempLocalStore = function(/* String */ objectId,callback){ var success = false; var localStore = localStorage.getItem(this._localEnum().STORAGE_KEY); if(localStore != null){ @@ -564,7 +547,7 @@ var OfflineStore = function(/* Map */ map) { * @param callback * @private */ - this._deleteItemInLocalStore = function(/* String */ entry,callback){ + this._deleteItemTempLocalStore = function(/* String */ entry,callback){ var success = false; var localStore = localStorage.getItem(this._localEnum().STORAGE_KEY); if(localStore != null){ diff --git a/samples/edit-basic.html b/samples/edit-basic.html index ccb0eac..fac9f3a 100644 --- a/samples/edit-basic.html +++ b/samples/edit-basic.html @@ -363,7 +363,7 @@ Sample demonstrates basic offline editing functionality for points, lines and po editToolbar.deactivate(); var newAttributes = lang.mixin({}, selectedTemplate.template.prototype.attributes); var newGraphic = new Graphic(evt.geometry, null, newAttributes); - //selectedTemplate.featureLayer.applyEdits([newGraphic], null, null); + offlineStore.applyEdits(newGraphic,selectedTemplate.featureLayer,offlineStore.enum().ADD,function(count,result,id){ if(result.success == true){ updatePendingTextArea() diff --git a/test/spec/OfflineStoreSpec.js b/test/spec/OfflineStoreSpec.js index 417c159..05e6bcf 100755 --- a/test/spec/OfflineStoreSpec.js +++ b/test/spec/OfflineStoreSpec.js @@ -225,7 +225,7 @@ describe("Validate local storage functionality - delete single Point",function() it("delete one graphic from local storage", function(){ var value = null; - var attempt = offlineStore._deleteObjectIdInLocalStore("42749",function(evt){ + var attempt = offlineStore._deleteObjectIdTempLocalStore("42749",function(evt){ value = evt; }.bind(this)) expect(value).toEqual(true);