Initial stab URL validation. Adding '*' to label is now done via CSS :before rather than jquery DOM manipulation.

This commit is contained in:
chouseknecht 2013-09-11 16:44:17 -04:00
parent 39ceceb18e
commit 55292c9d08
4 changed files with 19 additions and 13 deletions

View File

@ -97,7 +97,15 @@ angular.module('ProjectFormDefinition', [])
type: 'text',
ngShow: "scm_type !== '' && scm_type !== null",
awValidUrl: true,
awRequiredWhen: {variable: "scm_type", init: "true" }
awRequiredWhen: { variable: "scm_type", init: "true" },
awPopOver: "<p>Provide the URL to your SCM server. The value should begin with the protocol https:\/\/, http:\/\/ or ssh:\/\/.</p>" +
"<p>Do not inlcude username or password values. Use the authentication settings instead.</p>" +
"<p>Examples include:</p>" +
"<p>ssh:\/\/github.com:ansible/ansible-examples.git</p>" +
"<p>https:\/\/github.com/ansible/ansible-examples.git</p>",
dataTitle: 'SCM URL',
dataPlacement: 'right',
dataContainer: 'body'
},
scm_branch: {
labelBind: "scmBranchLabel",

View File

@ -48,6 +48,10 @@ body {
}
}
.prepend-asterisk:before {
content: "\002A";
}
.subtitle {
font-size: 16px;
}

View File

@ -112,26 +112,21 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
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('* ');
$(elm).parent().parent().parent().find('label').addClass('prepend-asterisk');
}
else {
$(elm).parent().parent().find('label').prepend('* ');
$(elm).parent().parent().find('label').addClass('prepend-asterisk');
}
}
else if (!scope[attrs.awRequiredWhen]) {
elm.removeAttr('required');
if ($(elm).hasClass('lookup')) {
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);
}
label.removeClass('prepend-asterisk');
}
if (scope[attrs.awRequiredWhen] && (viewValue == undefined || viewValue == null || viewValue == '')) {
validity = false;

View File

@ -92,10 +92,9 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
// Prepend an asterisk to required field label
$('.form-control[required]').each(function() {
var label = $(this).parent().parent().find('label');
var rgx = /^\*/;
if ( !rgx.test(label.text()) ) {
// required field does not have leading *
label.prepend('* ');
if (label && !label.hasClass('prepend-asterisk')) {
console.log('adding prepend');
label.addClass('prepend-asterisk');
}
});