mirror of
https://github.com/ansible/awx.git
synced 2026-01-13 11:00:03 -03:30
Merge pull request #5150 from jlmitch5/nullPromptField
fix erros with promptable lookups
This commit is contained in:
commit
3f098b1167
@ -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)'
|
||||
}
|
||||
},
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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.")) + "</div>\n";
|
||||
html += "<div class=\"error\" id=\"" + this.form.name + "-" + fld + "-notfound-error\" ng-show=\"" +
|
||||
this.form.name + '_form.' +
|
||||
field.sourceModel + '_' + field.sourceField + ".$dirty && " +
|
||||
this.form.name + '_form.' + field.sourceModel + '_' + field.sourceField +
|
||||
".$error.awlookup && !(" + this.form.name + '_form.' +
|
||||
field.sourceModel + '_' + field.sourceField + ".$dirty && " +
|
||||
this.form.name + '_form.' + field.sourceModel + '_' + field.sourceField +
|
||||
".$error.required)\">" + i18n._("That value was not found. Please enter or select a valid value.") + "</div>\n";
|
||||
} else {
|
||||
html += "<div class=\"error\" id=\"" + this.form.name + "-" + fld + "-notfound-error\" ng-show=\"" +
|
||||
this.form.name + '_form.' +
|
||||
field.sourceModel + '_' + field.sourceField + ".$dirty && " +
|
||||
this.form.name + '_form.' + field.sourceModel + '_' + field.sourceField +
|
||||
".$error.awlookup\">" + i18n._("That value was not found. Please enter or select a valid value.") + "</div>\n";
|
||||
}
|
||||
html += "<div class=\"error\" id=\"" + this.form.name + "-" + fld + "-notfound-error\" ng-show=\"" +
|
||||
this.form.name + '_form.' +
|
||||
field.sourceModel + '_' + field.sourceField + ".$dirty && " +
|
||||
this.form.name + '_form.' + field.sourceModel + '_' + field.sourceField +
|
||||
".$error.awlookup\">" + i18n._("That value was not found. Please enter or select a valid value.") + "</div>\n";
|
||||
html += "<div class=\"error api-error\" id=\"" + this.form.name + "-" + fld + "-api-error\" ng-bind=\"" + field.sourceModel + '_' + field.sourceField +
|
||||
"_api_error\"></div>\n";
|
||||
html += "</div>\n";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user