diff options
author | Struan Donald <struan@exo.org.uk> | 2013-06-12 13:34:19 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-06-12 18:47:53 +0100 |
commit | b513e82c1e6fa9624d17fdfdc2809a5f6d53a1eb (patch) | |
tree | e9f25a7d9046770656bb334749a934636f202e3e /www/js/views/submit.js | |
parent | 4abf38cb9a70b5de01f36293f471ee41ab25313e (diff) |
if the server rejects the report as invalid then display some errors
Diffstat (limited to 'www/js/views/submit.js')
-rw-r--r-- | www/js/views/submit.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/www/js/views/submit.js b/www/js/views/submit.js index 3e1ef8e..654fb01 100644 --- a/www/js/views/submit.js +++ b/www/js/views/submit.js @@ -43,6 +43,7 @@ } else { this.report = new FMS.Report( this.model.toJSON() ); this.listenTo( this.report, 'sync', this.onReportSync ); + this.listenTo( this.report, 'invalid', this.onReportInvalid ); this.listenTo( this.report, 'error', this.onReportError ); this.report.save(); } @@ -73,6 +74,19 @@ this.navigate( 'sent' ); }, + onReportInvalid: function(model, err, options) { + var errors = err.errors; + var errorList = '<ul><li class="plain">Invalid report</li>'; + for ( var k in errors ) { + // FIXME! to stop jslint complaining for now + if ( k !== '' ) { + errorList += '<li>' + errors[k] + '</li>'; + } + } + errorList += '</ul>'; + $('#errors').html(errorList).show(); + }, + onReportError: function(model, err, options) { alert( FMS.strings.sync_error + ': ' + err.errors); }, |