Copy/move groups/host route config and search init (#4396)

* beginning of fixing copy-move-groups

* Configure copy-move group route, initialize search in copy-move-group controller, fix stateExtender squashing

* Hook up copy-move-hosts route/controller, use generic "copy_search" as search parameter name

* lint

* fixes 400 error on copy group route
This commit is contained in:
Leigh Johnson
2016-12-15 14:53:38 -05:00
committed by GitHub
parent f77949b4b0
commit f8d75554b3
6 changed files with 72 additions and 61 deletions

View File

@@ -5,10 +5,10 @@
*************************************************/ *************************************************/
export default export default
['$scope', '$state', '$stateParams', 'generateList', 'GroupManageService', 'GetBasePath', 'CopyMoveGroupList', 'group', ['$scope', '$state', '$stateParams', 'GroupManageService', 'GetBasePath', 'CopyMoveGroupList', 'group', 'Dataset',
function($scope, $state, $stateParams, GenerateList, GroupManageService, GetBasePath, CopyMoveGroupList, group){ function($scope, $state, $stateParams, GroupManageService, GetBasePath, CopyMoveGroupList, group, Dataset){
var list = CopyMoveGroupList, var list = CopyMoveGroupList;
view = GenerateList;
$scope.item = group; $scope.item = group;
$scope.submitMode = $stateParams.groups === undefined ? 'move' : 'copy'; $scope.submitMode = $stateParams.groups === undefined ? 'move' : 'copy';
$scope['toggle_'+ list.iterator] = function(id){ $scope['toggle_'+ list.iterator] = function(id){
@@ -58,33 +58,18 @@
$(el).prop('disabled', (idx, value) => !value); $(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 function init(){
// SearchInit({ var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/';
// scope: $scope, url += $stateParams.group ? '?not__id__in=' + group.id + ',' + _.last($stateParams.group) : '?not__id=' + group.id;
// set: list.name, list.basePath = url;
// list: list, $scope.atRootLevel = $stateParams.group ? false : true;
// url: url
// }); // search init
// PaginateInit({ $scope.list = list;
// scope: $scope, $scope[`${list.iterator}_dataset`] = Dataset.data;
// list: list, $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
// url : url, }
// mode: 'lookup'
// });
// $scope.search(list.iterator, null, true, false);
// remove the current group from list
};
init(); init();
}]; }];

View File

@@ -5,10 +5,10 @@
*************************************************/ *************************************************/
export default export default
['$scope', '$state', '$stateParams', 'generateList', 'HostManageService', 'GetBasePath', 'CopyMoveGroupList', 'host', ['$scope', '$state', '$stateParams', 'generateList', 'HostManageService', 'GetBasePath', 'CopyMoveGroupList', 'host', 'Dataset',
function($scope, $state, $stateParams, GenerateList, HostManageService, GetBasePath, CopyMoveGroupList, host){ function($scope, $state, $stateParams, GenerateList, HostManageService, GetBasePath, CopyMoveGroupList, host, Dataset){
var list = CopyMoveGroupList, var list = CopyMoveGroupList;
view = GenerateList;
$scope.item = host; $scope.item = host;
$scope.submitMode = 'copy'; $scope.submitMode = 'copy';
$scope['toggle_'+ list.iterator] = function(id){ $scope['toggle_'+ list.iterator] = function(id){
@@ -40,29 +40,11 @@
} }
}; };
var init = function(){ var init = function(){
var url = GetBasePath('inventory') + $stateParams.inventory_id + '/groups/'; // search init
list.basePath = url; $scope.list = list;
view.inject(list, { $scope[`${list.iterator}_dataset`] = Dataset.data;
mode: 'lookup', $scope[list.name] = $scope[`${list.iterator}_dataset`].results;
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);
}; };
init(); init();
}]; }];

View File

@@ -10,7 +10,7 @@
<input type="radio" ng-model="submitMode" value="move" class="ng-pristine ng-untouched ng-valid"> Move <input type="radio" ng-model="submitMode" value="move" class="ng-pristine ng-untouched ng-valid"> Move
</label> </label>
</div> </div>
<div id="copyMove-list"></div> <div id="copyMove-list" ui-view="copyMoveList"></div>
<div class="copyMove-root form-group pull-left" ng-hide="atRootLevel"> <div class="copyMove-root form-group pull-left" ng-hide="atRootLevel">
<span><input type="checkbox" ng-model="targetRootGroup" ng-change="toggleTargetRootGroup()"> Use the inventory root</span> <span><input type="checkbox" ng-model="targetRootGroup" ng-change="toggleTargetRootGroup()"> Use the inventory root</span>
</div> </div>

View File

@@ -10,14 +10,31 @@ import CopyMoveHostsController from './copy-move-hosts.controller';
var copyMoveGroupRoute = { var copyMoveGroupRoute = {
name: 'inventoryManage.copyMoveGroup', name: 'inventoryManage.copyMoveGroup',
url: '/copy-move-group/{group_id}', url: '/copy-move-group/{group_id:int}',
searchPrefix: 'copy',
data: { data: {
group_id: 'group_id', group_id: 'group_id',
}, },
params: {
copy_search: {
value: {
not__id__in: null
},
dynamic: true,
squash: ''
}
},
ncyBreadcrumb: { ncyBreadcrumb: {
label: "COPY OR MOVE {{item.name}}" label: "COPY OR MOVE {{item.name}}"
}, },
resolve: { 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){ group: ['GroupManageService', '$stateParams', function(GroupManageService, $stateParams){
return GroupManageService.get({id: $stateParams.group_id}).then(res => res.data.results[0]); return GroupManageService.get({id: $stateParams.group_id}).then(res => res.data.results[0]);
}] }]
@@ -26,16 +43,33 @@ var copyMoveGroupRoute = {
'form@inventoryManage' : { 'form@inventoryManage' : {
controller: CopyMoveGroupsController, controller: CopyMoveGroupsController,
templateUrl: templateUrl('inventories/manage/copy-move/copy-move'), 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 = { var copyMoveHostRoute = {
name: 'inventoryManage.copyMoveHost', name: 'inventoryManage.copyMoveHost',
url: '/copy-move-host/{host_id}', url: '/copy-move-host/{host_id}',
searchPrefix: 'copy',
ncyBreadcrumb: { ncyBreadcrumb: {
label: "COPY OR MOVE {{item.name}}" label: "COPY OR MOVE {{item.name}}"
}, },
resolve: { 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){ host: ['HostManageService', '$stateParams', function(HostManageService, $stateParams){
return HostManageService.get({id: $stateParams.host_id}).then(res => res.data.results[0]); return HostManageService.get({id: $stateParams.host_id}).then(res => res.data.results[0]);
}] }]
@@ -44,6 +78,16 @@ var copyMoveHostRoute = {
'form@inventoryManage': { 'form@inventoryManage': {
templateUrl: templateUrl('inventories/manage/copy-move/copy-move'), templateUrl: templateUrl('inventories/manage/copy-move/copy-move'),
controller: CopyMoveHostsController, controller: CopyMoveHostsController,
},
'copyMoveList@inventoryManage.copyMoveHost': {
templateProvider: function(CopyMoveGroupList, generateList) {
let html = generateList.build({
list: CopyMoveGroupList,
mode: 'lookup',
input_type: 'radio'
});
return html;
}
} }
} }
}; };

View File

@@ -12,7 +12,7 @@ export default
.value('CopyMoveGroupList', { .value('CopyMoveGroupList', {
name: 'groups', name: 'groups',
iterator: 'group', iterator: 'copy',
selectTitle: 'Copy Groups', selectTitle: 'Copy Groups',
index: false, index: false,
well: false, well: false,

View File

@@ -31,7 +31,7 @@ export default function($stateProvider) {
order_by: "name" order_by: "name"
}, },
dynamic: true, dynamic: true,
squash: true squash: ''
} }
} }
}; };