diff --git a/awx/ui/client/legacy-styles/forms.less b/awx/ui/client/legacy-styles/forms.less
index 741e654c99..5ce29fbe1c 100644
--- a/awx/ui/client/legacy-styles/forms.less
+++ b/awx/ui/client/legacy-styles/forms.less
@@ -490,9 +490,9 @@ input[type='radio']:checked:before {
.FormToggle {}
.FormToggle-container {
- float: right;
margin: 0 0 0 10px;
padding-bottom: 5px;
+ display: initial;
label {
&:first-child {
@@ -513,6 +513,16 @@ input[type='radio']:checked:before {
}
}
+.Form-inputLabelContainer {
+ width: 100%;
+ display: block !important;
+}
+
+.Form-inputLabelContainer[for=variables] {
+ width: 100%;
+ display: inline-block !important;
+}
+
.Form-inputLabel{
text-transform: uppercase;
color: @default-interface-txt;
@@ -614,6 +624,10 @@ input[type='radio']:checked:before {
max-width: 100% !important;
}
+.Form-checkbox {
+ float: right;
+}
+
.Form-subCheckbox {
margin-top: 5px;
font-size: small;
diff --git a/awx/ui/client/src/shared/Utilities.js b/awx/ui/client/src/shared/Utilities.js
index 3d3646e64d..0b7a86970f 100644
--- a/awx/ui/client/src/shared/Utilities.js
+++ b/awx/ui/client/src/shared/Utilities.js
@@ -665,6 +665,10 @@ angular.module('Utilities', ['RestServices', 'Utilities'])
// Don't toggle the dropdown when a multiselect option is
// being removed
if (multiple) {
+ if (params.disabledOptions) {
+ $(element).on('select2:selecting', e => e.preventDefault());
+ }
+
$(element).on('select2:opening', (e) => {
var unselecting = $(e.target).data('select2-unselecting');
if (unselecting === true) {
diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js
index 25a28db1d5..70e515f3a5 100644
--- a/awx/ui/client/src/shared/form-generator.js
+++ b/awx/ui/client/src/shared/form-generator.js
@@ -639,7 +639,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
return html;
}
- function label() {
+ function label(options) {
var html = '';
if (field.label || field.labelBind) {
html += "\n";
}
+
return html;
}
@@ -770,7 +775,21 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
//text fields
if (field.type === 'text' || field.type === 'password' || field.type === 'email') {
- html += label();
+ let labelOptions = {};
+
+ if (field.subCheckbox) {
+ labelOptions.checkbox = {
+ id: `${this.form.name}_${fld}_ask_chbox`,
+ ngShow: field.subCheckbox.ngShow,
+ ngChange: field.subCheckbox.ngChange,
+ ngModel: field.subCheckbox.variable,
+ ngDisabled: field.ngDisabled,
+ text: field.subCheckbox.text || ''
+ };
+ }
+
+ html += label(labelOptions);
+
html += "
\n";
@@ -821,19 +840,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
"\n
\n";
}
- if (field.subCheckbox) {
- html += "";
- }
-
// Add error messages
if (field.required || field.awRequiredWhen) {
error_message = i18n._('Please enter a value.');
@@ -930,24 +936,6 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += "\n";
- if (field.subCheckbox) {
- html += "";
- }
-
// Add error messages
if (field.required || field.awRequiredWhen) {
error_message = i18n._("Please enter a value.");
@@ -1006,8 +994,20 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
//textarea fields
if (field.type === 'textarea') {
+ let labelOptions = {};
- html += label();
+ if (field.subCheckbox) {
+ labelOptions.checkbox = {
+ id: `${this.form.name}_${fld}_ask_chbox`,
+ ngModel: field.subCheckbox.variable,
+ ngShow: field.subCheckbox.ngShow,
+ ngChange: field.subCheckbox.ngChange,
+ ngDisabled: field.ngDisabled || field.subCheckbox.ngDisabled,
+ text: field.subCheckbox.text || ''
+ };
+ }
+
+ html += label(labelOptions);
html += "\n";
- if (field.subCheckbox) {
- html += "
";
- }
-
// Add error messages
if (field.required) {
html += "
\n";
html += "
\n";
- if (field.subCheckbox) {
- html += "
";
- }
-
// Add error messages
if (field.required || field.awRequiredWhen) {
html += "
\n";
- if (field.subCheckbox) {
- html += "
";
- }
-
// Add error messages
if (field.required) {
html += "
\n";
html += "
\n";
- if (field.subCheckbox) {
- html += "
";
- }
-
// Add error messages
if (field.required || field.awRequiredWhen) {
html += "
`;
return html;
- }
+ },
};
+
+ function createCheckbox (options) {
+ let ngChange = options.ngChange ? `ng-change="${options.ngChange}"` : '';
+ let ngDisabled = options.ngDisabled ? `ng-disabled="${options.ngDisabled}"` : '';
+ let ngModel = options.ngModel ? `ng-model="${options.ngModel}"` : '';
+ let ngShow = options.ngShow ? `ng-show="${options.ngShow}"` : '';
+
+ return `
+ `;
+ }
}
]);
diff --git a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js
index 1be5229456..6b30a42248 100644
--- a/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js
+++ b/awx/ui/client/src/templates/survey-maker/render/multiple-choice.directive.js
@@ -2,7 +2,6 @@
import {templateUrl} from '../../../shared/template-url/template-url.factory';
function link($timeout, CreateSelect2, scope, element, attrs, ngModel) {
-
$timeout(function() {
// select2-ify the dropdown. If the preview flag is passed here
@@ -13,12 +12,13 @@ function link($timeout, CreateSelect2, scope, element, attrs, ngModel) {
// and we don't actually need the dropdown portion. Note that the custom
// dropdown adapter is used to get the dropdown contents to show up in
// a modal.
+
CreateSelect2({
element: element.find('select'),
multiple: scope.isMultipleSelect(),
- customDropdownAdapter: scope.preview ? false : true
+ customDropdownAdapter: scope.preview ? false : true,
+ disabledOptions: true
});
-
});
}
diff --git a/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html b/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html
index 0777b94c90..3e6a7bdceb 100644
--- a/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html
+++ b/awx/ui/client/src/templates/survey-maker/render/survey-question.partial.html
@@ -10,9 +10,7 @@
question="question"
choices="choices"
ng-required="isRequired === 'true'"
- ng-model="defaultValue"
- ng-disabled="isDisabled === 'true'"
- preview="preview">
+ ng-model="defaultValue">