diff --git a/awx/ui/client/src/forms/JobTemplates.js b/awx/ui/client/src/forms/JobTemplates.js index fd4946f329..af2379ae93 100644 --- a/awx/ui/client/src/forms/JobTemplates.js +++ b/awx/ui/client/src/forms/JobTemplates.js @@ -89,6 +89,7 @@ export default dataContainer: "body", subCheckbox: { variable: 'ask_inventory_on_launch', + ngChange: 'job_template_form.inventory_name.$validate()', ngShow: "!job_type.value || job_type.value !== 'scan'", text: i18n._('Prompt on launch') }, @@ -158,7 +159,8 @@ export default dataContainer: "body", subCheckbox: { variable: 'ask_credential_on_launch', - text: i18n._('Prompt on launch') + text: i18n._('Prompt on launch'), + ngChange: 'job_template_form.credential_name.$validate()', }, ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)' }, @@ -396,7 +398,7 @@ export default }, save: { ngClick: 'formSave()', //$scope.function to call on click, optional - ngDisabled: "job_templates_form.$invalid",//true //Disable when $pristine or $invalid, optional and when can_edit = false, for permission reasons + ngDisabled: "job_template_form.$invalid",//true //Disable when $pristine or $invalid, optional and when can_edit = false, for permission reasons ngShow: '(job_template_obj.summary_fields.user_capabilities.edit || canAddJobTemplate)' } }, diff --git a/awx/ui/client/src/shared/directives.js b/awx/ui/client/src/shared/directives.js index 63d21b68bf..78b9ec916f 100644 --- a/awx/ui/client/src/shared/directives.js +++ b/awx/ui/client/src/shared/directives.js @@ -638,6 +638,22 @@ function(ConfigurationUtils, i18n) { } function setValidity(ctrl, validity){ + var isRequired; + if (attrs.required) { + isRequired = true; + } else { + isRequired = false; + } + if (attrs.awRequiredWhen) { + if (attrs.awRequiredWhen.charAt(0) === "!") { + isRequired = !scope[attrs.awRequiredWhen.slice(1, attrs.awRequiredWhen.length)]; + } else { + isRequired = scope[attrs.awRequiredWhen]; + } + } + if (!isRequired && (viewValue === undefined || viewValue === undefined || viewValue === "")) { + validity = true; + } ctrl.$setValidity('awlookup', validity); return defer.resolve(validity); } @@ -977,9 +993,9 @@ function(ConfigurationUtils, i18n) { ctrl.$setValidity('max', true); ctrl.$dirty = true; ctrl.$render(); - if (scope.job_templates_form) { + if (scope.job_template_form) { // need a way to find the parent form and mark it dirty - scope.job_templates_form.$dirty = true; + scope.job_template_form.$dirty = true; } if (!scope.$$phase) { scope.$digest(); diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index 68872f0174..6d2809181e 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1404,12 +1404,21 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat field.sourceModel + '_' + field.sourceField + ".$dirty && " + this.form.name + '_form.' + field.sourceModel + '_' + field.sourceField + ".$error.required\">" + (field.requiredErrorMsg ? field.requiredErrorMsg : i18n._("Please select a value.")) + "\n"; + html += "
" + i18n._("That value was not found. Please enter or select a valid value.") + "
\n"; + } else { + html += "
" + i18n._("That value was not found. Please enter or select a valid value.") + "
\n"; } - html += "
" + i18n._("That value was not found. Please enter or select a valid value.") + "
\n"; html += "
\n"; html += "\n";