1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-05 05:51:21 +03:00

AC-447 Fixed bug in /lib/directive.js-> awRequiredWhen.

This commit is contained in:
chouseknecht 2013-09-11 12:49:13 -04:00
parent fd16c0827a
commit c4f8872ae4
2 changed files with 14 additions and 8 deletions

View File

@ -83,8 +83,6 @@ angular.module('ProjectFormDefinition', [])
type: 'select',
id: 'local-path-select',
ngOptions: 'path for path in project_local_paths',
addRequired: false,
editRequired: false,
awRequiredWhen: { variable: "pathRequired", init: "true" },
ngShow: "scm_type == '' || scm_type == null",
awPopOver: '<p>Select from the list of directories found in the base path.' +

View File

@ -107,24 +107,32 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
function checkIt () {
var viewValue = elm.val();
var txt, label;
validity = true;
if ( scope[attrs.awRequiredWhen] && (elm.attr('required') == null || elm.attr('required') == undefined) ) {
$(elm).attr('required','required');
if ($(elm).hasClass('lookup')) {
$(elm).parent().parent().parent().find('label').prepend('* ');
}
else {
$(elm).parent().parent().find('label').prepend('* ');
}
}
else if (!scope[attrs.awRequiredWhen]) {
elm.removeAttr('required');
if ($(elm).hasClass('lookup')) {
var txt = $(elm).parent().parent().parent().find('label').text();
var txt = txt.replace(/^\*/,'');
var label = $(elm).parent().parent().parent().find('label');
txt = $(elm).parent().parent().parent().find('label').text();
label = $(elm).parent().parent().parent().find('label');
}
else {
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 == '')) {
validity = false;
}