aboutsummaryrefslogtreecommitdiffstats
path: root/www/js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-03-05 16:29:09 +0000
committerStruan Donald <struan@exo.org.uk>2013-03-05 16:29:09 +0000
commitc1d9a61bf69db7a48ba33c95cdc0b8fc00f1755c (patch)
tree76c2ee3e47d6f5437ca2af39cdadbddd5ac5f7a0 /www/js
parent697dd86603ccfd8d8df823044d6cfc56c39872b8 (diff)
save personal details when we submit, load them when we start and use
them in the submit form
Diffstat (limited to 'www/js')
-rw-r--r--www/js/app.js10
-rw-r--r--www/js/models/report.js6
-rw-r--r--www/js/views/submit.js5
3 files changed, 16 insertions, 5 deletions
diff --git a/www/js/app.js b/www/js/app.js
index 035c0ae..54fc8b9 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -42,6 +42,7 @@ var tpl = {
],
initialized: 0,
+ users: new FMS.Users(),
currentUser: null,
currentLocation: null,
@@ -59,6 +60,15 @@ var tpl = {
router: new FMS.appRouter()
});
+ // we only ever have the details of one user
+ FMS.users.fetch();
+ if ( FMS.users.length > 0 ) {
+ FMS.currentUser = FMS.users.get(1);
+ }
+ if ( !FMS.currentUser ) {
+ FMS.currentUser = new FMS.User({id: 1});
+ }
+
document.addEventListener('backbutton', function() { FMS.router.back(); }, true);
Backbone.history.start();
diff --git a/www/js/models/report.js b/www/js/models/report.js
index c9a5f0f..44d1aef 100644
--- a/www/js/models/report.js
+++ b/www/js/models/report.js
@@ -65,7 +65,7 @@
used_map: 1
};
- if ( FMS.currentUser ) {
+ if ( FMS.currentUser && FMS.currentUser.get('password') ) {
params.name = FMS.currentUser.get('name');
params.email = FMS.currentUser.get('email');
params.phone = FMS.currentUser.get('phone');
@@ -83,14 +83,12 @@
params.submit_register = 1;
}
- /*
- FMS.currentUser = new FMS.User( {
+ FMS.currentUser.set({
name: params.name,
email: params.email,
phone: params.phone,
password: params.password
});
- */
}
var that = this;
diff --git a/www/js/views/submit.js b/www/js/views/submit.js
index 1ce411e..e222ffe 100644
--- a/www/js/views/submit.js
+++ b/www/js/views/submit.js
@@ -27,7 +27,7 @@
}
template = _.template( tpl.get( this.template ) );
if ( this.model ) {
- this.$el.html(template({ model: this.model.toJSON(), user: FMS.currentUser }));
+ this.$el.html(template({ model: this.model.toJSON(), user: FMS.currentUser.toJSON() }));
} else {
this.$el.html(template());
}
@@ -42,6 +42,9 @@
},
onReportSync: function(model, resp, options) {
+ if ( FMS.currentUser ) {
+ FMS.currentUser.save();
+ }
this.navigate( 'sent', 'left' );
},