diff --git a/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js b/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js index 75235a3984..e25fa46af8 100644 --- a/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js +++ b/awx/ui/client/src/configuration/auth-form/configuration-auth.controller.js @@ -81,7 +81,8 @@ export default [ return authVm.dropdownValue; }; - var activeForm = function() { + + const activeForm = function(revertDropdown) { if(!_.get($scope.$parent, [formTracker.currentFormName(), '$dirty'])) { authVm.activeAuthForm = getActiveAuthForm(); formTracker.setCurrentAuth(authVm.activeAuthForm); @@ -113,6 +114,9 @@ export default [ }).catch(() => { event.preventDefault(); $('#FormModal-dialog').dialog('close'); + if (revertDropdown) { + revertDropdown(); + } }); }, "class": "btn btn-primary", @@ -124,6 +128,26 @@ export default [ authVm.ldapSelected = (authVm.activeAuthForm.indexOf('ldap') !== -1); }; + const changeAuthDropdown = (previousVal) => { + activeForm(() => { + authVm.dropdownValue = previousVal; + CreateSelect2({ + element: '#configure-dropdown-nav', + multiple: false, + }); + }); + }; + + const changeLdapDropdown = (previousVal) => { + activeForm(() => { + authVm.ldapDropdownValue = previousVal; + CreateSelect2({ + element: '#configure-ldap-dropdown', + multiple: false, + }); + }); + }; + var dropdownOptions = [ {label: i18n._('Azure AD'), value: 'azure'}, {label: i18n._('GitHub'), value: 'github'}, @@ -412,7 +436,8 @@ export default [ angular.extend(authVm, { - activeForm: activeForm, + changeAuthDropdown: changeAuthDropdown, + changeLdapDropdown: changeLdapDropdown, activeAuthForm: activeAuthForm, authForms: authForms, dropdownOptions: dropdownOptions, diff --git a/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html b/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html index 2bfa19b401..dcbf4e258e 100644 --- a/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html +++ b/awx/ui/client/src/configuration/auth-form/configuration-auth.partial.html @@ -8,7 +8,7 @@ class="form-control" ng-model="authVm.dropdownValue" ng-options="opt.value as opt.label for opt in authVm.dropdownOptions" - ng-change="authVm.activeForm()"> + ng-change="authVm.changeAuthDropdown('{{authVm.dropdownValue}}')"> @@ -21,7 +21,7 @@ class="form-control" ng-model="authVm.ldapDropdownValue" ng-options="opt.value as opt.label for opt in authVm.ldapDropdownOptions" - ng-change="authVm.activeForm()"> + ng-change="authVm.changeLdapDropdown('{{authVm.ldapDropdownValue}}')">