From bcd57b18c20b1f47e504d4e12f21f889c631aded Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Tue, 21 Apr 2015 13:31:08 -0400 Subject: [PATCH] migrated job type select to using api options as well --- awx/ui/static/js/controllers/JobTemplates.js | 49 ++++++++++++-------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index efe76aa1ac..5ea22e9998 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -272,13 +272,7 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $ }; $scope.mode = "add"; $scope.parseType = 'yaml'; - ParseTypeChange({ scope: $scope, field_id: 'job_templates_variables', onChange: callback }); - - $scope.job_type_options = [ - { value: 'run', label: 'Run' }, - { value: 'check', label: 'Check' }, - { value: 'scan' , label: 'Scan'} - ]; + ParseTypeChange({ scope: $scope, field_id: 'job_templates_variables', onChange: callback }) $scope.playbook_options = []; $scope.allow_callbacks = 'false'; @@ -341,16 +335,22 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $ }); }); + var selectCount = 0; + if ($scope.removeChoicesReady) { $scope.removeChoicesReady(); } $scope.removeChoicesReady = $scope.$on('choicesReadyVerbosity', function () { - // this sets the default option as specified by the controller. - $scope.verbosity = $scope.verbosity_options[$scope.verbosity_field.default]; - $scope.$emit('lookUpInitialize'); + selectCount++; + if (selectCount === 2) { + // this sets the default options for the selects as specified by the controller. + $scope.verbosity = $scope.verbosity_options[$scope.verbosity_field.default]; + $scope.job_type = $scope.job_type_options[$scope.job_type_field.default]; + $scope.$emit('lookUpInitialize'); + } }); - // setup verbosity options lookup + // setup verbosity options select GetChoices({ scope: $scope, url: defaultUrl, @@ -359,6 +359,15 @@ export function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $ callback: 'choicesReadyVerbosity' }); + // setup job type options select + GetChoices({ + scope: $scope, + url: defaultUrl, + field: 'job_type', + variable: 'job_type_options', + callback: 'choicesReadyVerbosity' + }); + // Update playbook select whenever project value changes selectPlaybook = function (oldValue, newValue) { var url; @@ -668,13 +677,6 @@ export function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $scope.parseType = 'yaml'; $scope.showJobType = false; - // Our job type options - $scope.job_type_options = [ - { value: 'run', label: 'Run' }, - { value: 'check', label: 'Check' }, - { value: 'scan', label: 'Scan'} - ]; - SurveyControllerInit({ scope: $scope, parent_scope: $scope, @@ -972,7 +974,7 @@ export function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, } $scope.removeChoicesReady = $scope.$on('choicesReady', function() { choicesCount++; - if (choicesCount === 3) { + if (choicesCount === 4) { $scope.$emit('LoadJobs'); } }); @@ -1002,6 +1004,15 @@ export function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, callback: 'choicesReady' }); + // setup job type options lookup + GetChoices({ + scope: $scope, + url: defaultUrl, + field: 'job_type', + variable: 'job_type_options', + callback: 'choicesReady' + }); + function saveCompleted() { setTimeout(function() { $scope.$apply(function() {