mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 20:51:21 -03:30
AC-303 Adding a project now requires an Organization.
This commit is contained in:
parent
37e7eb83d6
commit
5842fb1158
@ -72,7 +72,7 @@ ProjectsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routePar
|
||||
|
||||
function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, ProjectsForm,
|
||||
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
|
||||
//scope.
|
||||
@ -90,6 +90,14 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
LoadBreadCrumbs();
|
||||
GetProjectPath({ scope: scope, master: master });
|
||||
|
||||
LookUpInit({
|
||||
scope: scope,
|
||||
form: form,
|
||||
current_item: null,
|
||||
list: OrganizationList,
|
||||
field: 'organization'
|
||||
});
|
||||
|
||||
// Save
|
||||
scope.formSave = function() {
|
||||
var data = {};
|
||||
@ -100,12 +108,23 @@ function ProjectsAdd ($scope, $rootScope, $compile, $location, $log, $routeParam
|
||||
Rest.setUrl(url);
|
||||
Rest.post(data)
|
||||
.success( function(data, status, headers, config) {
|
||||
$rootScope.flashMessage = "New project successfully created!";
|
||||
(base == 'projects') ? ReturnToCaller() : ReturnToCaller(1);
|
||||
var id = data.id;
|
||||
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) {
|
||||
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',
|
||||
'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath',
|
||||
'ReturnToCaller', 'GetProjectPath'
|
||||
'ReturnToCaller', 'GetProjectPath', 'LookUpInit', 'OrganizationList'
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
* Credentials.js
|
||||
* Form definition for Credential model
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
angular.module('CredentialFormDefinition', [])
|
||||
.value(
|
||||
|
||||
@ -30,6 +30,21 @@ angular.module('ProjectFormDefinition', [])
|
||||
addRequired: 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: {
|
||||
label: 'Project Base Path',
|
||||
type: 'textarea',
|
||||
@ -103,14 +118,14 @@ angular.module('ProjectFormDefinition', [])
|
||||
label: 'Edit',
|
||||
ngClick: "edit('organizations', \{\{ organization.id \}\}, '\{\{ organization.name \}\}')",
|
||||
icon: 'icon-edit',
|
||||
awToolTip: 'Edit the credential'
|
||||
awToolTip: 'Edit the organization'
|
||||
},
|
||||
"delete": {
|
||||
label: 'Delete',
|
||||
ngClick: "delete('organizations', \{\{ organization.id \}\}, '\{\{ organization.name \}\}', 'organizations')",
|
||||
icon: 'icon-remove',
|
||||
"class": 'btn-danger',
|
||||
awToolTip: 'Delete the credential'
|
||||
awToolTip: 'Delete the organization'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user