diff options
-rw-r--r-- | www/css/fms.css | 15 | ||||
-rw-r--r-- | www/js/models/report.js | 4 | ||||
-rw-r--r-- | www/js/views/submit.js | 14 | ||||
-rw-r--r-- | www/templates/en/submit_confirm.html | 2 | ||||
-rw-r--r-- | www/templates/en/submit_name.html | 1 | ||||
-rw-r--r-- | www/templates/en/submit_password.html | 1 |
6 files changed, 35 insertions, 2 deletions
diff --git a/www/css/fms.css b/www/css/fms.css index b0b3eee..bc2c4be 100644 --- a/www/css/fms.css +++ b/www/css/fms.css @@ -360,6 +360,21 @@ #details-page { background: white !important; } + + #errors { + display: none; + } + + #errors ul { + padding: 0px 0px 0px 20px; + } + + #errors li.plain { + font-weight: bold; + margin-left: -20px; + list-style: none; + } + .ui-loader { height: 100%; width: 100%; diff --git a/www/js/models/report.js b/www/js/models/report.js index 2508b3f..88e9dfd 100644 --- a/www/js/models/report.js +++ b/www/js/models/report.js @@ -93,7 +93,7 @@ if ( data.success ) { that.trigger('sync', that, data, options); } else { - that.trigger('error', that, data, options); + that.trigger('invalid', that, data, options); } } else { that.trigger('error', that, FMS.strings.report_send_error, options); @@ -128,7 +128,7 @@ if ( data.success ) { that.trigger('sync', that, data, options); } else { - that.trigger('error', that, data, options); + that.trigger('invalid', that, data, options); } }, error: function (data, status, errorThrown ) { 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); }, diff --git a/www/templates/en/submit_confirm.html b/www/templates/en/submit_confirm.html index 255b21c..ca87e78 100644 --- a/www/templates/en/submit_confirm.html +++ b/www/templates/en/submit_confirm.html @@ -11,6 +11,8 @@ Please confirm your name, if you want it to be public and optionally your phone number. </p> + <div id="errors"></div> + <div class="inputcard"> <div> <input data-role="none" type="text" value="<%= user.name %>" name="name" id="form_name" placeholder="Please enter your name" required> diff --git a/www/templates/en/submit_name.html b/www/templates/en/submit_name.html index 5b87c62..a5d80e9 100644 --- a/www/templates/en/submit_name.html +++ b/www/templates/en/submit_name.html @@ -3,6 +3,7 @@ </div> <div data-role="content"> + <div id="errors"></div> <div class="inputcard"> <div> <input data-role="none" type="text" value="<%= user.name %>" name="name" id="form_name" placeholder="Please enter your name" required> diff --git a/www/templates/en/submit_password.html b/www/templates/en/submit_password.html index 045885f..1624c70 100644 --- a/www/templates/en/submit_password.html +++ b/www/templates/en/submit_password.html @@ -3,6 +3,7 @@ </div> <div data-role="content"> + <div id="errors"></div> <form id="passwordForm" name="passwordForm"> <div id="password_row"> <div class="inputcard"> |