Skip to content

Commit

Permalink
Merge pull request #493 from andygup/v3.7
Browse files Browse the repository at this point in the history
v3.7.0
  • Loading branch information
andygup authored Nov 1, 2016
2 parents 2626661 + ca31f01 commit 9025744
Show file tree
Hide file tree
Showing 12 changed files with 728 additions and 589 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# offline-editor-js - Changelog

## Version 3.7.0 - Nov 1, 2016

No breaking changes.

**Enhancements**
* Closes #491 - better handling of OBJECTID when returning online
* Closes #492 - it's working again, no clue why. No fix. Could be how JSON is being returned from AGOL.


## Version 3.6.0 - October 17, 2016

No breaking changes.
Expand Down
17 changes: 10 additions & 7 deletions dist/offline-edit-advanced-min.js

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

38 changes: 34 additions & 4 deletions dist/offline-edit-advanced-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! esri-offline-maps - v3.6.0 - 2016-10-17
/*! esri-offline-maps - v3.7.0 - 2016-11-01
* Copyright (c) 2016 Environmental Systems Research Institute, Inc.
* Apache License*/
// Configure offline/online detection
Expand Down Expand Up @@ -41,7 +41,8 @@ define([
_featureLayers: {},
_featureCollectionUsageFlag: false, // if a feature collection was used to create the feature layer.
_editStore: new O.esri.Edit.EditStore(),
_defaultXhrTimeout: 15000, // ms
_defaultXhrTimeout: 15000, // ms
_esriFieldTypeOID: "", // Determines the correct casing for objectid. Some feature layers use different casing

ONLINE: "online", // all edits will directly go to the server
OFFLINE: "offline", // edits will be enqueued
Expand Down Expand Up @@ -137,6 +138,14 @@ define([
// library will break and we'll have to re-architect how it manages UIDs.
layer.objectIdField = this.DB_UID;

// NOTE: set the casing for the feature layers objectid.
for(var i = 0; i < layer.fields.length; i++){
if(layer.fields[i].type === "esriFieldTypeOID"){
this._esriFieldTypeOID = layer.fields[i].name;
break;
}
}

var url = null;

// There have been reproducible use cases showing when a browser is restarted offline that
Expand Down Expand Up @@ -1912,7 +1921,28 @@ define([
});
}

// addResults present a special case for handling objectid
if(addResults.length > 0) {
var objectid = "";

if(addResults[0].hasOwnProperty("objectid")){
objectid = "objectid";
}

if(addResults[0].hasOwnProperty("objectId")){
objectid = "objectId";
}

if(addResults[0].hasOwnProperty("OBJECTID")){
objectid = "OBJECTID";
}

// ??? These are the most common objectid values. I may have missed some!

// Some feature layers will return different casing such as: 'objectid', 'objectId' and 'OBJECTID'
// Normalize these values to the feature type OID so that we don't break other aspects
// of the JS API.
adds[0].attributes[that._esriFieldTypeOID] = addResults[0][objectid];
var graphic = new Graphic(adds[0].geometry,null,adds[0].attributes);
layer.add(graphic);
}
Expand Down Expand Up @@ -2067,11 +2097,11 @@ define([
if( req.status === 200 && req.responseText !== "")
{
try {
var obj = JSON.parse(this.response);
var obj = JSON.parse(this.responseText);
callback(obj.addResults, obj.updateResults, obj.deleteResults);
}
catch(err) {
console.error("EDIT REQUEST RESPONSE WAS NOT SUCCESSFUL:", req);
console.error("FAILED TO PARSE EDIT REQUEST RESPONSE:", req);
errback("Unable to parse xhr response", req);
}
}
Expand Down
Loading

0 comments on commit 9025744

Please sign in to comment.