Fixed bug that prevent temp store deletes when multiple edits were cached.

This commit is contained in:
andygup 2014-01-14 17:51:41 -07:00
parent fa1a50eb71
commit 5452dc7373
2 changed files with 17 additions and 3 deletions

View File

@ -79,6 +79,7 @@ var OfflineStore = function(/* Map */ map) {
TOKEN : "|||",
EDIT_EVENT_DUPLICATE: "duplicateEditEvent",
INTERNET_STATUS_EVENT: "internetStatusChangeEvent",
DELETE_ITEM_EVENT: "deleteItemFromTempStoreEvent",
INDEX_UPDATE_EVENT: "indexUpdateEvent",
REQUIRED_LIBS : [
"Hydrate.js",
@ -399,12 +400,14 @@ var OfflineStore = function(/* Map */ map) {
* @private
*/
this._reestablishedInternet = function(){
var data = localStorage.getItem(this._localEnum().STORAGE_KEY);
if(data != null){
var dataArr = [];
var split = data.split(this._localEnum().TOKEN);
for(var property in split){
var item = split[property];
if(Boolean(item))dataArr.push(item);
if(typeof item !== "undefined" && item.length > 0 && item !== null && item != ""){
var graphic = this._deserializeGraphic(item);
var layer = this.getGraphicsLayerById(graphic.layer);
@ -412,11 +415,18 @@ var OfflineStore = function(/* Map */ map) {
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._deleteItemTempLocalStore(valueToDelete);
this._setItemLocalStoreIndexObject(indexObject);
}.bind(this));
}
}
var length = dataArr.length;
for(var i=0;i<length;i++){
var deleteTempItem = this._deleteItemTempLocalStore(dataArr[i]);
if(deleteTempItem != true){
console.log("_reestablishedInternet: There was a problem deleting an item from temp local store.");
}
}
}
else{
console.log("_reestablishedInternet: localStorage was empty.");
@ -567,6 +577,8 @@ var OfflineStore = function(/* Map */ map) {
}
}
}
this._dispatchEvent(success,this._localEnum().DELETE_ITEM_EVENT);
return success;
}

View File

@ -243,6 +243,9 @@ Sample demonstrates basic offline editing functionality for points, lines and po
alert("Duplicate edit event");
console.log("duplicate event attempt");
break;
case "deleteItemFromTempStoreEvent":
updatePendingTextArea();
break;
}
},false);
document.addEventListener("windowErrorEvent",function(evt){
@ -416,7 +419,6 @@ Sample demonstrates basic offline editing functionality for points, lines and po
* @param evt
*/
function updateHistoryTextArea(){
updatePendingTextArea();
var logText = "";
var index = offlineStore.getLocalStoreIndex();
if(index != null){