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 ec50d2a3b3..fe85f071ea 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 @@ -227,16 +227,15 @@ export default [ // Flag to avoid re-rendering and breaking Select2 dropdowns on tab switching var dropdownRendered = false; - $scope.$on('populated', function() { - startCodeMirrors(); - // Create Select2 fields - var opts = []; + + function populateLDAPGroupType(flag){ if($scope.$parent.AUTH_LDAP_GROUP_TYPE !== null) { - opts.push({ - id: $scope.$parent.AUTH_LDAP_GROUP_TYPE, - text: $scope.$parent.AUTH_LDAP_GROUP_TYPE - }); + $scope.$parent.AUTH_LDAP_GROUP_TYPE = _.find($scope.$parent.AUTH_LDAP_GROUP_TYPE_options, { value: $scope.$parent.AUTH_LDAP_GROUP_TYPE }); + } + + if(flag !== undefined){ + dropdownRendered = flag; } if(!dropdownRendered) { @@ -245,15 +244,17 @@ export default [ element: '#configuration_ldap_template_AUTH_LDAP_GROUP_TYPE', multiple: false, placeholder: i18n._('Select group types'), - opts: opts }); - // Fix for bug where adding selected opts causes form to be $dirty and triggering modal - // TODO Find better solution for this bug - $timeout(function(){ - $scope.$parent.configuration_ldap_template_form.$setPristine(); - }, 1000); } + } + $scope.$on('AUTH_LDAP_GROUP_TYPE_populated', function(e, data, flag) { + populateLDAPGroupType(flag); + }); + + $scope.$on('populated', function() { + startCodeMirrors(); + populateLDAPGroupType(); }); angular.extend(authVm, { diff --git a/awx/ui/client/src/configuration/configuration.controller.js b/awx/ui/client/src/configuration/configuration.controller.js index 78b9b228d3..8a3c110838 100644 --- a/awx/ui/client/src/configuration/configuration.controller.js +++ b/awx/ui/client/src/configuration/configuration.controller.js @@ -295,9 +295,11 @@ export default [ ConfigurationService.patchConfiguration(payload) .then(function() { $scope[key] = $scope.configDataResolve[key].default; - if(key === "AD_HOC_COMMANDS"){ - $scope.AD_HOC_COMMANDS = $scope.AD_HOC_COMMANDS.toString(); - $scope.$broadcast('adhoc_populated', null, false); + if($scope[key + '_field'].type === "select"){ + // We need to re-instantiate the Select2 element + // after resetting the value. Example: + // `$scope.$broadcast(AD_HOC_COMMANDS_populated)` + $scope.$broadcast(key+'_populated', null, false); } loginUpdate(); }) diff --git a/awx/ui/client/src/configuration/jobs-form/configuration-jobs.controller.js b/awx/ui/client/src/configuration/jobs-form/configuration-jobs.controller.js index 89bf46d458..6a177ae0c1 100644 --- a/awx/ui/client/src/configuration/jobs-form/configuration-jobs.controller.js +++ b/awx/ui/client/src/configuration/jobs-form/configuration-jobs.controller.js @@ -77,6 +77,7 @@ export default [ function populateAdhocCommand(flag){ + $scope.$parent.AD_HOC_COMMANDS = $scope.$parent.AD_HOC_COMMANDS.toString(); var ad_hoc_commands = $scope.$parent.AD_HOC_COMMANDS.split(','); $scope.$parent.AD_HOC_COMMANDS = _.map(ad_hoc_commands, (item) => _.find($scope.$parent.AD_HOC_COMMANDS_options, { value: item })); @@ -94,7 +95,7 @@ export default [ } } - $scope.$on('adhoc_populated', function(e, data, flag) { + $scope.$on('AD_HOC_COMMANDS_populated', function(e, data, flag) { populateAdhocCommand(flag); }); diff --git a/awx/ui/client/src/configuration/system-form/configuration-system.controller.js b/awx/ui/client/src/configuration/system-form/configuration-system.controller.js index c227e0dc92..10ac4b74ef 100644 --- a/awx/ui/client/src/configuration/system-form/configuration-system.controller.js +++ b/awx/ui/client/src/configuration/system-form/configuration-system.controller.js @@ -152,16 +152,21 @@ export default [ var dropdownRendered = false; - $scope.$on('populated', function() { + $scope.$on('populated', function(e, data, flag) { + populateLogAggregator(flag); + }); - var opts = []; + $scope.$on('LOG_AGGREGATOR_TYPE_populated', function(e, data, flag) { + populateLogAggregator(flag); + }); + + function populateLogAggregator(flag){ if($scope.$parent.LOG_AGGREGATOR_TYPE !== null) { - _.each(ConfigurationUtils.listToArray($scope.$parent.LOG_AGGREGATOR_TYPE), function(type) { - opts.push({ - id: type, - text: type - }); - }); + $scope.$parent.LOG_AGGREGATOR_TYPE = _.find($scope.$parent.LOG_AGGREGATOR_TYPE_options, { value: $scope.$parent.LOG_AGGREGATOR_TYPE }); + } + + if(flag !== undefined){ + dropdownRendered = flag; } if(!dropdownRendered) { @@ -170,11 +175,10 @@ export default [ element: '#configuration_logging_template_LOG_AGGREGATOR_TYPE', multiple: false, placeholder: i18n._('Select types'), - opts: opts }); + $scope.$parent.configuration_logging_template_form.LOG_AGGREGATOR_TYPE.$setPristine(); } - - }); + } // Fix for bug where adding selected opts causes form to be $dirty and triggering modal // TODO Find better solution for this bug diff --git a/awx/ui/client/src/configuration/ui-form/configuration-ui.controller.js b/awx/ui/client/src/configuration/ui-form/configuration-ui.controller.js index cea17ca4f0..43cf4d6c98 100644 --- a/awx/ui/client/src/configuration/ui-form/configuration-ui.controller.js +++ b/awx/ui/client/src/configuration/ui-form/configuration-ui.controller.js @@ -78,24 +78,48 @@ // Flag to avoid re-rendering and breaking Select2 dropdowns on tab switching var dropdownRendered = false; - $scope.$on('populated', function(){ + function populatePendoTrackingState(flag){ + if($scope.$parent.PENDO_TRACKING_STATE !== null) { + $scope.$parent.PENDO_TRACKING_STATE = _.find($scope.$parent.PENDO_TRACKING_STATE_options, { value: $scope.$parent.PENDO_TRACKING_STATE }); + } + + if(flag !== undefined){ + dropdownRendered = flag; + } + if(!dropdownRendered) { dropdownRendered = true; CreateSelect2({ element: '#configuration_ui_template_PENDO_TRACKING_STATE', multiple: false, - placeholder: i18n._('Select commands'), - opts: [{ - id: $scope.$parent.PENDO_TRACKING_STATE, - text: $scope.$parent.PENDO_TRACKING_STATE - }] + placeholder: i18n._('Select commands') }); - // Fix for bug where adding selected opts causes form to be $dirty and triggering modal - // TODO Find better solution for this bug - $timeout(function(){ - $scope.$parent.configuration_ui_template_form.$setPristine(); - }, 1000); } + } + + $scope.$on('PENDO_TRACKING_STATE_populated', function(e, data, flag) { + populatePendoTrackingState(flag); + }); + + $scope.$on('populated', function(e, data, flag){ + populatePendoTrackingState(flag); + // if(!dropdownRendered) { + // dropdownRendered = true; + // CreateSelect2({ + // element: '#configuration_ui_template_PENDO_TRACKING_STATE', + // multiple: false, + // placeholder: i18n._('Select commands'), + // opts: [{ + // id: $scope.$parent.PENDO_TRACKING_STATE, + // text: $scope.$parent.PENDO_TRACKING_STATE + // }] + // }); + // // Fix for bug where adding selected opts causes form to be $dirty and triggering modal + // // TODO Find better solution for this bug + // $timeout(function(){ + // $scope.$parent.configuration_ui_template_form.$setPristine(); + // }, 1000); + // } }); angular.extend(uiVm, {