mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
AC-303 Adding a project now requires an Organization.
This commit is contained in:
@@ -72,7 +72,7 @@ ProjectsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routePar
|
|||||||
|
|
||||||
function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
||||||
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope,
|
||||||
GetBasePath, ReturnToCaller, GetProjectPath)
|
GetBasePath, ReturnToCaller, GetProjectPath, LookUpInit, OrganizationList)
|
||||||
{
|
{
|
||||||
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
|
||||||
//scope.
|
//scope.
|
||||||
@@ -90,6 +90,14 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
LoadBreadCrumbs();
|
LoadBreadCrumbs();
|
||||||
GetProjectPath({ scope: scope, master: master });
|
GetProjectPath({ scope: scope, master: master });
|
||||||
|
|
||||||
|
LookUpInit({
|
||||||
|
scope: scope,
|
||||||
|
form: form,
|
||||||
|
current_item: null,
|
||||||
|
list: OrganizationList,
|
||||||
|
field: 'organization'
|
||||||
|
});
|
||||||
|
|
||||||
// Save
|
// Save
|
||||||
scope.formSave = function() {
|
scope.formSave = function() {
|
||||||
var data = {};
|
var data = {};
|
||||||
@@ -100,12 +108,23 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
Rest.setUrl(url);
|
Rest.setUrl(url);
|
||||||
Rest.post(data)
|
Rest.post(data)
|
||||||
.success( function(data, status, headers, config) {
|
.success( function(data, status, headers, config) {
|
||||||
$rootScope.flashMessage = "New project successfully created!";
|
var id = data.id;
|
||||||
(base == 'projects') ? ReturnToCaller() : ReturnToCaller(1);
|
var url = GetBasePath('projects') + id + '/organizations/';
|
||||||
|
var org = { id: scope.organization };
|
||||||
|
Rest.setUrl(url);
|
||||||
|
Rest.post(org)
|
||||||
|
.success( function(data, status, headers, config) {
|
||||||
|
$rootScope.flashMessage = "New project successfully created!";
|
||||||
|
(base == 'projects') ? ReturnToCaller() : ReturnToCaller(1);
|
||||||
|
})
|
||||||
|
.error( function(data, status, headers, config) {
|
||||||
|
ProcessErrors(scope, data, status, ProjectsForm,
|
||||||
|
{ hdr: 'Error!', msg: 'Failed to add organization to project. POST returned status: ' + status });
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, ProjectsForm,
|
ProcessErrors(scope, data, status, ProjectsForm,
|
||||||
{ hdr: 'Error!', msg: 'Failed to create new project. Post returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to create new project. POST returned status: ' + status });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -121,7 +140,7 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
|||||||
|
|
||||||
ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
|
ProjectsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'ProjectsForm',
|
||||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
||||||
'ReturnToCaller', 'GetProjectPath'
|
'ReturnToCaller', 'GetProjectPath', 'LookUpInit', 'OrganizationList'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
* Credentials.js
|
* Credentials.js
|
||||||
* Form definition for Credential model
|
* Form definition for Credential model
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
angular.module('CredentialFormDefinition', [])
|
angular.module('CredentialFormDefinition', [])
|
||||||
.value(
|
.value(
|
||||||
|
|||||||
@@ -30,6 +30,21 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
addRequired: false,
|
addRequired: false,
|
||||||
editRequired: false
|
editRequired: false
|
||||||
},
|
},
|
||||||
|
organization: {
|
||||||
|
label: 'Organization',
|
||||||
|
type: 'lookup',
|
||||||
|
sourceModel: 'organization',
|
||||||
|
sourceField: 'name',
|
||||||
|
addRequired: true,
|
||||||
|
editRequired: false,
|
||||||
|
excludeMode: 'edit',
|
||||||
|
ngClick: 'lookUpOrganization()',
|
||||||
|
awRequiredWhen: {variable: "organizationrequired", init: "true" },
|
||||||
|
awPopOver: '<p>A project must have at least one organization. Pick one organization now to create the project, and then after ' +
|
||||||
|
'the project is created you can add additional organizations.' ,
|
||||||
|
dataTitle: 'Organization',
|
||||||
|
dataPlacement: 'right'
|
||||||
|
},
|
||||||
base_dir: {
|
base_dir: {
|
||||||
label: 'Project Base Path',
|
label: 'Project Base Path',
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
@@ -103,14 +118,14 @@ angular.module('ProjectFormDefinition', [])
|
|||||||
label: 'Edit',
|
label: 'Edit',
|
||||||
ngClick: "edit('organizations', \{\{ organization.id \}\}, '\{\{ organization.name \}\}')",
|
ngClick: "edit('organizations', \{\{ organization.id \}\}, '\{\{ organization.name \}\}')",
|
||||||
icon: 'icon-edit',
|
icon: 'icon-edit',
|
||||||
awToolTip: 'Edit the credential'
|
awToolTip: 'Edit the organization'
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
label: 'Delete',
|
label: 'Delete',
|
||||||
ngClick: "delete('organizations', \{\{ organization.id \}\}, '\{\{ organization.name \}\}', 'organizations')",
|
ngClick: "delete('organizations', \{\{ organization.id \}\}, '\{\{ organization.name \}\}', 'organizations')",
|
||||||
icon: 'icon-remove',
|
icon: 'icon-remove',
|
||||||
"class": 'btn-danger',
|
"class": 'btn-danger',
|
||||||
awToolTip: 'Delete the credential'
|
awToolTip: 'Delete the organization'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user