From 381a18a1612b596df2ff54fb8f46fd48e5561ef6 Mon Sep 17 00:00:00 2001 From: Javier Abadia Date: Sat, 5 Apr 2014 17:18:29 +0200 Subject: [PATCH] comments for next steps --- lib/edit/offlineFeaturesManager.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/edit/offlineFeaturesManager.js b/lib/edit/offlineFeaturesManager.js index 6fcd245..48d031f 100644 --- a/lib/edit/offlineFeaturesManager.js +++ b/lib/edit/offlineFeaturesManager.js @@ -123,13 +123,16 @@ define([ 6. update a new attachment concerns: - - should the key in the db be the objectId or the attachmentId? - manage the relationship between offline features and attachments: what if the user wants to add an attachment to a feature that is still offline? we need to keep track of objectids so that when the feature is sent to the server and receives a final objectid we replace the temporary negative id by its final objectid - what if the user deletes an offline feature that had offline attachments? we need to discard the attachment + pending tasks: + - delete attachment + - send attachments to server when reconnecting + */ // @@ -150,6 +153,7 @@ define([ } else { + // will only return LOCAL attachments var deferred = new Deferred(); this.attachmentsStore.getAttachmentsByFeatureId(this.url, objectId, function(attachments) { @@ -184,8 +188,6 @@ define([ // read file from input into variable this._readFilesFromForm(formNode, function(files) { - // callback is called once for each input[type=file] node in formNode - // and each input node might contain several files console.log(files); console.assert(files.length == 1, "we don't support multiple files (yet?)"); files.forEach(function(file) @@ -278,9 +280,11 @@ define([ } else { - console.log("deleteAttachments() - OFFLINE", objectId, attachmentsIds); + // TODO - + // case 1.- it is a new attachment + + // case 2.- it is an already existing attachment } } @@ -541,6 +545,8 @@ define([ _optimizeEditsQueue: function() { + // TODO: take care of attachments + // console.log("edits:", editsStore._retrieveEditsQueue().map(function(e){return this.getReadableEdit(e)},this)); var optimizedEdits = {}; var editCount = editsStore.pendingEditsCount(); @@ -599,6 +605,8 @@ define([ _replayStoredEdits: function(callback) { + // TODO: take care of attachments + if( editsStore.hasPendingEdits() ) { //