Fixed another undo bug.

This commit is contained in:
andygup 2014-01-14 17:15:58 -07:00
parent c20f68fcbd
commit fa1a50eb71
3 changed files with 6 additions and 23 deletions

View File

@ -399,24 +399,6 @@ var OfflineStore = function(/* Map */ map) {
* @private * @private
*/ */
this._reestablishedInternet = function(){ 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); var data = localStorage.getItem(this._localEnum().STORAGE_KEY);
if(data != null){ if(data != null){
@ -426,10 +408,11 @@ var OfflineStore = function(/* Map */ map) {
if(typeof item !== "undefined" && item.length > 0 && item !== null && item != ""){ if(typeof item !== "undefined" && item.length > 0 && item !== null && item != ""){
var graphic = this._deserializeGraphic(item); var graphic = this._deserializeGraphic(item);
var layer = this.getGraphicsLayerById(graphic.layer); 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){ this._layerEditManager(graphic.graphic,layer,graphic.enumValue,this.enum(),function(/* Number */ num, /* boolean */ success, /* String */ id,error){
var date = new Date(); var date = new Date();
var indexObject = new this._indexObject(graphic.layer,id,graphic.enumValue,success,graphic.graphic.geometry.type,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); this._setItemLocalStoreIndexObject(indexObject);
}.bind(this)); }.bind(this));
} }
@ -534,7 +517,7 @@ var OfflineStore = function(/* Map */ map) {
* @param callback * @param callback
* @private * @private
*/ */
this._deleteObjectIdInLocalStore = function(/* String */ objectId,callback){ this._deleteObjectIdTempLocalStore = function(/* String */ objectId,callback){
var success = false; var success = false;
var localStore = localStorage.getItem(this._localEnum().STORAGE_KEY); var localStore = localStorage.getItem(this._localEnum().STORAGE_KEY);
if(localStore != null){ if(localStore != null){
@ -564,7 +547,7 @@ var OfflineStore = function(/* Map */ map) {
* @param callback * @param callback
* @private * @private
*/ */
this._deleteItemInLocalStore = function(/* String */ entry,callback){ this._deleteItemTempLocalStore = function(/* String */ entry,callback){
var success = false; var success = false;
var localStore = localStorage.getItem(this._localEnum().STORAGE_KEY); var localStore = localStorage.getItem(this._localEnum().STORAGE_KEY);
if(localStore != null){ if(localStore != null){

View File

@ -363,7 +363,7 @@ Sample demonstrates basic offline editing functionality for points, lines and po
editToolbar.deactivate(); editToolbar.deactivate();
var newAttributes = lang.mixin({}, selectedTemplate.template.prototype.attributes); var newAttributes = lang.mixin({}, selectedTemplate.template.prototype.attributes);
var newGraphic = new Graphic(evt.geometry, null, newAttributes); 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){ offlineStore.applyEdits(newGraphic,selectedTemplate.featureLayer,offlineStore.enum().ADD,function(count,result,id){
if(result.success == true){ if(result.success == true){
updatePendingTextArea() updatePendingTextArea()

View File

@ -225,7 +225,7 @@ describe("Validate local storage functionality - delete single Point",function()
it("delete one graphic from local storage", function(){ it("delete one graphic from local storage", function(){
var value = null; var value = null;
var attempt = offlineStore._deleteObjectIdInLocalStore("42749",function(evt){ var attempt = offlineStore._deleteObjectIdTempLocalStore("42749",function(evt){
value = evt; value = evt;
}.bind(this)) }.bind(this))
expect(value).toEqual(true); expect(value).toEqual(true);