diff options
Diffstat (limited to 'www')
-rw-r--r-- | www/index.html | 2 | ||||
-rw-r--r-- | www/js/app.js | 10 | ||||
-rw-r--r-- | www/js/models/report.js | 6 | ||||
-rw-r--r-- | www/js/views/submit.js | 5 | ||||
-rw-r--r-- | www/templates/en/submit.html | 14 |
5 files changed, 25 insertions, 12 deletions
diff --git a/www/index.html b/www/index.html index a9b0f08..d7bab77 100644 --- a/www/index.html +++ b/www/index.html @@ -23,6 +23,7 @@ <script type="text/javascript" src="jslib/lodash.min.js"></script> <script type="text/javascript" src="jslib/backbone-min.js"></script> + <script type="text/javascript" src="jslib/backbone.localStorage-min.js"></script> <script type="text/javascript" src="jslib/json2.js"></script> <script type="text/javascript" src="jslib/jquery.validate.min.js"></script> @@ -43,6 +44,7 @@ <script type="text/javascript" src="js/views/sent.js"></script> <script type="text/javascript" src="js/models/report.js"></script> + <script type="text/javascript" src="js/models/user.js"></script> <script type="text/javascript" src="js/router.js"></script> <script type="text/javascript" src="js/app.js"></script> 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' ); }, diff --git a/www/templates/en/submit.html b/www/templates/en/submit.html index 986617a..a36d1e2 100644 --- a/www/templates/en/submit.html +++ b/www/templates/en/submit.html @@ -8,16 +8,16 @@ <fieldset> <div id="problem_form"> - <% if ( user ) { %> + <% if ( user && user.password ) { %> <div id="signed_in"> <p> - You are signed in as <span id="username"></span> + You are signed in as <span id="username"><%= user.name %></span> </p> <p id="confirm_details">Confirm details</p> <div id="name_details"> <label for="form_may_show_name">Name</label> - <input type="text" class="validName" value="" name="name" id="form_name" placeholder="Your name"> + <input type="text" class="validName" value="<%= user.name %>" name="name" id="form_name" placeholder="Your name"> <div class="checkbox-group"> <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1" checked> @@ -25,7 +25,7 @@ </div> <label for="form_phone">Phone number</label> - <input type="text" value="" name="phone" id="form_phone" placeholder="Your phone number (optional)"> + <input type="text" value="<%= user.phone %>" name="phone" id="form_phone" placeholder="Your phone number (optional)"> </div> <div class="form-txt-submit-box"> @@ -35,7 +35,7 @@ <% } else { %> <div id="signed_out"> <label for="form_email" id="email_label">Your email</label> - <input type="email" value="" name="email" id="form_email" placeholder="Please enter your email address" required> + <input type="email" value="<%= user.email %>" name="email" id="form_email" placeholder="Please enter your email address" required> <div id="form_sign_in"> <h4 id="have_password">Do you have a FixMyStreet password?</h4> @@ -56,7 +56,7 @@ <div id="name_details"> <label for="form_may_show_name">Name</label> - <input type="text" class="validName" value="" name="name" id="form_name" placeholder="Your name"> + <input type="text" class="validName" value="<%= user.name %>" name="name" id="form_name" placeholder="Your name"> <div class="checkbox-group"> <input type="checkbox" name="may_show_name" id="form_may_show_name" value="1" checked> @@ -64,7 +64,7 @@ </div> <label for="form_phone">Phone number</label> - <input type="text" value="" name="phone" id="form_phone" placeholder="Your phone number (optional)"> + <input type="text" value="<%= user.phone %>" name="phone" id="form_phone" placeholder="Your phone number (optional)"> </div> <div id="password_surround"> |