1st pass at bolting in attachment db store

This commit is contained in:
andygup 2014-02-23 12:16:52 -07:00
parent e1b9587e09
commit ac3baa69b0
3 changed files with 38 additions and 16 deletions

View File

@ -218,11 +218,11 @@ define([],function()
this.init = function(callback)
{
var request = indexedDB.open(this._localEnum().DB_NAME, 4);
callback = callback? callback : function(success) { console.log("DbStore::init() success:", success)}.bind(this);
callback = callback? callback : function(success) { console.log("dbAttachmentStore::init() success:", success)}.bind(this);
request.onerror = function(event)
{
console.log("indexedDB error: " + event.target.errorCode);
console.log("dbAttachmentStore error: " + event.target.errorCode);
callback(false,event.target.errorCode);
}.bind(this);

View File

@ -2,6 +2,7 @@
define([
"edit/editsStore",
"edit/dbAttachmentStore",
"dojo/Evented",
"dojo/_base/Deferred",
"dojo/promise/all",
@ -13,7 +14,8 @@ define([
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/request"],
function(editsStore,Evented,Deferred,all,declare,lang,GraphicsLayer,Graphic,SimpleMarkerSymbol,SimpleLineSymbol,SimpleFillSymbol,esriRequest)
function(editsStore,DbAttachmentStore,Evented,
Deferred,all,declare,lang,GraphicsLayer,Graphic,SimpleMarkerSymbol,SimpleLineSymbol,SimpleFillSymbol,esriRequest)
{
return declare([Evented],
{
@ -37,7 +39,7 @@ define([
* @param layer
* @returns deferred
*/
extend: function(layer)
extend: function(layer,callback)
{
var self = this;
@ -49,6 +51,22 @@ define([
layer._addAttachment = layer.addAttachment;
layer._queryAttachmentInfos = layer.queryAttachmentInfos;
try{
layer.offline = {
online: true,
store: new DbAttachmentStore(),
proxyPath: "../../lib/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())
}
layer.queryAttachmentInfos = function(objectId,callback,errback){
if( self.getOnlineStatus() == self.ONLINE)
{

View File

@ -102,20 +102,20 @@
mode: FeatureLayer.MODE_ONDEMAND
});
// map.infoWindow.setContent("<div id='content' style='width:100%'></div>");
// map.infoWindow.resize(350,200);
// var attachmentEditor = new AttachmentEditor({}, dom.byId("content"));
// attachmentEditor.startup();
map.infoWindow.setContent("<div id='content' style='width:100%'></div>");
map.infoWindow.resize(350,200);
var attachmentEditor = new AttachmentEditor({}, dom.byId("content"));
attachmentEditor.startup();
featureLayer.on("click", function(evt) {
var objectId = evt.graphic.attributes[featureLayer.objectIdField];
map.infoWindow.setTitle(objectId);
featureLayer.queryAttachmentInfos(objectId,function(evt){
console.log("AHAHAHA")
},function(err){
console.log("Problem querying attachments: " + err.toString())
})
//attachmentEditor.showAttachments(evt.graphic,featureLayer);
// featureLayer.queryAttachmentInfos(objectId,function(evt){
// console.log("AHAHAHA")
// },function(err){
// console.log("Problem querying attachments: " + err.toString())
// })
attachmentEditor.showAttachments(evt.graphic,featureLayer);
map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
});
@ -133,7 +133,6 @@
updateConnectivityIndicator();
updateStorageInfo();
Offline.options = {
checks: {
image: {
@ -156,7 +155,12 @@
try{
var test = featureLayer.allowGeometryUpdates; console.log("type " + test)
offlineFeaturesManager.extend(featureLayer);
offlineFeaturesManager.extend(featureLayer,function(success){
console.log("extend ");
if(success){
}
});
layer.on('update-end', logCurrentObjectIds);
//handle errors that happen while storing offline edits