mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
AC-447 Fixed bug in /lib/directive.js-> awRequiredWhen.
This commit is contained in:
@@ -83,8 +83,6 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
type: 'select',
|
type: 'select',
|
||||||
id: 'local-path-select',
|
id: 'local-path-select',
|
||||||
ngOptions: 'path for path in project_local_paths',
|
ngOptions: 'path for path in project_local_paths',
|
||||||
addRequired: false,
|
|
||||||
editRequired: false,
|
|
||||||
awRequiredWhen: { variable: "pathRequired", init: "true" },
|
awRequiredWhen: { variable: "pathRequired", init: "true" },
|
||||||
ngShow: "scm_type == '' || scm_type == null",
|
ngShow: "scm_type == '' || scm_type == null",
|
||||||
awPopOver: '<p>Select from the list of directories found in the base path.' +
|
awPopOver: '<p>Select from the list of directories found in the base path.' +
|
||||||
|
|||||||
@@ -107,22 +107,30 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
|
|||||||
|
|
||||||
function checkIt () {
|
function checkIt () {
|
||||||
var viewValue = elm.val();
|
var viewValue = elm.val();
|
||||||
|
var txt, label;
|
||||||
validity = true;
|
validity = true;
|
||||||
if ( scope[attrs.awRequiredWhen] && (elm.attr('required') == null || elm.attr('required') == undefined) ) {
|
if ( scope[attrs.awRequiredWhen] && (elm.attr('required') == null || elm.attr('required') == undefined) ) {
|
||||||
$(elm).attr('required','required');
|
$(elm).attr('required','required');
|
||||||
if ($(elm).hasClass('lookup')) {
|
if ($(elm).hasClass('lookup')) {
|
||||||
$(elm).parent().parent().parent().find('label').prepend('* ');
|
$(elm).parent().parent().parent().find('label').prepend('* ');
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$(elm).parent().parent().find('label').prepend('* ');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (!scope[attrs.awRequiredWhen]) {
|
else if (!scope[attrs.awRequiredWhen]) {
|
||||||
elm.removeAttr('required');
|
elm.removeAttr('required');
|
||||||
if ($(elm).hasClass('lookup')) {
|
if ($(elm).hasClass('lookup')) {
|
||||||
var txt = $(elm).parent().parent().parent().find('label').text();
|
txt = $(elm).parent().parent().parent().find('label').text();
|
||||||
var txt = txt.replace(/^\*/,'');
|
label = $(elm).parent().parent().parent().find('label');
|
||||||
var label = $(elm).parent().parent().parent().find('label');
|
}
|
||||||
if (label) {
|
else {
|
||||||
label.text(txt);
|
txt = $(elm).parent().parent().find('label').text();
|
||||||
}
|
label = $(elm).parent().parent().find('label');
|
||||||
|
}
|
||||||
|
txt = txt.replace(/^\* /,'');
|
||||||
|
if (label) {
|
||||||
|
label.text(txt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scope[attrs.awRequiredWhen] && (viewValue == undefined || viewValue == null || viewValue == '')) {
|
if (scope[attrs.awRequiredWhen] && (viewValue == undefined || viewValue == null || viewValue == '')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user