aboutsummaryrefslogtreecommitdiffstats
path: root/www/js/views/submit.js
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2013-03-04 13:21:40 +0000
committerStruan Donald <struan@exo.org.uk>2013-03-04 13:44:42 +0000
commit8e9607bd3969283bb251444a206d36b53a9d6b03 (patch)
tree124d9f6a62e9f269cd3b02757bad8cfc7715a09b /www/js/views/submit.js
parent8c8a82a7ba1c5edec48c2f98b351c7b4e15fc89e (diff)
submit page can now submit reports to be confirmed by email
Diffstat (limited to 'www/js/views/submit.js')
-rw-r--r--www/js/views/submit.js44
1 files changed, 43 insertions, 1 deletions
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, _, $);