now we can upload attachments and delete them from indexeddb afterwards

This commit is contained in:
Javier Abadia 2014-04-15 12:30:30 +02:00
parent d92acc87b3
commit 12be0cd6d6
2 changed files with 22 additions and 10 deletions

View File

@ -322,9 +322,24 @@ define([
var promises = []
attachments.forEach(function(attachment)
{
console.log("sending attachment", attachment.featureId);
promises.push( self._uploadAttachment(attachment) );
});
console.log("sending attachment", attachment.id, "to feature", attachment.featureId);
var uploadCompleted = self._uploadAttachment(attachment);
var deleteCompleted = new Deferred();
uploadCompleted.then(function(attachmentId, deleteCompleted) // closure to keep attachmentId and deleteCompleted value
{
return function(result)
{
console.log("upload complete",result,attachmentId);
this.attachmentsStore.delete(attachmentId, function(success)
{
console.log("delete complete", result, success);
deleteCompleted.resolve(result);
});
}.bind(this);
}.bind(this)(attachment.id, deleteCompleted)
);
promises.push( deleteCompleted );
}.bind(this));
console.log("promises", promises.length);
var allPromises = new all(promises);
allPromises.then(function(results)
@ -337,7 +352,7 @@ define([
console.log("error!",err);
callback && callback(false);
});
})
}.bind(this))
}

View File

@ -372,7 +372,7 @@ describe("Attachments", function()
expect(g_editsStore.pendingEditsCount()).toBe(0);
done();
});
/*
async.it("no attachments pending", function(done)
{
g_featureLayers[3].attachmentsStore.getUsage(function(usage)
@ -381,9 +381,7 @@ describe("Attachments", function()
done();
});
});
*/
/**/
async.it("query attachments info - online - 1", function(done)
{
g_featureLayers[3].queryAttachmentInfos(g1_online.attributes.objectid,
@ -417,7 +415,6 @@ describe("Attachments", function()
done();
});
});
//*/
})
});
});