From 79125e16af2adaec8db62ad73827f3e1bec8b4f3 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Wed, 4 Jun 2014 13:53:08 -0400 Subject: [PATCH] Inventory Group Delete The new delete method wasn't completely implemented. Still some old tree stuff and discarded endpoints lingergin' about. --- awx/ui/static/js/helpers/Groups.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index 778bbe87d1..f21a4e0df6 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -1237,8 +1237,8 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched return function (params) { var scope = params.scope, - tree_id = params.tree_id, - node = Find({ list: scope.groups, key: 'id', val: tree_id }), + group_id = params.group_id, + node = Find({ list: scope.groups, key: 'id', val: group_id }), hosts = [], groups = [], childCount = 0, @@ -1357,16 +1357,16 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched scope.removeDisassociateGroup(); } scope.removeDisassociateGroup = scope.$on('DisassociateGroup', function() { - var data, parent, url; - if (node.parent === 0) { - url = GetBasePath('inventory') + scope.inventory_id + '/groups/'; - data = { id: node.group_id, disassociate: 1 }; + var data, url; + if (!scope.selected_group_id) { + url = GetBasePath('inventory') + scope.inventory.id + '/groups/'; + data = { id: node.id, disassociate: 1 }; } else { - parent = Find({ list: scope.groups, key: 'id', val: node.parent }); - url = GetBasePath('groups') + parent.group_id + '/children/' + node.group_id + '/'; - data = { disassociate: 'all' }; + url = GetBasePath('groups') + node.id + '/children/'; + data = { disassociate: 1 }; } + Rest.setUrl(url); Rest.post(data) .success(function () { @@ -1383,15 +1383,7 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched scope.removeDeleteGroup(); } scope.removeDeleteGroup = scope.$on('DeleteGroup', function() { - var parent, url; - 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 + '/'; - } + var url = GetBasePath('groups') + node.id + '/'; Rest.setUrl(url); Rest.destroy() .success( function() {