diff options
author | Struan Donald <struan@exo.org.uk> | 2013-03-04 13:21:40 +0000 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-03-04 13:44:42 +0000 |
commit | 8e9607bd3969283bb251444a206d36b53a9d6b03 (patch) | |
tree | 124d9f6a62e9f269cd3b02757bad8cfc7715a09b /www/js | |
parent | 8c8a82a7ba1c5edec48c2f98b351c7b4e15fc89e (diff) |
submit page can now submit reports to be confirmed by email
Diffstat (limited to 'www/js')
-rw-r--r-- | www/js/models/report.js | 19 | ||||
-rw-r--r-- | www/js/views/submit.js | 44 |
2 files changed, 59 insertions, 4 deletions
diff --git a/www/js/models/report.js b/www/js/models/report.js index 26d91ad..539832b 100644 --- a/www/js/models/report.js +++ b/www/js/models/report.js @@ -71,18 +71,31 @@ params.name = FMS.currentUser.get('name'); params.email = FMS.currentUser.get('email'); params.phone = FMS.currentUser.get('phone'); + params.password_sign_in = FMS.currentUser.get('password'); + params.submit_sign_in = 1; } else { params.name = $('#form_name').val(); params.email = $('#form_email').val(); params.phone = $('#form_phone').val(); + params.password_sign_in = $('#password_sign_in').val(); + if ( this.submit_clicked == 'submit_sign_in' ) { + params.submit_sign_in = 1; + } else { + params.submit_register = 1; + } + + /* FMS.currentUser = new FMS.User( { name: params.name, email: params.email, - phone: params.phone + phone: params.phone, + password: params.password }); + */ } + var that = this; if ( model.get('file') && model.get('file') !== '' ) { var handlers = options; var fileUploadSuccess = function(r) { @@ -127,9 +140,9 @@ timeout: 30000, success: function(data) { if ( data.success ) { - options.success( data ); + that.trigger('sync', that, data, options); } else { - options.error( data ); + that.trigger('error', that, data, options); } }, error: function (data, status, errorThrown ) { diff --git a/www/js/views/submit.js b/www/js/views/submit.js index 3a04621..7d8644d 100644 --- a/www/js/views/submit.js +++ b/www/js/views/submit.js @@ -3,7 +3,49 @@ SubmitView: FMS.FMSView.extend({ template: 'submit', id: 'submit-page', - prev: 'details' + prev: 'details', + + events: { + 'pagehide': 'destroy', + 'pageshow': 'afterDisplay', + 'click .ui-btn-left': 'onClickButtonPrev', + 'click .ui-btn-right': 'onClickButtonNext', + 'click #submit_signed_in': 'onClickSubmit', + 'click #submit_sign_in': 'onClickSubmit', + 'click #submit_register': 'onClickSubmit' + }, + + render: function(){ + if ( !this.template ) { + console.log('no template to render'); + return; + } + template = _.template( tpl.get( this.template ) ); + if ( this.model ) { + this.$el.html(template({ model: this.model.toJSON(), user: FMS.currentUser })); + } else { + this.$el.html(template()); + } + this.afterRender(); + return this; + }, + + onClickSubmit: function(e) { + this.model.set( 'submit_clicked', $(e.target).attr('id') ); + + this.model.on('sync', this.onReportSync, this ); + this.model.on('error', this.onReportError, this ); + + this.model.save(); + }, + + onReportSync: function(model, resp, options) { + this.navigate( 'sent', 'left' ); + }, + + onReportError: function(model, err, options) { + alert( FMS.strings.sync_error + ': ' + err.errors); + } }) }); })(FMS, Backbone, _, $); |