diff options
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, _, $); |