mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 20:00:43 -03:30
Merge pull request #2582 from mabashian/1558-settings-unsaved
Revert the auth/ldap dropdowns if saving unsaved changes is not successful
This commit is contained in:
commit
58dad97cf0
@ -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,
|
||||
|
||||
@ -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}}')">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -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}}')">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user