Inventory group add/delete working

This commit is contained in:
Chris Houseknecht
2013-05-06 16:54:26 -04:00
parent 2afd8d44e7
commit bb7e1ae74f
7 changed files with 428 additions and 9 deletions

View File

@@ -69,7 +69,8 @@ HostsList.$inject = [ '$scope', '$rootScope', '$location', '$log', '$routeParams
function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams, HostForm,
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope)
GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller,
ClearScope, LookUpInventoryInit)
{
ClearScope('htmlTemplate'); //Garbage collection. Don't leave behind any listeners/watchers from the prior
//scope.
@@ -80,9 +81,27 @@ function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
var generator = GenerateForm;
var scope = generator.inject(form, {mode: 'add', related: false});
generator.reset();
var master = {};
LoadBreadCrumbs();
LookUpInventoryInit({ scope: scope });
// Load inventory lookup value
var url = defaultUrl + $routeParams.id + '/';
Rest.setUrl(url);
Rest.get()
.success( function(data, status, headers, config) {
scope['inventory'] = data.id;
master['inventory'] = data.id;
scope['inventory_name'] = data.name;
master['inventory_name'] = data.name;
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + url + '. GET status: ' + status });
});
// Save
scope.formSave = function() {
Rest.setUrl(defaultUrl + $routeParams.id + '/hosts/');
@@ -109,7 +128,7 @@ function HostsAdd ($scope, $rootScope, $compile, $location, $log, $routeParams,
}
HostsAdd.$inject = [ '$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'HostForm', 'GenerateForm',
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope' ];
'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'LookUpInventoryInit' ];
function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams, UserForm,
@@ -130,7 +149,7 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
LookUpInventoryInit({ scope: scope });
// After the Organization is loaded, retrieve each related set
// After form data loads, load related sets and lookups
scope.$on('dataLoaded', function() {
Rest.setUrl(scope['inventory_url']);
@@ -141,7 +160,7 @@ function HostsEdit ($scope, $rootScope, $compile, $location, $log, $routeParams,
})
.error( function(data, status, headers, config) {
ProcessErrors(scope, data, status, null,
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.orgnization_url + '. GET status: ' + status });
{ hdr: 'Error!', msg: 'Failed to retrieve: ' + scope.inventory_url + '. GET status: ' + status });
});
for (var set in relatedSets) {