From 069c60abf7ff7a030d1ef39b29e267f1e7ddd7aa Mon Sep 17 00:00:00 2001 From: mabashian Date: Mon, 16 Jul 2018 15:37:12 -0400 Subject: [PATCH] Re-initialize tag options before calling to create select2 on those fields in prompt modal --- .../src/templates/prompt/prompt.service.js | 4 ++-- .../prompt-other-prompts.controller.js | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/templates/prompt/prompt.service.js b/awx/ui/client/src/templates/prompt/prompt.service.js index f29e3ca856..f3bbc57225 100644 --- a/awx/ui/client/src/templates/prompt/prompt.service.js +++ b/awx/ui/client/src/templates/prompt/prompt.service.js @@ -38,8 +38,8 @@ function PromptService (Empty, $filter) { prompts.jobType.choices = _.get(params, 'launchOptions.actions.POST.job_type.choices', []).map(c => ({label: c[1], value: c[0]})); prompts.jobType.value = _.has(params, 'currentValues.job_type') && params.currentValues.job_type ? _.find(prompts.jobType.choices, item => item.value === params.currentValues.job_type) : _.find(prompts.jobType.choices, item => item.value === params.launchConf.defaults.job_type); prompts.limit.value = _.has(params, 'currentValues.limit') && params.currentValues.limit ? params.currentValues.limit : (_.has(params, 'launchConf.defaults.limit') ? params.launchConf.defaults.limit : ""); - prompts.tags.options = prompts.tags.value = (jobTags && jobTags !== "") ? jobTags.split(',').map((i) => ({name: i, label: i, value: i})) : []; - prompts.skipTags.options = prompts.skipTags.value = (skipTags && skipTags !== "") ? skipTags.split(',').map((i) => ({name: i, label: i, value: i})) : []; + prompts.tags.value = (jobTags && jobTags !== "") ? jobTags.split(',').map((i) => ({name: i, label: i, value: i})) : []; + prompts.skipTags.value = (skipTags && skipTags !== "") ? skipTags.split(',').map((i) => ({name: i, label: i, value: i})) : []; prompts.diffMode.value = _.has(params, 'currentValues.diff_mode') && typeof params.currentValues.diff_mode === 'boolean' ? params.currentValues.diff_mode : (_.has(params, 'launchConf.defaults.diff_mode') ? params.launchConf.defaults.diff_mode : null); return prompts; diff --git a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js index 71af177f87..1003ff0ec1 100644 --- a/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js +++ b/awx/ui/client/src/templates/prompt/steps/other-prompts/prompt-other-prompts.controller.js @@ -55,6 +55,16 @@ export default } if(scope.promptData.launchConf.ask_tags_on_launch) { + // Ensure that the options match the currently selected tags. These two things + // might get out of sync if the user re-opens the prompts before saving the + // schedule/wf node + scope.promptData.prompts.tags.options = _.map(scope.promptData.prompts.tags.value, function(tag){ + return { + value: tag.value, + name: tag.name, + label: tag.label + }; + }); CreateSelect2({ element: '#job_launch_job_tags', multiple: true, @@ -63,6 +73,16 @@ export default } if(scope.promptData.launchConf.ask_skip_tags_on_launch) { + // Ensure that the options match the currently selected tags. These two things + // might get out of sync if the user re-opens the prompts before saving the + // schedule/wf node + scope.promptData.prompts.skipTags.options = _.map(scope.promptData.prompts.skipTags.value, function(tag){ + return { + value: tag.value, + name: tag.name, + label: tag.label + }; + }); CreateSelect2({ element: '#job_launch_skip_tags', multiple: true,