From a90de488e1bf291a3c10d03da713bced9b4f3a87 Mon Sep 17 00:00:00 2001 From: chris Houseknecht Date: Wed, 15 Jan 2014 23:10:36 -0500 Subject: [PATCH] AC-756 Removed required on password field when in 'edit' mode. When editing an existing user all fields can now be changed without re-entering a password. However, if the password field is touched, then a strong password is required and a valid match must be supplied. Fixed the Reset button. Now if changing existing record, touch password, click reset, and all password, password match, and the strength progress bar are all reset. --- awx/ui/static/js/controllers/Users.js | 1 + awx/ui/static/js/forms/Users.js | 3 ++- awx/ui/static/js/helpers/Users.js | 7 +++--- awx/ui/static/lib/ansible/form-generator.js | 28 ++++++++++++--------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/awx/ui/static/js/controllers/Users.js b/awx/ui/static/js/controllers/Users.js index 31f5e3ff3c..92308bf14b 100644 --- a/awx/ui/static/js/controllers/Users.js +++ b/awx/ui/static/js/controllers/Users.js @@ -308,6 +308,7 @@ function UsersEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, for (var fld in master) { scope[fld] = master[fld]; } + scope['password_confirm'] = scope['password']; }; // Password change diff --git a/awx/ui/static/js/forms/Users.js b/awx/ui/static/js/forms/Users.js index 85006ea0d6..0b014366b6 100644 --- a/awx/ui/static/js/forms/Users.js +++ b/awx/ui/static/js/forms/Users.js @@ -70,7 +70,8 @@ angular.module('UserFormDefinition', []) label: 'Password', type: 'password', ngShow: 'ldap_user == false', - awRequiredWhen: { variable: "not_ldap_user", init: true }, + addRequired: true, + editRequired: false, ngChange: "clearPWConfirm('password_confirm')", autocomplete: false, chkPass: true diff --git a/awx/ui/static/js/helpers/Users.js b/awx/ui/static/js/helpers/Users.js index 1513adc5ac..fc825bd651 100644 --- a/awx/ui/static/js/helpers/Users.js +++ b/awx/ui/static/js/helpers/Users.js @@ -22,8 +22,9 @@ angular.module('UserHelper', [ 'UserFormDefinition' ]) UserForm.fields['organization'].readonly = false; UserForm.fields['username'].awRequiredWhen = { variable: "not_ldap_user", init: true }; UserForm.fields['username'].readonly = false; - UserForm.fields['password'].awRequiredWhen = { variable: "not_ldap_user", init: true }, - UserForm.fields['password'].readonly = false; - + //UserForm.fields['password'].awRequiredWhen = { variable: "not_ldap_user", init: true }, + //UserForm.fields['password'].readonly = false; + UserForm.fields['password'].editRequired = false; + UserForm.fields['password'].addRrequired = true; } }]); \ No newline at end of file diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index b391cb7833..c7acd0817d 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -198,30 +198,34 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies', 'Utilities']) for (var fld in this.form.fields) { if (this.form.fields[fld].type == 'checkbox_group') { for (var i=0; i < this.form.fields[fld].fields.length; i++) { - this.scope[this.form.fields[fld].fields[i].name] = ''; - this.scope[this.form.fields[fld].fields[i].name + '_api_error'] = ''; + this.scope[this.form.fields[fld].fields[i].name] = ''; + this.scope[this.form.fields[fld].fields[i].name + '_api_error'] = ''; } } else { - this.scope[fld] = ''; - this.scope[fld + '_api_error'] = ''; + this.scope[fld] = ''; + this.scope[fld + '_api_error'] = ''; } if (this.form.fields[fld].sourceModel) { - this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] = ''; - this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '_api_error'] = ''; + this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] = ''; + this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '_api_error'] = ''; } if ( this.form.fields[fld].type == 'lookup' && this.scope[this.form.name + '_form'][this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] ) { - this.scope[this.form.name + '_form'][this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField].$setPristine(); + this.scope[this.form.name + '_form'][this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField].$setPristine(); } if (this.scope[this.form.name + '_form'][fld]) { - this.scope[this.form.name + '_form'][fld].$setPristine(); + this.scope[this.form.name + '_form'][fld].$setPristine(); + } + if (this.form.fields[fld].chkPass && this.scope[this.form.name + '_form'][fld]) { + this.scope[this.form.name + '_form'][fld].$setValidity('complexity', true); + $('#progbar').css({ width: 0 }); + } + if (this.form.fields[fld].awPassMatch && this.scope[this.form.name + '_form'][fld]) { + this.scope[this.form.name + '_form'][fld].$setValidity('awpassmatch', true); } - //if (this.scope.fields[fld].awPassMatch) { - // this.scope[this.form.name + '_form'][fld].$setValidity('awpassmatch', true); - //} if (this.form.fields[fld].ask) { - this.scope[fld + '_ask'] = false; + this.scope[fld + '_ask'] = false; } } if (this.mode == 'add') {