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 37af28407b..9231e7a5b2 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 @@ -5,10 +5,10 @@ *************************************************/ export default - ['$scope', '$state', '$stateParams', 'generateList', 'GroupManageService', 'GetBasePath', 'CopyMoveGroupList', 'group', - function($scope, $state, $stateParams, GenerateList, GroupManageService, GetBasePath, CopyMoveGroupList, group){ - var list = CopyMoveGroupList, - view = GenerateList; + ['$scope', '$state', '$stateParams', 'GroupManageService', 'GetBasePath', 'CopyMoveGroupList', 'group', 'Dataset', + function($scope, $state, $stateParams, GroupManageService, GetBasePath, CopyMoveGroupList, group, Dataset){ + var list = CopyMoveGroupList; + $scope.item = group; $scope.submitMode = $stateParams.groups === undefined ? 'move' : 'copy'; $scope['toggle_'+ list.iterator] = function(id){ @@ -58,33 +58,18 @@ $(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', - scope: $scope, - input_type: 'radio' - }); - // @issue: OLD SEARCH - // SearchInit({ - // scope: $scope, - // set: list.name, - // list: list, - // url: url - // }); - // PaginateInit({ - // scope: $scope, - // list: list, - // url : url, - // mode: 'lookup' - // }); - // $scope.search(list.iterator, null, true, false); - // remove the current group from list - }; + function init(){ + 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; + + // search init + $scope.list = list; + $scope[`${list.iterator}_dataset`] = Dataset.data; + $scope[list.name] = $scope[`${list.iterator}_dataset`].results; + } + init(); }]; 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 9d278fde69..a01387c173 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 @@ -5,10 +5,10 @@ *************************************************/ export default - ['$scope', '$state', '$stateParams', 'generateList', 'HostManageService', 'GetBasePath', 'CopyMoveGroupList', 'host', - function($scope, $state, $stateParams, GenerateList, HostManageService, GetBasePath, CopyMoveGroupList, host){ - var list = CopyMoveGroupList, - view = GenerateList; + ['$scope', '$state', '$stateParams', 'generateList', 'HostManageService', 'GetBasePath', 'CopyMoveGroupList', 'host', 'Dataset', + function($scope, $state, $stateParams, GenerateList, HostManageService, GetBasePath, CopyMoveGroupList, host, Dataset){ + var list = CopyMoveGroupList; + $scope.item = host; $scope.submitMode = 'copy'; $scope['toggle_'+ list.iterator] = function(id){ @@ -40,29 +40,11 @@ } }; var init = function(){ - var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/'; - list.basePath = url; - view.inject(list, { - mode: 'lookup', - id: 'copyMove-list', - scope: $scope, - input_type: 'radio' - }); + // search init + $scope.list = list; + $scope[`${list.iterator}_dataset`] = Dataset.data; + $scope[list.name] = $scope[`${list.iterator}_dataset`].results; - // @issue: OLD SEARCH - // SearchInit({ - // scope: $scope, - // set: list.name, - // list: list, - // url: url - // }); - // PaginateInit({ - // scope: $scope, - // list: list, - // url : url, - // mode: 'lookup' - // }); - // $scope.search(list.iterator, null, true, false); }; init(); }]; 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 1847837b92..030f0c7e3a 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 @@ -10,7 +10,7 @@ Move -
+
Use the inventory root
diff --git a/awx/ui/client/src/inventories/manage/copy-move/copy-move.route.js b/awx/ui/client/src/inventories/manage/copy-move/copy-move.route.js index 6e2c190e3f..f15705778d 100644 --- a/awx/ui/client/src/inventories/manage/copy-move/copy-move.route.js +++ b/awx/ui/client/src/inventories/manage/copy-move/copy-move.route.js @@ -10,14 +10,31 @@ import CopyMoveHostsController from './copy-move-hosts.controller'; var copyMoveGroupRoute = { name: 'inventoryManage.copyMoveGroup', - url: '/copy-move-group/{group_id}', + url: '/copy-move-group/{group_id:int}', + searchPrefix: 'copy', data: { group_id: 'group_id', }, + params: { + copy_search: { + value: { + not__id__in: null + }, + dynamic: true, + squash: '' + } + }, ncyBreadcrumb: { label: "COPY OR MOVE {{item.name}}" }, resolve: { + Dataset: ['CopyMoveGroupList', 'QuerySet', '$stateParams', 'GetBasePath', 'group', + function(list, qs, $stateParams, GetBasePath, group) { + $stateParams.copy_search.not__id__in = ($stateParams.group.length > 0 ? group.id + ',' + _.last($stateParams.group) : group.id); + let path = GetBasePath(list.name); + return qs.search(path, $stateParams.copy_search); + } + ], group: ['GroupManageService', '$stateParams', function(GroupManageService, $stateParams){ return GroupManageService.get({id: $stateParams.group_id}).then(res => res.data.results[0]); }] @@ -26,16 +43,33 @@ var copyMoveGroupRoute = { 'form@inventoryManage' : { controller: CopyMoveGroupsController, templateUrl: templateUrl('inventories/manage/copy-move/copy-move'), + }, + 'copyMoveList@inventoryManage.copyMoveGroup': { + templateProvider: function(CopyMoveGroupList, generateList) { + let html = generateList.build({ + list: CopyMoveGroupList, + mode: 'lookup', + input_type: 'radio' + }); + return html; + } } } }; var copyMoveHostRoute = { name: 'inventoryManage.copyMoveHost', url: '/copy-move-host/{host_id}', + searchPrefix: 'copy', ncyBreadcrumb: { label: "COPY OR MOVE {{item.name}}" }, resolve: { + Dataset: ['CopyMoveGroupList', 'QuerySet', '$stateParams', 'GetBasePath', + function(list, qs, $stateParams, GetBasePath) { + let path = GetBasePath(list.name); + return qs.search(path, $stateParams.copy_search); + } + ], host: ['HostManageService', '$stateParams', function(HostManageService, $stateParams){ return HostManageService.get({id: $stateParams.host_id}).then(res => res.data.results[0]); }] @@ -44,6 +78,16 @@ var copyMoveHostRoute = { 'form@inventoryManage': { templateUrl: templateUrl('inventories/manage/copy-move/copy-move'), controller: CopyMoveHostsController, + }, + 'copyMoveList@inventoryManage.copyMoveHost': { + templateProvider: function(CopyMoveGroupList, generateList) { + let html = generateList.build({ + list: CopyMoveGroupList, + mode: 'lookup', + input_type: 'radio' + }); + return html; + } } } }; diff --git a/awx/ui/client/src/lists/Groups.js b/awx/ui/client/src/lists/Groups.js index 072c35f9a3..0bfc6a9f3f 100644 --- a/awx/ui/client/src/lists/Groups.js +++ b/awx/ui/client/src/lists/Groups.js @@ -12,7 +12,7 @@ export default .value('CopyMoveGroupList', { name: 'groups', - iterator: 'group', + iterator: 'copy', selectTitle: 'Copy Groups', index: false, well: false, diff --git a/awx/ui/client/src/shared/stateExtender.provider.js b/awx/ui/client/src/shared/stateExtender.provider.js index da8b34fbee..f9534c2665 100644 --- a/awx/ui/client/src/shared/stateExtender.provider.js +++ b/awx/ui/client/src/shared/stateExtender.provider.js @@ -31,7 +31,7 @@ export default function($stateProvider) { order_by: "name" }, dynamic: true, - squash: true + squash: '' } } };