mirror of
https://github.com/ansible/awx.git
synced 2026-01-21 22:48:02 -03:30
Merge pull request #3906 from jakemcdermott/fix-5110
Fix job / skip tags not getting used on launch prompt
This commit is contained in:
commit
1869b73826
@ -233,6 +233,38 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f
|
||||
}, true);
|
||||
};
|
||||
|
||||
function getSelectedTags(tagId) {
|
||||
const selectedTags = [];
|
||||
const choiceElements = $(tagId).siblings(".select2").first()
|
||||
.find(".select2-selection__choice");
|
||||
choiceElements.each((index, option) => {
|
||||
selectedTags.push({
|
||||
value: option.title,
|
||||
name: option.title,
|
||||
label: option.title
|
||||
});
|
||||
});
|
||||
return selectedTags;
|
||||
}
|
||||
|
||||
function consolidateTags (tags, otherTags) {
|
||||
const seen = [];
|
||||
const consolidated = [];
|
||||
tags.forEach(tag => {
|
||||
if (!seen.includes(tag.value)) {
|
||||
seen.push(tag.value);
|
||||
consolidated.push(tag);
|
||||
}
|
||||
});
|
||||
otherTags.forEach(tag => {
|
||||
if (!seen.includes(tag.value)) {
|
||||
seen.push(tag.value);
|
||||
consolidated.push(tag);
|
||||
}
|
||||
});
|
||||
return consolidated;
|
||||
}
|
||||
|
||||
vm.next = (currentTab) => {
|
||||
if(_.has(vm, 'steps.other_prompts.tab._active') && vm.steps.other_prompts.tab._active === true){
|
||||
try {
|
||||
@ -243,6 +275,22 @@ export default [ 'ProcessErrors', 'CredentialTypeModel', 'TemplatesStrings', '$f
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
// The current tag input state lives somewhere in the associated select2
|
||||
// widgetry and isn't directly tied to the vm, so extract the tag values
|
||||
// and update the vm to keep it in sync.
|
||||
if (vm.promptDataClone.launchConf.ask_tags_on_launch) {
|
||||
vm.promptDataClone.prompts.tags.value = consolidateTags(
|
||||
angular.copy(vm.promptDataClone.prompts.tags.value),
|
||||
getSelectedTags("#job_launch_job_tags")
|
||||
);
|
||||
}
|
||||
if (vm.promptDataClone.launchConf.ask_skip_tags_on_launch) {
|
||||
vm.promptDataClone.prompts.skipTags.value = consolidateTags(
|
||||
angular.copy(vm.promptDataClone.prompts.skipTags.value),
|
||||
getSelectedTags("#job_launch_skip_tags")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let nextStep;
|
||||
|
||||
@ -12,19 +12,6 @@ export default
|
||||
|
||||
let scope;
|
||||
|
||||
let consolidateTags = (tagModel, tagId) => {
|
||||
let tags = angular.copy(tagModel);
|
||||
$(tagId).siblings(".select2").first().find(".select2-selection__choice").each((optionIndex, option) => {
|
||||
tags.push({
|
||||
value: option.title,
|
||||
name: option.title,
|
||||
label: option.title
|
||||
});
|
||||
});
|
||||
|
||||
return [...tags.reduce((map, tag) => map.has(tag.value) ? map : map.set(tag.value, tag), new Map()).values()];
|
||||
};
|
||||
|
||||
vm.init = (_scope_) => {
|
||||
scope = _scope_;
|
||||
|
||||
@ -35,14 +22,6 @@ export default
|
||||
|
||||
const surveyPasswords = {};
|
||||
|
||||
if (scope.promptData.launchConf.ask_tags_on_launch) {
|
||||
scope.promptData.prompts.tags.value = consolidateTags(scope.promptData.prompts.tags.value, "#job_launch_job_tags");
|
||||
}
|
||||
|
||||
if (scope.promptData.launchConf.ask_skip_tags_on_launch) {
|
||||
scope.promptData.prompts.skipTags.value = consolidateTags(scope.promptData.prompts.skipTags.value, "#job_launch_skip_tags");
|
||||
}
|
||||
|
||||
if (scope.promptData.launchConf.survey_enabled){
|
||||
scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false);
|
||||
scope.promptData.surveyQuestions.forEach(surveyQuestion => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user