Inventory Group Delete

The new delete method wasn't completely implemented. Still some old tree stuff and discarded endpoints lingergin' about.
This commit is contained in:
Chris Houseknecht
2014-06-04 13:53:08 -04:00
parent da766edd52
commit 79125e16af

View File

@@ -1237,8 +1237,8 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
return function (params) { return function (params) {
var scope = params.scope, var scope = params.scope,
tree_id = params.tree_id, group_id = params.group_id,
node = Find({ list: scope.groups, key: 'id', val: tree_id }), node = Find({ list: scope.groups, key: 'id', val: group_id }),
hosts = [], hosts = [],
groups = [], groups = [],
childCount = 0, childCount = 0,
@@ -1357,16 +1357,16 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
scope.removeDisassociateGroup(); scope.removeDisassociateGroup();
} }
scope.removeDisassociateGroup = scope.$on('DisassociateGroup', function() { scope.removeDisassociateGroup = scope.$on('DisassociateGroup', function() {
var data, parent, url; var data, url;
if (node.parent === 0) { if (!scope.selected_group_id) {
url = GetBasePath('inventory') + scope.inventory_id + '/groups/'; url = GetBasePath('inventory') + scope.inventory.id + '/groups/';
data = { id: node.group_id, disassociate: 1 }; data = { id: node.id, disassociate: 1 };
} }
else { else {
parent = Find({ list: scope.groups, key: 'id', val: node.parent }); url = GetBasePath('groups') + node.id + '/children/';
url = GetBasePath('groups') + parent.group_id + '/children/' + node.group_id + '/'; data = { disassociate: 1 };
data = { disassociate: 'all' };
} }
Rest.setUrl(url); Rest.setUrl(url);
Rest.post(data) Rest.post(data)
.success(function () { .success(function () {
@@ -1383,15 +1383,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
scope.removeDeleteGroup(); scope.removeDeleteGroup();
} }
scope.removeDeleteGroup = scope.$on('DeleteGroup', function() { scope.removeDeleteGroup = scope.$on('DeleteGroup', function() {
var parent, url; var url = GetBasePath('groups') + node.id + '/';
if (node.parent === 0) {
// this is a top level group
url = GetBasePath('inventory') + scope.inventory_id + '/groups/' + node.group_id + '/';
}
else {
parent = Find({ list: scope.groups, key: 'id', val: node.parent });
url = GetBasePath('groups') + parent.group_id + '/children/' + node.group_id + '/';
}
Rest.setUrl(url); Rest.setUrl(url);
Rest.destroy() Rest.destroy()
.success( function() { .success( function() {