diff options
author | Struan Donald <struan@exo.org.uk> | 2013-04-02 11:01:07 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-04-02 11:01:07 +0100 |
commit | 9f979f491570c6bbff8735bcfa391430543d0041 (patch) | |
tree | c6773e651e6cdcc163ea25a8724b1004308bb7cc /www/js/models/report.js | |
parent | a6dd616d2e6d57e1a7d9ad629b2dfbfc77320bec (diff) |
save and load current report on app pause and resume
Diffstat (limited to 'www/js/models/report.js')
-rw-r--r-- | www/js/models/report.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/www/js/models/report.js b/www/js/models/report.js index 341574c..3215449 100644 --- a/www/js/models/report.js +++ b/www/js/models/report.js @@ -2,6 +2,7 @@ _.extend( FMS, { Report: Backbone.Model.extend({ urlRoot: CONFIG.FMS_URL + 'report/ajax', + localStorage: new Backbone.LocalStorage(CONFIG.NAMESPACE + '-reports'), defaults: { lat: 0, @@ -15,6 +16,14 @@ file: '' }, + localSave: function() { + var method = 'create'; + if ( this.id ) { + method = 'update'; + } + Backbone.localSync(method, this); + }, + sync: function(method, model, options) { switch (method) { case 'create': @@ -152,3 +161,12 @@ }) }); })(FMS, Backbone, _, $); + +(function(FMS, Backbone, _, $) { + _.extend( FMS, { + Reports: Backbone.Collection.extend({ + model: FMS.Report, + localStorage: new Backbone.LocalStorage(CONFIG.NAMESPACE + '-reports') + }) + }); +})(FMS, Backbone, _, $); |