mirror of
https://github.com/ansible/awx.git
synced 2026-02-25 15:06:02 -03:30
AC-450 initialize SCM Branch title value when editing a project. Added awValidUrl directive.
This commit is contained in:
@@ -371,6 +371,7 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
}
|
}
|
||||||
|
|
||||||
master['scm_type'] = scope['scm_type'];
|
master['scm_type'] = scope['scm_type'];
|
||||||
|
scope.scmBranchLabel = (scope.scm_type && scope.scm_type.value && scope.scm_type.value == 'svn') ? 'Revision #' : 'SCM Branch';
|
||||||
setAskCheckboxes();
|
setAskCheckboxes();
|
||||||
|
|
||||||
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
// Initialize related search functions. Doing it here to make sure relatedSets object is populated.
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
label: 'SCM URL',
|
label: 'SCM URL',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
ngShow: "scm_type !== '' && scm_type !== null",
|
ngShow: "scm_type !== '' && scm_type !== null",
|
||||||
addRequired: false,
|
awValidUrl: true,
|
||||||
editRequired: false,
|
|
||||||
awRequiredWhen: {variable: "scm_type", init: "true" }
|
awRequiredWhen: {variable: "scm_type", init: "true" }
|
||||||
},
|
},
|
||||||
scm_branch: {
|
scm_branch: {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ angular.module('JobEventsListDefinition', [])
|
|||||||
|
|
||||||
fields: {
|
fields: {
|
||||||
created: {
|
created: {
|
||||||
label: 'Date',
|
label: 'Created On',
|
||||||
key: true,
|
key: true,
|
||||||
nosort: true,
|
nosort: true,
|
||||||
searchable: false,
|
searchable: false,
|
||||||
|
|||||||
@@ -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
|
* Enable TB tooltips. To add a tooltip to an element, include the following directive in
|
||||||
* the element's attributes:
|
* the element's attributes:
|
||||||
|
|||||||
@@ -414,6 +414,7 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += (field.autocomplete !== undefined) ? this.attr(field, 'autocomplete') : "";
|
html += (field.autocomplete !== undefined) ? this.attr(field, 'autocomplete') : "";
|
||||||
html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" +
|
html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" +
|
||||||
field.awRequiredWhen.variable + "\" " : "";
|
field.awRequiredWhen.variable + "\" " : "";
|
||||||
|
html += (field.awValidUrl) ? "aw-valid-url " : "";
|
||||||
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled=\"" + field.associated + "_ask\" " : "";
|
html += (field.associated && this.form.fields[field.associated].ask) ? "ng-disabled=\"" + field.associated + "_ask\" " : "";
|
||||||
html += " >\n";
|
html += " >\n";
|
||||||
}
|
}
|
||||||
@@ -450,6 +451,10 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||||
".$error.awpassmatch\">Must match Password value</div>\n";
|
".$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) {
|
if (field.chkPass) {
|
||||||
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
html += "<div class=\"error\" ng-show=\"" + this.form.name + '_form.' + fld +
|
||||||
|
|||||||
Reference in New Issue
Block a user