AC-450 initialize SCM Branch title value when editing a project. Added awValidUrl directive.

This commit is contained in:
chouseknecht 2013-09-11 15:35:45 -04:00
parent 85833914ff
commit 39ceceb18e
5 changed files with 31 additions and 3 deletions

View File

@ -371,6 +371,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
}
master['scm_type'] = scope['scm_type'];
scope.scmBranchLabel = (scope.scm_type && scope.scm_type.value && scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
setAskCheckboxes();
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.

View File

@ -96,8 +96,7 @@ angular.module('ProjectFormDefinition', [])
label: 'SCM URL',
type: 'text',
ngShow: "scm_type !== '' && scm_type !== null",
addRequired: false,
editRequired: false,
awValidUrl: true,
awRequiredWhen: {variable: "scm_type", init: "true" }
},
scm_branch: {

View File

@ -33,7 +33,7 @@ angular.module('JobEventsListDefinition', [])
fields: {
created: {
label: 'Date',
label: 'Created On',
key: true,
nosort: true,
searchable: false,

View File

@ -195,6 +195,29 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Hos
}
}])
//
// awValidUrl
//
.directive('awValidUrl', [ function() {
return {
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift( function(viewValue) {
var validity = true;
if (viewValue !== '') {
ctrl.$setValidity('required', true);
var rgx = /^(https|http|ssh)\:\/\//;
var rgx2 = /\@/g;
if (!rgx.test(viewValue) || rgx2.test(viewValue)) {
validity = false;
}
}
ctrl.$setValidity('awvalidurl', validity);
})
}
}
}])
/*
* Enable TB tooltips. To add a tooltip to an element, include the following directive in
* the element's attributes:

View File

@ -414,6 +414,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
html += (field.autocomplete !== undefined) ? this.attr(field, 'autocomplete') : "";
html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" +
field.awRequiredWhen.variable + "\" " : "";
html += (field.awValidUrl) ? "aw-valid-url " : "";
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled=\"" + field.associated + "_ask\" " : "";
html += " >\n";
}
@ -450,6 +451,10 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
".$error.awpassmatch\">Must match Password value</div>\n";
}
if (field.awValidUrl) {
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
".$error.awvalidurl\">URL must begin with ssh, http or https and may not contain '@'</div>\n";
}
if (field.chkPass) {
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +