diff --git a/awx/ui/client/legacy-styles/ansible-ui.less b/awx/ui/client/legacy-styles/ansible-ui.less index cc8380c721..6459b5ca60 100644 --- a/awx/ui/client/legacy-styles/ansible-ui.less +++ b/awx/ui/client/legacy-styles/ansible-ui.less @@ -2296,3 +2296,4 @@ html input[disabled] { .CodeMirror--disabled .CodeMirror-cursors { display: none; } + diff --git a/awx/ui/client/legacy-styles/forms.less b/awx/ui/client/legacy-styles/forms.less index 23f49bde58..4ee8ecfa6e 100644 --- a/awx/ui/client/legacy-styles/forms.less +++ b/awx/ui/client/legacy-styles/forms.less @@ -478,6 +478,28 @@ input[type='radio']:checked:before { width: 100%; display: block !important; } + +.Form-inputLabelContainer[for=variables] { + width: auto; + display: inline-block !important; +} + +.FormToggle {} +.FormToggle-container { + float: right; + margin: 0 0 0 10px; + padding-bottom: 5px; + + .btn.btn-xs { + padding: 0px 10px; + } + + input { + visibility: hidden; + position: absolute; + } +} + .Form-inputLabel{ text-transform: uppercase; color: @default-interface-txt; diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index a1a2a6761f..4030aa2183 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -659,14 +659,26 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += (field.hintText) ? "\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tHint: " + field.hintText + "\n\t\t" : ""; // Variable editing if (fld === "variables" || fld === "extra_vars" || _.last(fld.split('_')) === 'variables' || fld === 'source_vars') { - html += "
" + - " YAML\n"; - html += " JSON\n"; - html += "
\n"; + let parseTypeId = `${form.name}_${fld}_parse_type`; + let parseTypeName = field.parseTypeName || 'parseType'; + let getToggleClass = (primary, secondary) => `{ + 'btn-primary': ${parseTypeName} === '${primary}', + 'btn-default' : ${parseTypeName} === '${secondary}' + }`; + let toggleLeftClass = getToggleClass('yaml', 'json'); + let toggleRightClass = getToggleClass('json', 'yaml'); + + html += ` +
+
+ + +
+
`; } if (field.labelAction) {