aboutsummaryrefslogtreecommitdiffstats
path: root/www
diff options
context:
space:
mode:
Diffstat (limited to 'www')
-rw-r--r--www/js/app.js16
-rw-r--r--www/js/views/existing.js20
-rw-r--r--www/js/views/submit.js21
3 files changed, 29 insertions, 28 deletions
diff --git a/www/js/app.js b/www/js/app.js
index caf7bed..20eceed 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -69,6 +69,22 @@ var tpl = {
localStorage.currentDraftID = null;
},
+ removeDraft: function(draftID, removePhoto) {
+ console.log( draftID );
+ var draft = FMS.allDrafts.get(draftID);
+ console.log( draft );
+ var uri = draft.get('file');
+ FMS.allDrafts.remove(draft);
+ draft.destroy();
+
+ if ( removePhoto && uri ) {
+ return FMS.files.deleteURI( uri );
+ }
+ var p = $.Deferred();
+ p.resolve();
+ return p;
+ },
+
initialize: function () {
if ( this.initialized == 1 ) {
return this;
diff --git a/www/js/views/existing.js b/www/js/views/existing.js
index 1fc88c0..4abf857 100644
--- a/www/js/views/existing.js
+++ b/www/js/views/existing.js
@@ -17,21 +17,13 @@
},
discardReport: function() {
- var uri = FMS.currentDraft.get('file');
- FMS.allDrafts.remove(FMS.currentDraft);
- FMS.currentDraft.destroy();
- localStorage.currentDraftID = null;
- FMS.currentDraft = new FMS.Draft();
-
- if ( uri ) {
- var del = FMS.files.deleteURI( uri );
-
- var that = this;
- del.done( function() { that.navigate( 'around' ); } );
+ var reset = FMS.removeDraft(FMS.currentDraft.id, true);
+ var that = this;
+ reset.done( function() { that.onDraftRemove(); } );
+ },
- } else {
- this.navigate( 'around', 'left' );
- }
+ onDraftRemove: function() {
+ this.navigate( 'around', 'left' );
}
})
});
diff --git a/www/js/views/submit.js b/www/js/views/submit.js
index d94a03f..27b21f7 100644
--- a/www/js/views/submit.js
+++ b/www/js/views/submit.js
@@ -47,23 +47,16 @@
if ( FMS.currentUser ) {
FMS.currentUser.save();
}
- var id = FMS.currentDraft.id;
- var uri = FMS.currentDraft.get('file');
- FMS.allDrafts.remove(FMS.currentDraft);
- FMS.currentDraft.destroy();
+ var reset = FMS.removeDraft( FMS,currentDraftID, true);
+ var that = this;
+ reset.done( function() { that.onRemoveDraft(); } );
+ },
+
+ onRemoveDraft: function() {
FMS.currentDraft = new FMS.Draft();
localStorage.currentDraftID = null;
FMS.createdReport = this.report;
-
- if ( uri ) {
- var del = FMS.files.deleteURI( uri );
-
- var that = this;
- del.done( function() { that.navigate( 'sent' ); } );
-
- } else {
- this.navigate( 'sent', 'left' );
- }
+ this.navigate( 'sent', 'left' );
},
onReportError: function(model, err, options) {