diff options
author | Struan Donald <struan@exo.org.uk> | 2013-07-26 16:33:25 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-07-26 16:33:25 +0100 |
commit | 2dfbaf0dfb44c630f2508336c78043515c1c30dd (patch) | |
tree | 199cfaf7d45f757a16f42ac04ecaa5f2fca7a5e3 /src/js/views/submit.js | |
parent | 2fdaad76631a256ec79841807ac4368ebe6ad83c (diff) |
Provide options if report submission fails
Rather that just please retry offer user ability to either save the
report for later or to try again.
Diffstat (limited to 'src/js/views/submit.js')
-rw-r--r-- | src/js/views/submit.js | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/js/views/submit.js b/src/js/views/submit.js index 2d122d9..3e11dd6 100644 --- a/src/js/views/submit.js +++ b/src/js/views/submit.js @@ -35,6 +35,10 @@ onClickSubmit: function(e) { // in case we are getting here from a form submission e.preventDefault(); + this.doSubmit(); + }, + + doSubmit: function() { this.beforeSubmit(); if ( this.validate() ) { @@ -99,10 +103,25 @@ }, onReportError: function(model, err, options) { + var msg = FMS.strings.unknown_sync_error; if ( err.errors ) { - this.displayAlert(FMS.strings.sync_error + ': ' + err.errors); - } else { - this.displayAlert(FMS.strings.unknown_sync_error); + msg = msg + ': ' + err.errors; + } + var that = this; + navigator.notification.confirm( + msg, + function(index) { that.handleReportError(index); }, + CONFIG.APP_NAME, + 'Save for Later,Try Again'); + }, + + handleReportError: function(index) { + if ( index === 1 ) { + this.stopListening(); + FMS.clearCurrentDraft(); + this.navigate('reports'); + } else if ( index === 2 ) { + this.doSubmit(); } }, |