diff options
author | Struan Donald <struan@exo.org.uk> | 2013-07-17 12:20:29 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2013-07-17 12:21:13 +0100 |
commit | 03c8d247f08c1068aadd5e9cac8f58d0b8d342fa (patch) | |
tree | d49ecff1fd516e2201fc177030169d97061ad821 /src | |
parent | 636cc1ee36a72b33f992f7e5712c1ba026af849e (diff) |
Change invalid report handling to allow subclass to override it.
Fix submit password screen to use this. Fixes #42
Diffstat (limited to 'src')
-rw-r--r-- | src/js/views/submit.js | 39 | ||||
-rw-r--r-- | src/templates/en/submit_password.html | 4 |
2 files changed, 25 insertions, 18 deletions
diff --git a/src/js/views/submit.js b/src/js/views/submit.js index 5ba6e83..9be6c68 100644 --- a/src/js/views/submit.js +++ b/src/js/views/submit.js @@ -76,21 +76,23 @@ }, onReportInvalid: function(model, err, options) { - var errors = err.errors; - var errorList = '<ul><li class="plain">' + FMS.strings.invalid_report + '</li>'; - var validErrors = [ 'password', 'category', 'name' ]; - for ( var k in errors ) { - if ( validErrors.indexOf(k) >= 0 || errors[k].match(/required/) ) { - if ( k === 'password' ) { - error = FMS.strings.password_problem; - } else if ( k !== '') { - error = errors[k]; + if ( !this._handleInvalid( model, err, options ) ) { + var errors = err.errors; + var errorList = '<ul><li class="plain">' + FMS.strings.invalid_report + '</li>'; + var validErrors = [ 'password', 'category', 'name' ]; + for ( var k in errors ) { + if ( validErrors.indexOf(k) >= 0 || errors[k].match(/required/) ) { + if ( k === 'password' ) { + error = FMS.strings.password_problem; + } else if ( k !== '') { + error = errors[k]; + } + errorList += '<li>' + error + '</li>'; } - errorList += '<li>' + error + '</li>'; } + errorList += '</ul>'; + $('#errors').html(errorList).show(); } - errorList += '</ul>'; - $('#errors').html(errorList).show(); }, onReportError: function(model, err, options) { @@ -104,6 +106,10 @@ beforeSubmit: function() {}, afterSubmit: function() {}, + _handleInvalid: function() { + return false; + }, + _destroy: function() { this.stopListening(); } @@ -300,18 +306,15 @@ FMS.isLoggedIn = 1; }, - onReportError: function(model, err, options) { + _handleInvalid: function(model, err, options) { if ( err.check_name ) { $('#form_name').val(err.check_name); $('#password_row').hide(); $('#check_name').show(); $('#confirm_name').focus(); - } else { - if ( err.errors && err.errors.password ) { - this.validationError('form_password', err.errors.password ); - } - $('#report').focus(); + return true; } + return false; } }) diff --git a/src/templates/en/submit_password.html b/src/templates/en/submit_password.html index 07fb8ac..efc64c5 100644 --- a/src/templates/en/submit_password.html +++ b/src/templates/en/submit_password.html @@ -17,6 +17,10 @@ </div> <div id="check_name" class="nodisplay"> <div class="inputcard"> + <p> + Please confirm your name, if you want it to be public and optionally your phone number. + </p> + <div> <input data-role="none" type="text" value="" id="form_name" name="name"> </div> |