spaces 2 tabs

This commit is contained in:
Javier Abadia 2014-03-02 15:56:14 +01:00
parent 7442fd32a2
commit 51102a3442

View File

@ -2,7 +2,7 @@
define([
"edit/editsStore",
"edit/dbAttachmentStore",
"edit/dbAttachmentStore",
"dojo/Evented",
"dojo/_base/Deferred",
"dojo/promise/all",
@ -32,19 +32,19 @@ define([
events: {
EDITS_SENT: 'edits-sent', // ...whenever any edit is actually sent to the server
EDITS_ENQUEUED: 'edits-enqueued', // ...when an edit is enqueued (and not sent to the server)
ALL_EDITS_SENT: 'all-edits-sent', // ...after going online and there are no pending edits in the queue
ATTACHMENTS_SENT: 'attachments-sent',
ATTACHMENTS_INFO: 'attachments-info',
ATTACHMENTS_ADD: 'attachments-add',
ATTACHMENTS_DELETED: 'attachments-deleted'
ALL_EDITS_SENT: 'all-edits-sent', // ...after going online and there are no pending edits in the queue
ATTACHMENTS_SENT: 'attachments-sent',
ATTACHMENTS_INFO: 'attachments-info',
ATTACHMENTS_ADD: 'attachments-add',
ATTACHMENTS_DELETED: 'attachments-deleted'
},
/**
* Overrides a feature layer.
* @param layer
* @returns deferred
*/
extend: function(layer,callback)
/**
* Overrides a feature layer.
* @param layer
* @returns deferred
*/
extend: function(layer,callback)
{
var self = this;
@ -53,103 +53,103 @@ define([
/* replace the applyEdits() method */
layer._applyEdits = layer.applyEdits;
layer._addAttachment = layer.addAttachment;
layer._queryAttachmentInfos = layer.queryAttachmentInfos;
layer._deleteAttachments = layer.deleteAttachments;
layer._addAttachment = layer.addAttachment;
layer._queryAttachmentInfos = layer.queryAttachmentInfos;
layer._deleteAttachments = layer.deleteAttachments;
try{
layer.offline = {
online: true,
store: new DbAttachmentStore(),
proxyPath: "../lib/resource-proxy/proxy.php"
//proxyPath: "http://localhost/proxy/proxy.php"
};
try{
layer.offline = {
online: true,
store: new DbAttachmentStore(),
proxyPath: "../lib/resource-proxy/proxy.php"
//proxyPath: "http://localhost/proxy/proxy.php"
};
if( /*false &&*/ layer.offline.store.isSupported() )
layer.offline.store.init(callback);
else
return callback(false, "indexedDB not supported");
}
catch(err){
console.log("problem! " + err.toString())
}
if( /*false &&*/ layer.offline.store.isSupported() )
layer.offline.store.init(callback);
else
return callback(false, "indexedDB not supported");
}
catch(err){
console.log("problem! " + err.toString())
}
layer.queryAttachmentInfos = function(objectId,callback,errback){
if( self.getOnlineStatus() == self.ONLINE)
{
var def = this._queryAttachmentInfos(objectId,
function()
{
self.emit(self.events.ATTACHMENTS_INFO,arguments);
callback && callback.apply(this,arguments);
},
errback);
return def;
}
else
{
//Needs to return a deferred
//TODO we should check if the objectId resides in local database
var deferred = new Deferred();
return deferred;
}
}
layer.queryAttachmentInfos = function(objectId,callback,errback){
if( self.getOnlineStatus() == self.ONLINE)
{
var def = this._queryAttachmentInfos(objectId,
function()
{
self.emit(self.events.ATTACHMENTS_INFO,arguments);
callback && callback.apply(this,arguments);
},
errback);
return def;
}
else
{
//Needs to return a deferred
//TODO we should check if the objectId resides in local database
var deferred = new Deferred();
return deferred;
}
}
layer.addAttachment = function(objectId,formNode,callback,errback){
if( self.getOnlineStatus() == self.ONLINE)
{
return this._addAttachment(objectId,formNode,
function(evt){
self.emit(self.events.ATTACHMENTS_SENT,arguments);
callback
},
function(err){
console.log("addAttachment: " + err)
errback
}
)
}
else
{
if(typeof objectId !== "undefined" || objectId.length > 0 || objectId !== null){
//this._storeAttachment()
}
}
}
layer.addAttachment = function(objectId,formNode,callback,errback){
if( self.getOnlineStatus() == self.ONLINE)
{
return this._addAttachment(objectId,formNode,
function(evt){
self.emit(self.events.ATTACHMENTS_SENT,arguments);
callback
},
function(err){
console.log("addAttachment: " + err)
errback
}
)
}
else
{
if(typeof objectId !== "undefined" || objectId.length > 0 || objectId !== null){
//this._storeAttachment()
}
}
}
layer.deleteAttachments = function(objectId,attachmentsIds,callback,errback){
if( self.getOnlineStatus() == self.ONLINE)
{
var def = this._deleteAttachments(objectId,attachmentsIds,
function()
{
self.emit(self.events.ATTACHMENTS_DELETED,arguments);
callback && callback.apply(this,arguments);
},
errback);
return def;
}
else
{
if(typeof objectId !== "undefined" || objectId.length > 0 || objectId !== null){
//this._storeAttachment()
}
}
}
layer.deleteAttachments = function(objectId,attachmentsIds,callback,errback){
if( self.getOnlineStatus() == self.ONLINE)
{
var def = this._deleteAttachments(objectId,attachmentsIds,
function()
{
self.emit(self.events.ATTACHMENTS_DELETED,arguments);
callback && callback.apply(this,arguments);
},
errback);
return def;
}
else
{
if(typeof objectId !== "undefined" || objectId.length > 0 || objectId !== null){
//this._storeAttachment()
}
}
}
layer._storeAttachment = function(object,callback){
layer._storeAttachment = function(object,callback){
}
}
/**
* Overrides the ArcGIS API for JavaSccript applyEdits() method.
* @param adds Creates a new edit entry.
* @param updates Updates an existing entry.
* @param deletes Deletes an existing entry.
* @param callback Called when the operation is complete.
* @param errback An error object is returned if an error occurs
* @returns {*} deferred
*/
/**
* Overrides the ArcGIS API for JavaSccript applyEdits() method.
* @param adds Creates a new edit entry.
* @param updates Updates an existing entry.
* @param deletes Deletes an existing entry.
* @param callback Called when the operation is complete.
* @param errback An error object is returned if an error occurs
* @returns {*} deferred
*/
layer.applyEdits = function(adds,updates,deletes,callback,errback)
{
// inside this method, 'this' will be the FeatureLayer
@ -253,17 +253,19 @@ define([
function _initPhantomLayer()
{
try{
layer._phantomLayer = new GraphicsLayer({opacity:0.8});
// layer._phantomLayer.disableMouseEvents();
// var index = layer.getMap().graphicsLayerIds.indexOf(layer.id);
// layer._map.addLayer(layer._phantomLayer,index-1);
layer._map.addLayer(layer._phantomLayer);
try
{
layer._phantomLayer = new GraphicsLayer({opacity:0.8});
// layer._phantomLayer.disableMouseEvents();
// var index = layer.getMap().graphicsLayerIds.indexOf(layer.id);
// layer._map.addLayer(layer._phantomLayer,index-1);
layer._map.addLayer(layer._phantomLayer);
}
catch(err)
{
console.log("Unable to init PhantomLayer");
}
}
catch(err){
console.log("Unable to init PhantomLayer");
}
}
_initPhantomLayer();
}, // extend
@ -317,39 +319,39 @@ define([
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [255,255,255,0],
"outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": color, "width": width }
"outline": { "type": "esriSLS", "style": "esriSLSSolid", "color": color, "width": width }
});
this._phantomSymbols['polygon'][editsStore.UPDATE] = new SimpleFillSymbol({
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [255,255,255,0],
"outline": { "type": "esriSLS", "style": "esriSLSDash", "color": color, "width": width }
"outline": { "type": "esriSLS", "style": "esriSLSDash", "color": color, "width": width }
});
this._phantomSymbols['polygon'][editsStore.DELETE] = new SimpleFillSymbol({
"type": "esriSFS",
"style": "esriSFSSolid",
"color": [255,255,255,0],
"outline": { "type": "esriSLS", "style": "esriSLSDot", "color": color, "width": width }
"outline": { "type": "esriSLS", "style": "esriSLSDot", "color": color, "width": width }
});
}
return this._phantomSymbols[ geometry.type ][ operation ];
},
/**
* Forces library into an offline state. Any edits applied during this condition will be stored locally
*/
/**
* Forces library into an offline state. Any edits applied during this condition will be stored locally
*/
goOffline: function()
{
console.log('going offline');
this._onlineStatus = this.OFFLINE;
},
/**
* 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
* @param callback callback( boolean, errors )
*/
/**
* 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
* @param callback callback( boolean, errors )
*/
goOnline: function(callback)
{
console.log('going online');
@ -362,20 +364,20 @@ define([
//this.refresh();
},
/**
* Determines if offline or online condition exists
* @returns {string} ONLINE or OFFLINE
*/
/**
* Determines if offline or online condition exists
* @returns {string} ONLINE or OFFLINE
*/
getOnlineStatus: function()
{
return this._onlineStatus;
},
/**
* A string value representing human readable information on pending edits
* @param edit
* @returns {string}
*/
/**
* A string value representing human readable information on pending edits
* @param edit
* @returns {string}
*/
getReadableEdit: function(edit)
{
var layer = this._featureLayers[ edit.layer ];