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:
Michael Abashian 2018-07-19 16:16:33 -04:00 committed by GitHub
commit 58dad97cf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View File

@ -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,

View File

@ -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>