mirror of
https://github.com/ansible/awx.git
synced 2026-05-23 08:37:48 -02:30
AC-351 latest changes. Fixed project add/edit form issues.
This commit is contained in:
@@ -104,6 +104,8 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
GetProjectPath({ scope: scope, master: master });
|
GetProjectPath({ scope: scope, master: master });
|
||||||
|
|
||||||
|
scope.scm_type = null;
|
||||||
|
master.scm_type = null;
|
||||||
scope.scm_type_options = [
|
scope.scm_type_options = [
|
||||||
{ label: 'GitHub', value: 'git' },
|
{ label: 'GitHub', value: 'git' },
|
||||||
{ label: 'SVN', value: 'svn' }];
|
{ label: 'SVN', value: 'svn' }];
|
||||||
@@ -120,10 +122,18 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
var data = {};
|
var data = {};
|
||||||
for (var fld in form.fields) {
|
for (var fld in form.fields) {
|
||||||
|
if (form.fields[fld].type == 'checkbox_group') {
|
||||||
|
for (var i=0; i < form.fields[fld].fields.length; i++) {
|
||||||
|
data[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
data[fld] = scope[fld];
|
data[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (scope.scm_type) {
|
if (scope.scm_type) {
|
||||||
data.scm_type = scope.scm_type.value;
|
data.scm_type = scope.scm_type.value;
|
||||||
|
delete data.local_path;
|
||||||
}
|
}
|
||||||
var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
var url = (base == 'teams') ? GetBasePath('teams') + $routeParams.team_id + '/projects/' : defaultUrl;
|
||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
@@ -149,6 +159,11 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
scope.scmChange = function() {
|
||||||
|
// When an scm_type is set, path is not required
|
||||||
|
scope.pathRequired = (scope.scm_type) ? false : true;
|
||||||
|
}
|
||||||
|
|
||||||
// Cancel
|
// Cancel
|
||||||
scope.formReset = function() {
|
scope.formReset = function() {
|
||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
@@ -231,11 +246,19 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
LoadBreadCrumbs({ path: '/projects/' + id, title: data.name });
|
LoadBreadCrumbs({ path: '/projects/' + id, title: data.name });
|
||||||
for (var fld in form.fields) {
|
for (var fld in form.fields) {
|
||||||
|
if (form.fields[fld].type == 'checkbox_group') {
|
||||||
|
for (var i=0; i < form.fields[fld].fields.length; i++) {
|
||||||
|
scope[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
|
||||||
|
master[form.fields[fld].fields[i].name] = data[form.fields[fld].fields[i].name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
if (data[fld]) {
|
if (data[fld]) {
|
||||||
scope[fld] = data[fld];
|
scope[fld] = data[fld];
|
||||||
master[fld] = data[fld];
|
master[fld] = data[fld];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var related = data.related;
|
var related = data.related;
|
||||||
for (var set in form.related) {
|
for (var set in form.related) {
|
||||||
if (related[set]) {
|
if (related[set]) {
|
||||||
@@ -250,7 +273,12 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scope.pathRequired = false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
scope.pathRequired = true;
|
||||||
|
}
|
||||||
|
|
||||||
master['scm_type'] = scope['scm_type'];
|
master['scm_type'] = scope['scm_type'];
|
||||||
setAskCheckboxes();
|
setAskCheckboxes();
|
||||||
|
|
||||||
@@ -270,10 +298,18 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
$rootScope.flashMessage = null;
|
$rootScope.flashMessage = null;
|
||||||
var params = {};
|
var params = {};
|
||||||
for (var fld in form.fields) {
|
for (var fld in form.fields) {
|
||||||
|
if (form.fields[fld].type == 'checkbox_group') {
|
||||||
|
for (var i=0; i < form.fields[fld].fields.length; i++) {
|
||||||
|
params[form.fields[fld].fields[i].name] = scope[form.fields[fld].fields[i].name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
params[fld] = scope[fld];
|
params[fld] = scope[fld];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (scope.scm_type) {
|
if (scope.scm_type) {
|
||||||
params.scm_type = scope.scm_type.value;
|
params.scm_type = scope.scm_type.value;
|
||||||
|
delete params.local_path;
|
||||||
}
|
}
|
||||||
Rest.setUrl(defaultUrl);
|
Rest.setUrl(defaultUrl);
|
||||||
Rest.put(params)
|
Rest.put(params)
|
||||||
@@ -359,6 +395,11 @@ function ProjectsEdit ($scope, $rootScope, $compile, $location, $log, $routePara
|
|||||||
scope[associated] = '';
|
scope[associated] = '';
|
||||||
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
scope[form.name + '_form'][associated].$setValidity('awpassmatch', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope.scmChange = function() {
|
||||||
|
// When an scm_type is set, path is not required
|
||||||
|
scope.pathRequired = (scope.scm_type) ? false : true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
|
ProjectsEdit.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
base_dir: {
|
base_dir: {
|
||||||
label: 'Project Base Path',
|
label: 'Project Base Path',
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
"class": 'span6',
|
"class": 'col-lg-6',
|
||||||
showonly: true,
|
showonly: true,
|
||||||
awPopOver: '<p>Base path used for locating playbooks. Directories found inside this path will be listed in the playbook directory drop-down. ' +
|
awPopOver: '<p>Base path used for locating playbooks. Directories found inside this path will be listed in the playbook directory drop-down. ' +
|
||||||
'Together the base path and selected playbook directory provide the full path used to locate playbooks.</p>' +
|
'Together the base path and selected playbook directory provide the full path used to locate playbooks.</p>' +
|
||||||
@@ -58,13 +58,24 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
dataContainer: 'body',
|
dataContainer: 'body',
|
||||||
dataPlacement: 'right'
|
dataPlacement: 'right'
|
||||||
},
|
},
|
||||||
|
scm_type: {
|
||||||
|
label: 'SCM Type',
|
||||||
|
type: 'select',
|
||||||
|
ngOptions: 'type.label for type in scm_type_options',
|
||||||
|
ngChange: 'scmChange()',
|
||||||
|
"default": '',
|
||||||
|
addRequired: false,
|
||||||
|
editRequired: false
|
||||||
|
},
|
||||||
local_path: {
|
local_path: {
|
||||||
label: 'Playbook Directory',
|
label: 'Playbook Directory',
|
||||||
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: true,
|
addRequired: false,
|
||||||
editRequired: true,
|
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.' +
|
awPopOver: '<p>Select from the list of directories found in the base path.' +
|
||||||
'Together the base path and the playbook directory provide the full path used to locate playbooks.</p>' +
|
'Together the base path and the playbook directory provide the full path used to locate playbooks.</p>' +
|
||||||
'<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>',
|
'<p>Use PROJECTS_ROOT in your environment settings file to determine the base path value.</p>',
|
||||||
@@ -72,14 +83,6 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
dataContainer: 'body',
|
dataContainer: 'body',
|
||||||
dataPlacement: 'right'
|
dataPlacement: 'right'
|
||||||
},
|
},
|
||||||
scm_type: {
|
|
||||||
label: 'SCM Type',
|
|
||||||
type: 'select',
|
|
||||||
ngOptions: 'type.label for type in scm_type_options',
|
|
||||||
"default": '',
|
|
||||||
addRequired: false,
|
|
||||||
editRequired: false
|
|
||||||
},
|
|
||||||
scm_url: {
|
scm_url: {
|
||||||
label: 'SCM URL',
|
label: 'SCM URL',
|
||||||
type: 'text',
|
type: 'text',
|
||||||
|
|||||||
@@ -137,8 +137,16 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
// value, you have clear the model.
|
// value, you have clear the model.
|
||||||
this.scope[this.form.name + '_form'].$setPristine();
|
this.scope[this.form.name + '_form'].$setPristine();
|
||||||
for (var fld in this.form.fields) {
|
for (var fld in this.form.fields) {
|
||||||
|
if (this.form.fields[fld].type == 'checkbox_group') {
|
||||||
|
for (var i=0; i < this.form.fields[fld].fields.length; i++) {
|
||||||
|
this.scope[this.form.fields[fld].fields[i].name] = '';
|
||||||
|
this.scope[this.form.fields[fld].fields[i].name + '_api_error'] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.scope[fld] = '';
|
this.scope[fld] = '';
|
||||||
this.scope[fld + '_api_error'] = '';
|
this.scope[fld + '_api_error'] = '';
|
||||||
|
}
|
||||||
if (this.form.fields[fld].sourceModel) {
|
if (this.form.fields[fld].sourceModel) {
|
||||||
this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] = '';
|
this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField] = '';
|
||||||
this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '_api_error'] = '';
|
this.scope[this.form.fields[fld].sourceModel + '_' + this.form.fields[fld].sourceField + '_api_error'] = '';
|
||||||
@@ -480,6 +488,8 @@ angular.module('FormGenerator', ['GeneratorHelpers', 'ngCookies'])
|
|||||||
html += (options.mode == 'edit' && field.editRequired) ? "required " : "";
|
html += (options.mode == 'edit' && field.editRequired) ? "required " : "";
|
||||||
html += (options.mode == 'add' && field.addRequired) ? "required " : "";
|
html += (options.mode == 'add' && field.addRequired) ? "required " : "";
|
||||||
html += (field.readonly) ? "readonly " : "";
|
html += (field.readonly) ? "readonly " : "";
|
||||||
|
html += (field.awRequiredWhen) ? "data-awrequired-init=\"" + field.awRequiredWhen.init + "\" aw-required-when=\"" +
|
||||||
|
field.awRequiredWhen.variable + "\" " : "";
|
||||||
html += ">\n";
|
html += ">\n";
|
||||||
html += "<option value=\"\">Choose " + field.label + "</option>\n";
|
html += "<option value=\"\">Choose " + field.label + "</option>\n";
|
||||||
html += "</select>\n";
|
html += "</select>\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user