This commit is contained in:
Andy Gup 2015-05-11 15:36:00 -06:00
parent 6f700a2ba5
commit f699bb8c37
11 changed files with 33 additions and 25 deletions

View File

@ -1,5 +1,13 @@
# offline-editor-js - Changelog
## Version 2.8.1 - May 11, 2015
No breaking changes.
**Enhancements**
* Closes #339 - offline update of a new attachment needs to be handled as an ADD.
* Updated offlineAttachmentsSpec.js to test for #339 condition.
## Version 2.8 - May 4, 2015
This release focused on updating full offline editing capabilities. Recommended update. No breaking changes.

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! offline-editor-js - v2.8 - 2015-05-05
/*! offline-editor-js - v2.8.1 - 2015-05-11
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
/*jshint -W030 */
@ -266,10 +266,17 @@ define([
var files = this._getFilesFromForm(formNode);
var file = files[0]; // addAttachment can only add one file, so the rest -if any- are ignored
var action = self.attachmentsStore.TYPE.UPDATE; // Is this an ADD or an UPDATE?
var deferred = new Deferred();
self.attachmentsStore.store(this.url, attachmentId, objectId, file, self.attachmentsStore.TYPE.UPDATE, function (success, newAttachment) {
// If the attachment has a temporary ID we want to keep it's action as an ADD.
// Otherwise we'll get an error when we try to UPDATE an ObjectId that doesn't exist in ArcGIS Online or Server.
if(attachmentId < 0) {
action = self.attachmentsStore.TYPE.ADD;
}
self.attachmentsStore.store(this.url, attachmentId, objectId, file, action, function (success, newAttachment) {
var returnValue = {attachmentId: attachmentId, objectId: objectId, success: success};
if (success) {
self.emit(self.events.ATTACHMENT_ENQUEUED, returnValue);
@ -1906,8 +1913,6 @@ define([
*/
_makeEditRequest: function(url,adds, updates, deletes, callback, errback) {
//var dfd = new Deferred();
var data = new FormData();
data.append("f", "json");
if(adds.length > 0) {
@ -1927,12 +1932,7 @@ define([
if( req.status === 200 && req.responseText !== "")
{
var obj = JSON.parse(this.response);
//dfd.resolve(obj);
callback(obj.addResults, obj.updateResults, obj.deleteResults);
//callback(this.response);
//Object.keys(this.response).forEach(function(key) {
// console.log(key, this.response[key]);
//});
}
};
req.onerror = function(e)
@ -3076,12 +3076,12 @@ O.esri.Edit.AttachmentsStore = function () {
callback(false, event.target.error.message);
};
var objectStore = transaction.objectStore(this.objectStoreName);
var request = objectStore.put(newAttachment);
request.onsuccess = function (event) {
//console.log("item added to db " + event.target.result);
};
try {
transaction.objectStore(this.objectStoreName).put(newAttachment);
}
catch(err) {
callback(false, err);
}
}
else {
callback(false, fileContent);

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! offline-editor-js - v2.8 - 2015-05-05
/*! offline-editor-js - v2.8.1 - 2015-05-11
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
define([

View File

@ -1,4 +1,4 @@
/*! offline-editor-js - v2.8 - 2015-05-05
/*! offline-editor-js - v2.8.1 - 2015-05-11
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
define(["dojo/query","dojo/request","esri/geometry/Polygon","dojo/_base/declare"],function(a,b,c,d){"use strict";return d("O.esri.Tiles.OfflineTilesEnabler",[],{getBasemapLayer:function(a){var b=a.layerIds[0];return a.getLayer(b)},extend:function(c,d,e){c._tilesCore=new O.esri.Tiles.TilesCore,c._lastTileUrl="",c._imageType="",c._minZoom=null,c._maxZoom=null,c._getTileUrl=c.getTileUrl;var f=!0;return"undefined"!=typeof e&&(f=e),c.offline={online:f,store:new O.esri.Tiles.TilesStore,proxyPath:null},c.offline.store.isSupported()?(c.offline.store.init(function(b){b&&(c.resampling=!1,c.getTileUrl=function(b,d,e){var f=this._getTileUrl(b,d,e);if(this.offline.online)return""==c._imageType&&(c._imageType=this.tileInfo.format.toLowerCase()),c._lastTileUrl=f,f;f=f.split("?")[0];var g="void:/"+b+"/"+d+"/"+e,h=null;return c._tilesCore._getTiles(h,this._imageType,f,g,this.offline.store,a),g},d&&d(!0))}.bind(this)),c.getLevelEstimation=function(a,b,c){var d=new O.esri.Tiles.TilingScheme(this),e=d.getAllCellIdsInExtent(a,b),f={level:b,tileCount:e.length,sizeBytes:e.length*c};return f},c.prepareForOffline=function(a,b,d,e){c._tilesCore._createCellsForOffline(this,a,b,d,function(a){this._doNextTile(0,a,e)}.bind(this))},c.goOffline=function(){this.offline.online=!1},c.goOnline=function(){this.offline.online=!0,this.refresh()},c.isOnline=function(){return this.offline.online},c.deleteAllTiles=function(a){var b=this.offline.store;b.deleteAll(a)},c.getOfflineUsage=function(a){var b=this.offline.store;b.usedSpace(a)},c.getTilePolygons=function(a){c._tilesCore._getTilePolygons(this.offline.store,c.url,this,a)},c.saveToFile=function(a,b){c._tilesCore._saveToFile(a,this.offline.store,b)},c.loadFromFile=function(a,b){c._tilesCore._loadFromFile(a,this.offline.store,b)},c.getMaxZoom=function(a){null==this._maxZoom&&(this._maxZoom=c.tileInfo.lods[c.tileInfo.lods.length-1].level),a(this._maxZoom)},c.getMinZoom=function(a){null==this._minZoom&&(this._minZoom=c.tileInfo.lods[0].level),a(this._minZoom)},c.getMinMaxLOD=function(a,b){var d={},e=c.getMap(),f=e.getLevel()+a,g=e.getLevel()+b;return null!=this._maxZoom&&null!=this._minZoom?(d.max=Math.min(this._maxZoom,g),d.min=Math.max(this._minZoom,f)):(c.getMinZoom(function(a){d.min=Math.max(a,f)}),c.getMaxZoom(function(a){d.max=Math.min(a,g)})),d},c.estimateTileSize=function(a){c._tilesCore._estimateTileSize(b,this._lastTileUrl,this.offline.proxyPath,a)},c.getExtentBuffer=function(a,b){return b.xmin-=a,b.ymin-=a,b.xmax+=a,b.ymax+=a,b},c.getTileUrlsByExtent=function(a,b){var d=new O.esri.Tiles.TilingScheme(c),e=d.getAllCellIdsInExtent(a,b),f=[];return e.forEach(function(a){f.push(c.url+"/"+b+"/"+a[1]+"/"+a[0])}.bind(this)),f},void(c._doNextTile=function(a,b,d){var e=b[a],f=this._getTileUrl(e.level,e.row,e.col);c._tilesCore._storeTile(f,this.offline.proxyPath,this.offline.store,function(c,f){c||(f={cell:e,msg:f});var g=d({countNow:a,countMax:b.length,cell:e,error:f,finishedDownloading:!1});g||a===b.length-1?d({finishedDownloading:!0,cancelRequested:g}):this._doNextTile(a+1,b,d)}.bind(this))})):d(!1,"indexedDB not supported")}})}),"undefined"!=typeof O?O.esri.Tiles={}:(O={},O.esri={Tiles:{}}),O.esri.Tiles.Base64Utils={},O.esri.Tiles.Base64Utils.outputTypes={Base64:0,Hex:1,String:2,Raw:3},O.esri.Tiles.Base64Utils.addWords=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},O.esri.Tiles.Base64Utils.stringToWord=function(a){for(var b=8,c=(1<<b)-1,d=[],e=0,f=a.length*b;f>e;e+=b)d[e>>5]|=(a.charCodeAt(e/b)&c)<<e%32;return d},O.esri.Tiles.Base64Utils.wordToString=function(a){for(var b=8,c=(1<<b)-1,d=[],e=0,f=32*a.length;f>e;e+=b)d.push(String.fromCharCode(a[e>>5]>>>e%32&c));return d.join("")},O.esri.Tiles.Base64Utils.wordToHex=function(a){for(var b="0123456789abcdef",c=[],d=0,e=4*a.length;e>d;d++)c.push(b.charAt(a[d>>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15));return c.join("")},O.esri.Tiles.Base64Utils.wordToBase64=function(a){for(var b="=",c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d=[],e=0,f=4*a.length;f>e;e+=3)for(var g=(a[e>>2]>>8*(e%4)&255)<<16|(a[e+1>>2]>>8*((e+1)%4)&255)<<8|a[e+2>>2]>>8*((e+2)%4)&255,h=0;4>h;h++)d.push(8*e+6*h>32*a.length?b:c.charAt(g>>6*(3-h)&63));return d.join("")},/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */

View File

@ -1,4 +1,4 @@
/*! offline-editor-js - v2.8 - 2015-05-05
/*! offline-editor-js - v2.8.1 - 2015-05-11
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
define([

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,4 @@
/*! offline-editor-js - v2.8 - 2015-05-05
/*! offline-editor-js - v2.8.1 - 2015-05-11
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
/**

View File

@ -1,6 +1,6 @@
{
"name": "offline-editor-js",
"version": "2.8",
"version": "2.8.1",
"description": "Lightweight set of libraries for working offline with map tiles and ArcGIS feature services",
"author": "Andy Gup <agup@esri.com> (http://blog.andygup.net)",
"license": "Apache 2",

View File

@ -9,7 +9,7 @@
"appHomePage": "appcache-features.html",
"optimizedApiURL": "../samples/jsolib",
"arcGISBaseURL": "http://js.arcgis.com/3.11",
"version": "2.8",
"version": "2.8.1",
"private": true,
"description": "manifest generator project",
"repository": {