aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--www/js/views/submit.js41
2 files changed, 24 insertions, 18 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bb3b239..90b406d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@
- iPhone X support. #259
- Bugfixes
- Skip empty report details screen.
+ - Correctly set user title. #156
- Development improvements
- CONFIG.SKIP_CONFIRM_REPORT flag to skip confirmation screen
- Ensure compatibility with latest Cordova versions.
diff --git a/www/js/views/submit.js b/www/js/views/submit.js
index ec89928..4d38aa3 100644
--- a/www/js/views/submit.js
+++ b/www/js/views/submit.js
@@ -128,6 +128,22 @@
}
},
+ validateUserTitle: function() {
+ if ( this.model.get('titles_list') && this.model.get('titles_list').length > 0 ) {
+ if ( $('#form_title').val() === '' ) {
+ this.validationError('form_title', FMS.strings.required);
+ return false;
+ }
+ }
+ return true;
+ },
+
+ setUserTitle: function() {
+ if ( this.model.get('titles_list') && this.model.get('titles_list').length > 0 ) {
+ FMS.currentUser.set('title', $('#form_title').val());
+ }
+ },
+
beforeSubmit: function() {},
afterSubmit: function() {},
@@ -265,11 +281,8 @@
}
}
- if ( this.model.get('titles_list') && this.model.get('titles_list').length > 0 ) {
- if ( $('#form_title').val() === '' ) {
- this.validationError('form_title', FMS.strings.required);
- isValid = 0;
- }
+ if (!this.validateUserTitle()) {
+ isValid = 0;
}
return isValid;
@@ -283,10 +296,7 @@
this.model.set('may_show_name', $('#form_may_show_name').is(':checked'));
FMS.currentUser.set('name', $('#form_name').val());
FMS.currentUser.set('may_show_name', $('#form_may_show_name').is(':checked'));
-
- if ( this.model.get('titles_list') && this.model.get('titles_list').length > 0 ) {
- FMS.currentUser.set('title', $('#form_title').val());
- }
+ this.setUserTitle();
if ( FMS.currentUser ) {
FMS.currentUser.save();
@@ -337,13 +347,9 @@
this.validationError('form_password', FMS.validationStrings.password );
}
- if ( $('#form_name').val() && this.model.get('titles_list') && this.model.get('titles_list').length > 0 ) {
- if ( $('#form_title').val() === '' ) {
- this.validationError('form_title', FMS.strings.required);
- isValid = 0;
- }
+ if ($('#form_name').val() && !this.validateUserTitle()) {
+ isValid = 0;
}
-
return isValid;
},
@@ -358,9 +364,7 @@
this.model.set('may_show_name', $('#form_may_show_name').is(':checked'));
FMS.currentUser.set('name', $('#form_name').val());
FMS.currentUser.set('may_show_name', $('#form_may_show_name').is(':checked'));
- if ( this.model.get('titles_list') && this.model.get('titles_list').length > 0 ) {
- FMS.currentUser.set('title', $('#form_title').val());
- }
+ this.setUserTitle();
FMS.currentUser.save();
} else {
// if this is set then we are registering a password
@@ -463,6 +467,7 @@
this.model.set('submit_clicked', 'submit_register');
FMS.currentUser.set('name', $('#form_name').val());
FMS.currentUser.set('may_show_name', $('#form_may_show_name').is(':checked'));
+ this.setUserTitle();
},
onReportError: function(model, err, options) {