mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-26 18:01:47 -05:00
Fixed form validation issues on Projects detail for manual projects. When editing an existing project, local_path value was not being set, even though it diplayed properly. Changed local_path from array of strings to array of objects. Now local_path values are sorted and the correct object in the list is selected.
This commit is contained in:
committed by
Chris Church
parent
bac22205a8
commit
a5c44a391c
@@ -17,6 +17,24 @@ angular.module('ProjectPathHelper', ['RestServices', 'Utilities'])
|
||||
var scope = params.scope;
|
||||
var master = params.master;
|
||||
|
||||
function arraySort(data) {
|
||||
//Sort nodes by name
|
||||
var names = [];
|
||||
var newData = [];
|
||||
for (var i=0; i < data.length; i++) {
|
||||
names.push(data[i].value);
|
||||
}
|
||||
names.sort();
|
||||
for (var j=0; j < names.length; j++) {
|
||||
for (i=0; i < data.length; i++) {
|
||||
if (data[i].value == names[j]) {
|
||||
newData.push(data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
|
||||
scope.showMissingPlaybooksAlert = false;
|
||||
|
||||
Rest.setUrl( GetBasePath('config') );
|
||||
@@ -24,12 +42,22 @@ angular.module('ProjectPathHelper', ['RestServices', 'Utilities'])
|
||||
.success( function(data, status, headers, config) {
|
||||
var opts = [];
|
||||
for (var i=0; i < data.project_local_paths.length; i++) {
|
||||
opts.push(data.project_local_paths[i]);
|
||||
opts.push({ label: data.project_local_paths[i], value: data.project_local_paths[i] });
|
||||
}
|
||||
if (scope.local_path) {
|
||||
opts.push(scope.local_path);
|
||||
// List only includes paths not assigned to projects, so add the
|
||||
// path assigned to the current project.
|
||||
opts.push({ label: scope.local_path, value: scope.local_path });
|
||||
}
|
||||
scope.project_local_paths = arraySort(opts);
|
||||
if (scope.local_path) {
|
||||
for (var i=0; scope.project_local_paths.length; i++) {
|
||||
if (scope.project_local_paths[i].value == scope.local_path) {
|
||||
scope.local_path = scope.project_local_paths[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
scope.project_local_paths = opts;
|
||||
scope.base_dir = data.project_base_dir;
|
||||
master.base_dir = scope.base_dir; // Keep in master object so that it doesn't get
|
||||
// wiped out on form reset.
|
||||
|
||||
Reference in New Issue
Block a user