diff options
author | Struan Donald <struan@exo.org.uk> | 2013-04-19 15:55:05 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-04-22 15:56:00 +0100 |
commit | c87246d4b0597d25b2407c22ca26a30aa7505e1e (patch) | |
tree | 29f2bc8b68ef7b234b4c53a10f42b1ab486dfc2c /www/js | |
parent | f1afbeffe0f749f0fb22280485a1c7f982446564 (diff) |
do not save blank offline reports
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/views/offline.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/www/js/views/offline.js b/www/js/views/offline.js index 8fcc6a7..6bc0134 100644 --- a/www/js/views/offline.js +++ b/www/js/views/offline.js @@ -18,6 +18,17 @@ 'click #locate': 'locate' }, + draftHasContent: function() { + var hasContent = false; + + if ( $('#form_title').val() || $('#form_detail').val() || + this.model.get('lat') || this.model.get('file') ) { + hasContent = true; + } + + return hasContent; + }, + failedLocation: function(details) { this.finishedLocating(); this.locateCount = 21; @@ -86,6 +97,21 @@ onClickButtonNext: function() { this.updateCurrentReport(); + if ( !this.draftHasContent() && this.model.id ) { + var del = FMS.removeDraft( this.model.id ); + + var that = this; + del.done( function() { that.draftDeleted(); } ); + } else { + localStorage.currentDraftID = null; + localStorage.currentDraft = new FMS.Draft(); + this.navigate( this.next, 'left' ); + } + }, + + draftDeleted: function() { + localStorage.currentDraftID = null; + localStorage.currentDraft = new FMS.Draft(); this.navigate( this.next, 'left' ); }, @@ -93,7 +119,6 @@ this.model.set('title', $('#form_title').val()); this.model.set('details', $('#form_detail').val()); FMS.saveCurrentDraft(); - localStorage.currentDraftID = FMS.currentDraft.id; } }) }); |