diff --git a/awx/ui/client/src/inventories/manage/copy-move/copy-move-groups.controller.js b/awx/ui/client/src/inventories/manage/copy-move/copy-move-groups.controller.js index 90ce9c5fda..0ae7afb857 100644 --- a/awx/ui/client/src/inventories/manage/copy-move/copy-move-groups.controller.js +++ b/awx/ui/client/src/inventories/manage/copy-move/copy-move-groups.controller.js @@ -26,24 +26,43 @@ GroupManageService.associateGroup(group, $scope.selected.id).then(() => $state.go('^', null, {reload: true})); break; case 'move': - // at the root group level, no dissassociation is needed - if (!$stateParams.group){ - GroupManageService.associateGroup(group, $scope.selected.id).then(() => $state.go('^', null, {reload: true})); - } - else{ - // unsure if orphaned resources get garbage collected, safe bet is to associate before disassociate - GroupManageService.associateGroup(group, $scope.selected.id).then(() => { - GroupManageService.disassociateGroup(group, _.last($stateParams.group)) - .then(() => $state.go('^', null, {reload: true})); - }); + switch($scope.targetRootGroup){ + case true: + // disassociating group will bubble it to the root group level + GroupManageService.disassociateGroup(group.id, _.last($stateParams.group)).then(() => $state.go('^', null, {reload: true})); + break; + default: + // at the root group level, no dissassociation is needed + if (!$stateParams.group){ + GroupManageService.associateGroup(group, $scope.selected.id).then(() => $state.go('^', null, {reload: true})); + } + else{ + // unsure if orphaned resources get garbage collected, safe bet is to associate before disassociate + GroupManageService.associateGroup(group, $scope.selected.id).then(() => { + GroupManageService.disassociateGroup(group.id, _.last($stateParams.group)) + .then(() => $state.go('^', null, {reload: true})); + }); + } + break; } - break; } }; + $scope.toggleTargetRootGroup = function(){ + $scope.selected = !$scope.selected; + // cannot perform copy operations to root group level + $scope.submitMode = 'move'; + // toggle off anything currently selected in the list, for clarity + _.forEach($scope.groups, (item) => {item.checked = null;}); + // disable list selections + $('#copyMove-list :input').each((idx, el) => { + $(el).prop('disabled', (idx, value) => !value); + }); + }; var init = function(){ var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/'; url += $stateParams.group ? '?not__id__in=' + group.id + ',' + _.last($stateParams.group) : '?not__id=' + group.id; list.basePath = url; + $scope.atRootLevel = $stateParams.group ? false : true; view.inject(list, { mode: 'lookup', id: 'copyMove-list', @@ -65,4 +84,4 @@ // remove the current group from list }; init(); - }]; \ No newline at end of file + }]; diff --git a/awx/ui/client/src/inventories/manage/copy-move/copy-move-hosts.controller.js b/awx/ui/client/src/inventories/manage/copy-move/copy-move-hosts.controller.js index 14774de3ba..f04346f775 100644 --- a/awx/ui/client/src/inventories/manage/copy-move/copy-move-hosts.controller.js +++ b/awx/ui/client/src/inventories/manage/copy-move/copy-move-hosts.controller.js @@ -34,7 +34,7 @@ HostManageService.associateGroup(host, $scope.selected.id).then(() => { HostManageService.disassociateGroup(host, _.last($stateParams.group)) .then(() => $state.go('^', null, {reload: true})); - }); + }); } break; } @@ -62,4 +62,4 @@ $scope.search(list.iterator, null, true, false); }; init(); - }]; \ No newline at end of file + }]; diff --git a/awx/ui/client/src/inventories/manage/copy-move/copy-move.block.less b/awx/ui/client/src/inventories/manage/copy-move/copy-move.block.less index 76bdc2724c..aa865c165b 100644 --- a/awx/ui/client/src/inventories/manage/copy-move/copy-move.block.less +++ b/awx/ui/client/src/inventories/manage/copy-move/copy-move.block.less @@ -23,4 +23,7 @@ .copyMove-buttons{ height: 30px; margin-top: 10px; -} \ No newline at end of file +} +.copyMove-root{ + margin-top: 10px; +} diff --git a/awx/ui/client/src/inventories/manage/copy-move/copy-move.partial.html b/awx/ui/client/src/inventories/manage/copy-move/copy-move.partial.html index a148985287..39a87a729f 100644 --- a/awx/ui/client/src/inventories/manage/copy-move/copy-move.partial.html +++ b/awx/ui/client/src/inventories/manage/copy-move/copy-move.partial.html @@ -2,16 +2,18 @@