mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
parent
d61fcd691a
commit
f0913c0f24
@ -25,7 +25,8 @@ define([
|
|||||||
_featureLayers: {},
|
_featureLayers: {},
|
||||||
_featureCollectionUsageFlag: false, // if a feature collection was used to create the feature layer.
|
_featureCollectionUsageFlag: false, // if a feature collection was used to create the feature layer.
|
||||||
_editStore: new O.esri.Edit.EditStore(),
|
_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
|
ONLINE: "online", // all edits will directly go to the server
|
||||||
OFFLINE: "offline", // edits will be enqueued
|
OFFLINE: "offline", // edits will be enqueued
|
||||||
@ -121,6 +122,14 @@ define([
|
|||||||
// library will break and we'll have to re-architect how it manages UIDs.
|
// library will break and we'll have to re-architect how it manages UIDs.
|
||||||
layer.objectIdField = this.DB_UID;
|
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;
|
var url = null;
|
||||||
|
|
||||||
// There have been reproducible use cases showing when a browser is restarted offline that
|
// There have been reproducible use cases showing when a browser is restarted offline that
|
||||||
@ -1896,7 +1905,28 @@ define([
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// addResults present a special case for handling objectid
|
||||||
if(addResults.length > 0) {
|
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);
|
var graphic = new Graphic(adds[0].geometry,null,adds[0].attributes);
|
||||||
layer.add(graphic);
|
layer.add(graphic);
|
||||||
}
|
}
|
||||||
@ -2051,11 +2081,11 @@ define([
|
|||||||
if( req.status === 200 && req.responseText !== "")
|
if( req.status === 200 && req.responseText !== "")
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
var obj = JSON.parse(this.response);
|
var obj = JSON.parse(this.responseText);
|
||||||
callback(obj.addResults, obj.updateResults, obj.deleteResults);
|
callback(obj.addResults, obj.updateResults, obj.deleteResults);
|
||||||
}
|
}
|
||||||
catch(err) {
|
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);
|
errback("Unable to parse xhr response", req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,8 +24,9 @@ define([
|
|||||||
_onlineStatus: "online",
|
_onlineStatus: "online",
|
||||||
_featureLayers: {},
|
_featureLayers: {},
|
||||||
_editStore: new O.esri.Edit.EditStorePOLS(),
|
_editStore: new O.esri.Edit.EditStorePOLS(),
|
||||||
_defaultXhrTimeout: 15000, // ms
|
_defaultXhrTimeout: 15000, // ms
|
||||||
_autoOfflineDetect: true,
|
_autoOfflineDetect: true,
|
||||||
|
_esriFieldTypeOID: "", // Determines the correct casing for objectid. Some feature layers use different casing
|
||||||
|
|
||||||
ONLINE: "online", // all edits will directly go to the server
|
ONLINE: "online", // all edits will directly go to the server
|
||||||
OFFLINE: "offline", // edits will be enqueued
|
OFFLINE: "offline", // edits will be enqueued
|
||||||
@ -76,6 +77,14 @@ define([
|
|||||||
// library will break and we'll have to re-architect how it manages UIDs.
|
// library will break and we'll have to re-architect how it manages UIDs.
|
||||||
layer.objectIdField = this.DB_UID;
|
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;
|
var url = null;
|
||||||
|
|
||||||
// There have been reproducible use cases showing when a browser is restarted offline that
|
// There have been reproducible use cases showing when a browser is restarted offline that
|
||||||
@ -820,7 +829,29 @@ define([
|
|||||||
this._makeEditRequest(layer, adds, updates, deletes,
|
this._makeEditRequest(layer, adds, updates, deletes,
|
||||||
function (addResults, updateResults, deleteResults) {
|
function (addResults, updateResults, deleteResults) {
|
||||||
|
|
||||||
|
// addResults present a special case for handling objectid
|
||||||
if(addResults.length > 0) {
|
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);
|
var graphic = new Graphic(adds[0].geometry,null,adds[0].attributes);
|
||||||
layer.add(graphic);
|
layer.add(graphic);
|
||||||
}
|
}
|
||||||
@ -962,11 +993,12 @@ define([
|
|||||||
if( req.status === 200 && req.responseText !== "")
|
if( req.status === 200 && req.responseText !== "")
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
var obj = JSON.parse(this.response);
|
// var b = this.responseText.replace(/"/g, "'"); // jshint ignore:line
|
||||||
|
var obj = JSON.parse(this.responseText);
|
||||||
callback(obj.addResults, obj.updateResults, obj.deleteResults);
|
callback(obj.addResults, obj.updateResults, obj.deleteResults);
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
console.error("EDIT REQUEST REPONSE WAS NOT SUCCESSFUL:", req);
|
console.error("FAILED TO PARSE EDIT REQUEST RESPONSE:", req);
|
||||||
errback("Unable to parse xhr response", req);
|
errback("Unable to parse xhr response", req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user