From 768fa13aefdb9f891f580c93ab19140cadb3cf50 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 28 Jun 2017 17:00:41 -0700 Subject: [PATCH] adding type ahead selector to survey for job tags and skip tags --- .../launchjob.factory.js | 16 +++++++++---- .../job-submission.controller.js | 8 +++++-- .../job-submission.directive.js | 12 ++++++++++ .../job-submission.partial.html | 23 +++++++++++++++++-- 4 files changed, 51 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js b/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js index 5bc55d1173..b05c6015f9 100644 --- a/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js +++ b/awx/ui/client/src/job-submission/job-submission-factories/launchjob.factory.js @@ -50,12 +50,20 @@ export default } - if(scope.ask_tags_on_launch && scope.other_prompt_data && typeof scope.other_prompt_data.job_tags === 'string'){ - job_launch_data.job_tags = scope.other_prompt_data.job_tags; + if(scope.ask_tags_on_launch && scope.other_prompt_data && Array.isArray(scope.other_prompt_data.job_tags)){ + scope.job_tags = _.map(scope.job_tags, function(i){return i.value;}); + $("#job_launch_job_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){ + scope.job_tags.push(option.title); + }); + job_launch_data.job_tags = (Array.isArray(scope.job_tags)) ? _.uniq(scope.job_tags).join() : ""; } - if(scope.ask_skip_tags_on_launch && scope.other_prompt_data && typeof scope.other_prompt_data.skip_tags === 'string'){ - job_launch_data.skip_tags = scope.other_prompt_data.skip_tags; + if(scope.ask_skip_tags_on_launch && scope.other_prompt_data && Array.isArray(scope.other_prompt_data.skip_tags)){ + scope.skip_tags = _.map(scope.skip_tags, function(i){return i.value;}); + $("#job_launch_skip_tags").siblings(".select2").first().find(".select2-selection__choice").each(function(optionIndex, option){ + scope.skip_tags.push(option.title); + }); + job_launch_data.skip_tags = (Array.isArray(scope.skip_tags)) ? _.uniq(scope.skip_tags).join() : ""; } if(scope.ask_limit_on_launch && scope.other_prompt_data && scope.other_prompt_data.limit){ diff --git a/awx/ui/client/src/job-submission/job-submission.controller.js b/awx/ui/client/src/job-submission/job-submission.controller.js index 5aa3dde0c4..d028b25b6b 100644 --- a/awx/ui/client/src/job-submission/job-submission.controller.js +++ b/awx/ui/client/src/job-submission/job-submission.controller.js @@ -219,11 +219,15 @@ export default } if($scope.ask_tags_on_launch) { - $scope.other_prompt_data.job_tags = (data.defaults && data.defaults.job_tags) ? data.defaults.job_tags : ""; + $scope.other_prompt_data.job_tags_options = (data.defaults && data.defaults.job_tags) ? data.defaults.job_tags.split(',') + .map((i) => ({name: i, label: i, value: i})) : []; + $scope.other_prompt_data.job_tags = $scope.other_prompt_data.job_tags_options; } if($scope.ask_skip_tags_on_launch) { - $scope.other_prompt_data.skip_tags = (data.defaults && data.defaults.skip_tags) ? data.defaults.skip_tags : ""; + $scope.other_prompt_data.skip_tags_options = (data.defaults && data.defaults.skip_tags) ? data.defaults.skip_tags.split(',') + .map((i) => ({name: i, label: i, value: i})) : []; + $scope.other_prompt_data.skip_tags = $scope.other_prompt_data.skip_tags_options; } if($scope.ask_variables_on_launch) { diff --git a/awx/ui/client/src/job-submission/job-submission.directive.js b/awx/ui/client/src/job-submission/job-submission.directive.js index 20ea2fd793..c0689056bd 100644 --- a/awx/ui/client/src/job-submission/job-submission.directive.js +++ b/awx/ui/client/src/job-submission/job-submission.directive.js @@ -61,6 +61,18 @@ export default [ 'templateUrl', 'CreateDialog', 'Wait', 'CreateSelect2', 'ParseT placeholder: i18n._('Select a credential') }); + CreateSelect2({ + element: '#job_launch_job_tags', + multiple: true, + addNew: true + }); + + CreateSelect2({ + element: '#job_launch_skip_tags', + multiple: true, + addNew: true + }); + if(scope.step === 'otherprompts' && scope.ask_variables_on_launch) { ParseTypeChange({ scope: scope, diff --git a/awx/ui/client/src/job-submission/job-submission.partial.html b/awx/ui/client/src/job-submission/job-submission.partial.html index 7932ab1ee9..3908228f5f 100644 --- a/awx/ui/client/src/job-submission/job-submission.partial.html +++ b/awx/ui/client/src/job-submission/job-submission.partial.html @@ -214,7 +214,16 @@ Job Tags
- +
@@ -222,7 +231,17 @@ Skip Tags
- + +