1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

AC-234 create organizaions via Projects Tab

This commit is contained in:
chouseknecht 2013-07-19 11:00:55 -04:00
parent 22e1a1ae72
commit 549ba9a150
2 changed files with 15 additions and 4 deletions

View File

@ -101,6 +101,9 @@ angular.module('ansible', [
when('/projects/:project_id/organizations',
{ templateUrl: urlPrefix + 'partials/projects.html', controller: OrganizationsList }).
when('/projects/:project_id/organizations/add',
{ templateUrl: urlPrefix + 'partials/projects.html', controller: OrganizationsAdd }).
when('/inventories',
{ templateUrl: urlPrefix + 'partials/inventories.html', controller: InventoriesList }).

View File

@ -138,6 +138,7 @@ function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $route
// Inject dynamic view
var form = GenerateForm;
var scope = form.inject(OrganizationForm, {mode: 'add', related: false});
var base = $location.path().replace(/^\//,'').split('/')[0];
var defaultUrl = GetBasePath('organizations');
form.reset();
@ -145,12 +146,19 @@ function OrganizationsAdd ($scope, $rootScope, $compile, $location, $log, $route
// Save
scope.formSave = function() {
Rest.setUrl(defaultUrl);
var url = GetBasePath(base);
url += (base != 'organizations') ? $routeParams['project_id'] + '/organizations/' : '';
Rest.setUrl(url);
Rest.post({ name: $scope.name,
description: $scope.description })
.success( function(data, status, headers, config) {
$rootScope.flashMessage = "New organization successfully created!";
$location.path('/organizations/' + data.id);
.success( function(data, status, headers, config) {
if (base == 'organizations') {
$rootScope.flashMessage = "New organization successfully created!";
$location.path('/organizations/' + data.id);
}
else {
ReturnToCaller(1);
}
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, OrganizationForm,