1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 08:21:15 +03:00

adding type ahead selector to survey

for job tags and skip tags
This commit is contained in:
Jared Tabor 2017-06-28 17:00:41 -07:00
parent 56724ffa50
commit 768fa13aef
4 changed files with 51 additions and 8 deletions

View File

@ -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){

View File

@ -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) {

View File

@ -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,

View File

@ -214,7 +214,16 @@
<span class="Form-inputLabel" translate>Job Tags</span>
</label>
<div>
<textarea rows="5" ng-model="other_prompt_data.job_tags" name="tags" class="form-control Form-textArea Form-textInput"></textarea>
<select
id="job_launch_job_tags"
ng-options="v.label for v in other_prompt_data.job_tags_options track by v.value"
ng-model="other_prompt_data.job_tags"
class="form-control Form-dropDown"
name="verbosity"
tabindex="-1"
aria-hidden="true"
multiple>
</select>
</div>
</div>
<div class="form-group Form-formGroup Form-formGroup--singleColumn" ng-if="ask_skip_tags_on_launch">
@ -222,7 +231,17 @@
<span class="Form-inputLabel" translate>Skip Tags</span>
</label>
<div>
<textarea rows="5" ng-model="other_prompt_data.skip_tags" name="skip_tags" class="form-control Form-textArea Form-textInput"></textarea>
<!-- <textarea rows="5" ng-model="other_prompt_data.skip_tags" name="skip_tags" class="form-control Form-textArea Form-textInput"></textarea> -->
<select
id="job_launch_skip_tags"
ng-options="v.label for v in other_prompt_data.skip_tags_options track by v.value"
ng-model="other_prompt_data.skip_tags"
class="form-control Form-dropDown"
name="verbosity"
tabindex="-1"
aria-hidden="true"
multiple>
</select>
</div>
</div>
</form>