diff options
author | Struan Donald <struan@exo.org.uk> | 2013-04-10 17:49:46 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-04-10 19:28:10 +0100 |
commit | 29dbfd34463b4b8150c480e10728e95d9899f790 (patch) | |
tree | 2677fc239e4ea775f4a8f27d9f195de7e621dba7 /www/js/views/submit.js | |
parent | 0e46c1437b622f503f9ab8154dff4e6db33a0cb1 (diff) |
when we have submitted a report remove the draft and any associated photo
Diffstat (limited to 'www/js/views/submit.js')
-rw-r--r-- | www/js/views/submit.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/www/js/views/submit.js b/www/js/views/submit.js index b48461c..b2e54f0 100644 --- a/www/js/views/submit.js +++ b/www/js/views/submit.js @@ -43,12 +43,26 @@ }, onReportSync: function(model, resp, options) { + this.stopListening(); if ( FMS.currentUser ) { FMS.currentUser.save(); } - FMS.currentDraft = new FMS.Draft(); + var id = FMS.currentDraft.id; + var uri = FMS.currentDraft.get('file'); + FMS.allDrafts.remove(FMS.currentDraft); + FMS.currentDraft.destroy(); + localStorage.currentDraftID = null; FMS.createdReport = this.report; - this.navigate( 'sent', 'left' ); + + if ( uri ) { + var del = FMS.files.deleteURI( this.photoURI ); + + var that = this; + del.done( function() { that.navigate( 'sent' ); } ); + + } else { + this.navigate( 'sent', 'left' ); + } }, onReportError: function(model, err, options) { |