Skip to content

Commit

Permalink
Merge pull request #337 from andygup/goonline
Browse files Browse the repository at this point in the history
v2.8
  • Loading branch information
andygup committed May 5, 2015
2 parents 04e0208 + b9c3345 commit 1fa1bb8
Show file tree
Hide file tree
Showing 18 changed files with 623 additions and 277 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# offline-editor-js - Changelog

## Version 2.8 - May 4, 2015

This release focused on updating full offline editing capabilities. Recommended update. No breaking changes.

**Enhancements**
* Added functionality to `offlineFeaturesManager.js` to detect and handle when a feature layer is created using a feature collection.
* Addresses browser changes in Chrome 42.x and Firefox 37.x with respect to how they handle HTML/JS apps when going offline and
then transitioning back online.
* Updated `appcache-features.html` sample.

**Bug Fix**
* Closes #336 - problem with appcache-features sample. The application now correctly syncs when going back online after
a full offline restart. It also contains improvements in how the app life-cycle is handled.

## Version 2.7.1 - April 29, 2015

This release has enhancements and has no breaking changes.
Expand Down
6 changes: 3 additions & 3 deletions dist/offline-edit-min.js

Large diffs are not rendered by default.

290 changes: 223 additions & 67 deletions dist/offline-edit-src.js

Large diffs are not rendered by default.

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.

2 changes: 1 addition & 1 deletion dist/offline-tiles-advanced-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! offline-editor-js - v2.7.1 - 2015-04-29
/*! offline-editor-js - v2.8 - 2015-05-05
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
define([
Expand Down
2 changes: 1 addition & 1 deletion dist/offline-tiles-basic-min.js

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

2 changes: 1 addition & 1 deletion dist/offline-tiles-basic-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! offline-editor-js - v2.7.1 - 2015-04-29
/*! offline-editor-js - v2.8 - 2015-05-05
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
define([
Expand Down
2 changes: 1 addition & 1 deletion dist/offline-tpk-min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/offline-tpk-src.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! offline-editor-js - v2.7.1 - 2015-04-29
/*! offline-editor-js - v2.8 - 2015-05-05
* Copyright (c) 2015 Environmental Systems Research Institute, Inc.
* Apache License*/
/**
Expand Down
38 changes: 34 additions & 4 deletions doc/howtouseeditlibrary.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ NOTE: You can also monitor standard ArcGIS API for JavaScript layer events using
```
**Step 4** After the `layers-add-result` event fires extend the feature layer using the `extend()` method. Optionally, if you are building a fully offline app then you will also need to set the `dataStore` property in the constructor.
**Step 4** After the `layers-add-result` event fires extend the feature layer using the `extend()` method. Optionally, if you are building a fully offline app then you will also need to set the `dataStore` property in the constructor.
Note: the `layer.extend()` callback only indicates that the edits database has been successfully initialized.
```js
Expand All @@ -86,7 +88,7 @@ NOTE: You can also monitor standard ArcGIS API for JavaScript layer events using
// options.graphics = JSON.stringify(layer1.toJson());
// options.zoom = map.getZoom();
offlineFeaturesManager.extend(layer1,function(success,error){
offlineFeaturesManager.extend(layer1,function(success, error){
if(success){
console.log("layer1 has been extended for offline use.");
}
Expand All @@ -95,6 +97,34 @@ NOTE: You can also monitor standard ArcGIS API for JavaScript layer events using
```
When working with fully offline browser restarts you should wait until the layer has been successfully extended before forcing the library to go back online. The workflow for this coding pattern is you start out online > offline > browser restart > then back online.
```js
offlineFeaturesManager.extend(layer1, function(success, error) {
if(success) {
// If the app is online then force offlineFeaturesManager to its online state
// This will force the library to check for pending edits and attempt to
// resend them to the Feature Service.
if(_isOnline){ // Check if app is online or offline
offlineFeaturesManager.goOnline(function(result){
if(!result.success){
alert("There was a problem when attempting to go back online.");
}
else {
// Do somthing good!
}
});
}
else {
offlineFeaturesManager.goOffline();
}
}
});
```
The `dataStore` property is an object that is used to store any data related to your app that will assist in restoring it and any feature layers after a full offline browser restart. The `dataStore` object has one reserved key and that is `id`. If you overwrite the `id` key the application will fail to update the `dataStore` object correctly. Here is an example of one possible `dataStore` object:
```js
Expand Down Expand Up @@ -160,9 +190,9 @@ Force the library to return to an online condition. If there are pending edits,
```js
function goOnline()
{
offlineFeaturesManager.goOnline(function(success,results)
offlineFeaturesManager.goOnline(function(result)
{
if(success){
if(result.success){
//Modify user inteface depending on success/failure
}
});
Expand Down
6 changes: 3 additions & 3 deletions doc/offlinefeaturesmanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ OfflineFeaturesManager provides the following functionality.

Methods | Returns | Description
--- | --- | ---
`extend(layer,callback,dataStore)`|`callback( boolean, errors )`| Overrides a feature layer, by replacing the `applyEdits()` method of the layer. You can use the FeatureLayer as always, but it's behaviour will be enhanced according to the online status of the manager and the capabilities included in this library. `Callback` is related to initialization the library. <br><br>`dataStore` is an optional Object that contains any information you need when reconsistuting the layer after an offline browser restart. Refer to the [How to use the edit library doc](howtouseeditlibrary.md) for addition information.
`extend( layer,` `callback, dataStore)`|`callback( boolean, errors )`| Overrides a feature layer, by replacing the `applyEdits()` method of the layer. You can use the FeatureLayer as always, but it's behaviour will be enhanced according to the online status of the manager and the capabilities included in this library.<br><br> `Callback` indicates the layer has been extended. <br><br>`dataStore` is an optional Object that contains any information you need when reconsistuting the layer after an offline browser restart. Refer to the [How to use the edit library doc](howtouseeditlibrary.md) for addition information.
`goOffline()` | nothing | Forces library into an offline state. Any edits applied to extended FeatureLayers during this condition will be stored locally.
`goOnline(callback)` | `callback( boolean, results )` | Forces library to return to an online state. If there are pending edits, an attempt will be made to sync them with the remote feature server. Callback function will be called when resync process is done. <br><br>Refer to the [How to use the edit library doc](howtouseeditlibrary.md) for addition information on the `results` object.
`goOnline(callback)` | No attachments: `callback( {success: boolean, responses: Object } )`<br><br> With attachments: `callback( {success: boolean, responses: uploadedResponses, dbResponses: dbResponses })` | Forces library to return to an online state. If there are pending edits, an attempt will be made to sync them with the remote feature server. Callback function will be called when resync process is done. <br><br>Refer to the [How to use the edit library doc](howtouseeditlibrary.md) for addition information on the `results` object.
`getOnlineStatus()` | `ONLINE`, `OFFLINE` or `RECONNECTING`| Determines the current state of the manager. Please, note that this library doesn't detect actual browser offline/online condition. You need to use the `offline.min.js` library included in `vendor\offline` directory to detect connection status and connect events to goOffline() and goOnline() methods. See `military-offline.html` sample.
`getFeatureLayerJSONDataStore` | `callback( boolean, Object)` | **New @ v2.7.1** Returns the feature layer's dataStore Object.
`getFeatureLayerJSONDataStore( callback )` | `callback( boolean, Object)` | **New @ v2.7.1** Returns the feature layer's dataStore Object.
`getReadableEdit()` | String | **DEPRECATED** @ v2.5. A string value representing human readable information on pending edits. Use `featureLayer.getAllEditsArray()`.


Expand Down
2 changes: 1 addition & 1 deletion lib/edit/editsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ O.esri.Edit.EditStore = function () {
this._db = event.target.result;
this._isDBInit = true;
console.log("database opened successfully");
callback(true);
callback(true, null);
}.bind(this);
};

Expand Down
Loading

0 comments on commit 1fa1bb8

Please sign in to comment.