aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-04-22 15:33:32 +0100
committerStruan Donald <struan@exo.org.uk>2013-04-22 15:58:17 +0100
commitbacefc8d0568236ffdb1912882e2ff5419b2a818 (patch)
treeedc7808388b320c310be010123ddb3ff7dc3a037 /www/js
parented17181e0660ce6452b9fbc4a8a6d1a807dca453 (diff)
set and clear currentDraft details via methods on FMS object to ensure consistency
Diffstat (limited to 'www/js')
-rw-r--r--www/js/app.js10
-rw-r--r--www/js/views/existing.js7
-rw-r--r--www/js/views/offline.js6
-rw-r--r--www/js/views/submit.js3
4 files changed, 16 insertions, 10 deletions
diff --git a/www/js/app.js b/www/js/app.js
index 2ce05e2..6e09047 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -97,6 +97,16 @@ var tpl = {
return p;
},
+ setCurrentDraft: function(draft) {
+ FMS.currentDraft = draft;
+ localStorage.currentDraftID = draft.id;
+ },
+
+ clearCurrentDraft: function() {
+ FMS.currentDraftID = new FMS.Draft();
+ localStorage.currentDraftID = null;
+ },
+
initialize: function () {
if ( this.initialized == 1 ) {
return this;
diff --git a/www/js/views/existing.js b/www/js/views/existing.js
index 95beee5..c9bf459 100644
--- a/www/js/views/existing.js
+++ b/www/js/views/existing.js
@@ -13,18 +13,17 @@
},
useReport: function() {
- localStorage.currentDraftID = FMS.currentDraft.id;
+ FMS.setCurrentDraft(this.model);
this.navigate('around');
},
saveReport: function() {
- localStorage.currentDraftID = null;
- FMS.currentDraft = new FMS.Draft();
+ FMS.clearCurrentDraft();
this.navigate('around');
},
discardReport: function() {
- var reset = FMS.removeDraft(FMS.currentDraft.id, true);
+ var reset = FMS.removeDraft(this.model.id, true);
var that = this;
reset.done( function() { that.onDraftRemove(); } );
},
diff --git a/www/js/views/offline.js b/www/js/views/offline.js
index 8f963f6..342ee1a 100644
--- a/www/js/views/offline.js
+++ b/www/js/views/offline.js
@@ -113,15 +113,13 @@
var that = this;
del.done( function() { that.draftDeleted(); } );
} else {
- localStorage.currentDraftID = null;
- localStorage.currentDraft = new FMS.Draft();
+ FMS.clearCurrentDraft();
this.navigate( this.next, 'left' );
}
},
draftDeleted: function() {
- localStorage.currentDraftID = null;
- localStorage.currentDraft = new FMS.Draft();
+ FMS.clearCurrentDraft();
this.navigate( this.next, 'left' );
},
diff --git a/www/js/views/submit.js b/www/js/views/submit.js
index 4878d7e..937eaa7 100644
--- a/www/js/views/submit.js
+++ b/www/js/views/submit.js
@@ -57,8 +57,7 @@
},
onRemoveDraft: function() {
- FMS.currentDraft = new FMS.Draft();
- localStorage.currentDraftID = null;
+ FMS.clearCurrentDraft();
FMS.createdReport = this.report;
this.navigate( 'sent', 'left' );
},