Skip to content

Commit

Permalink
Merge pull request #420 from andygup/display_bug
Browse files Browse the repository at this point in the history
v2.16
  • Loading branch information
andygup committed Oct 29, 2015
2 parents 9552ba1 + 6a0c802 commit 8cc5783
Show file tree
Hide file tree
Showing 15 changed files with 249 additions and 66 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# offline-editor-js - Changelog

## Version 2.16 - Oct. 29, 2015

No breaking changes. Recommended update.

**Enhancements**
* Closes #418 - Updated How To Use Edit Library doc to show a recursive coding pattern for loading multiple feature layers.

**Bug Fix**
* Closes #419 - OfflineFeaturesManager now works correctly when extending multiple feature layers.

## Version 2.15 - Sep. 29, 2015

No breaking changes.
Expand Down
6 changes: 3 additions & 3 deletions dist/offline-edit-min.js

Large diffs are not rendered by default.

86 changes: 65 additions & 21 deletions dist/offline-edit-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! esri-offline-maps - v2.15.0 - 2015-09-29
/*! esri-offline-maps - v2.16.0 - 2015-10-29
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
/*jshint -W030 */
Expand Down Expand Up @@ -388,7 +388,6 @@ define([
layer.applyEdits = function (adds, updates, deletes, callback, errback) {
// inside this method, 'this' will be the FeatureLayer
// and 'self' will be the offlineFeatureLayer object

var promises = [];

if (self.getOnlineStatus() === self.ONLINE) {
Expand All @@ -405,8 +404,8 @@ define([
var results = {addResults: [], updateResults: [], deleteResults: []};
var updatesMap = {};

adds = adds || [];
adds.forEach(function (addEdit) {
var _adds = adds || [];
_adds.forEach(function (addEdit) {
var deferred = new Deferred();

var objectId = this._getNextTempId();
Expand Down Expand Up @@ -503,19 +502,35 @@ define([

all(promises).then(function (r) {
// Make sure all edits were successful. If not throw an error.
var success = true;
var promisesSuccess = true;
for (var v = 0; v < r.length; v++) {
if (r[v] === false) {
success = false;
promisesSuccess = false;
}
}

layer._pushFeatureCollections();
layer._pushFeatureCollections(function(success){
console.log("All edits done");

if(success && promisesSuccess){
self.emit(self.events.EDITS_ENQUEUED, results);
}
else {
if(!success){
console.log("applyEdits() there was a problem with _pushFeatureCollections.");
}
self.emit(self.events.EDITS_ENQUEUED_ERROR, results);
}

//promisesSuccess === true ? self.emit(self.events.EDITS_ENQUEUED, results) : self.emit(self.events.EDITS_ENQUEUED_ERROR, results);

// we already pushed the edits into the database, now we let the FeatureLayer to do the local updating of the layer graphics
this._editHandler(results, _adds, updatesMap, callback, errback, deferred1);
}.bind(this));

// we already pushed the edits into the database, now we let the FeatureLayer to do the local updating of the layer graphics
//success === true ? self.emit(self.events.EDITS_ENQUEUED, results) : self.emit(self.events.EDITS_ENQUEUED_ERROR, results);
// EDITS_ENQUEUED = callback(true, edit), and EDITS_ENQUEUED_ERROR = callback(false, /*String */ error)
this._editHandler(results, adds, updatesMap, callback, errback, deferred1);
success === true ? self.emit(self.events.EDITS_ENQUEUED, results) : self.emit(self.events.EDITS_ENQUEUED_ERROR, results);
//this._editHandler(results, _adds, updatesMap, callback, errback, deferred1);
}.bind(this));

return deferred1;
Expand Down Expand Up @@ -765,10 +780,10 @@ define([
* to reconstitute a featureLayer and then redisplay all the associated features.
*
* To retrieve use OfflineFeaturesManager.getFeatureCollections().
*
* @param callback (boolean)
* @private
*/
layer._pushFeatureCollections = function(){
layer._pushFeatureCollections = function(callback){

// First let's see if any collections exists
self._editStore._getFeatureCollections(function(success, result) {
Expand Down Expand Up @@ -827,8 +842,12 @@ define([
self._editStore._pushFeatureCollections(result, function(success, error) {
if(!success){
console.error("There was a problem creating the featureCollectionObject: " + error);
callback(false);
}
});
else {
callback(true);
}
}.bind(this));
});
};

Expand Down Expand Up @@ -1159,9 +1178,18 @@ define([
if(r.length === 0 && url){
// Initialize the internal featureLayerCollectionObject
if(this.ENABLE_FEATURECOLLECTION) {
layer._pushFeatureCollections();
layer._pushFeatureCollections(function(success){
if(success){
callback(true, null);
}
else {
callback(false, null);
}
});
}
else {
callback(true, null);
}
callback(true, null);
}
else if(r[0].success && !url){

Expand All @@ -1175,9 +1203,18 @@ define([

// Initialize the internal featureLayerCollectionObject
if(this.ENABLE_FEATURECOLLECTION) {
layer._pushFeatureCollections();
layer._pushFeatureCollections(function(success){
if(success){
callback(true, null);
}
else {
callback(false, null);
}
});
}
else {
callback(true, null);
}
callback(true, null);
}
else {
// NOTE: We have to have a valid feature layer URL in order to initialize the featureLayerCollectionObject
Expand All @@ -1188,12 +1225,19 @@ define([
}
else if(r[0].success){

// Initialize the internal featureLayerCollectionObject
if(this.ENABLE_FEATURECOLLECTION) {
layer._pushFeatureCollections();
layer._pushFeatureCollections(function(success){
if(success){
callback(true, null);
}
else {
callback(false, null);
}
});
}
else {
callback(true, null);
}

callback(true, null);
}
}.bind(this));

Expand Down
2 changes: 1 addition & 1 deletion dist/offline-tiles-advanced-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions dist/offline-tiles-advanced-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! esri-offline-maps - v2.15.0 - 2015-09-29
/*! esri-offline-maps - v2.16.0 - 2015-10-29
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
define([
Expand Down Expand Up @@ -449,7 +449,7 @@ define([
},

/**
* Assign various properties to the layer
* Assign various properties to the layer and then load tiles
* @param result
* @param context
* @param callback
Expand Down Expand Up @@ -544,10 +544,9 @@ define([
}
}
else {
// Now it's okay to parse the response
self._parseTileInfo(staticResponse, self, callback);
}

//callback(this.response);
}
else
{
Expand Down
Loading

0 comments on commit 8cc5783

Please sign in to comment.