Merge pull request #4728 from mabashian/4027-inventory-groups-pagination

Generate the correct base path for groups and hosts so that paginate works properly
This commit is contained in:
Michael Abashian 2017-01-14 08:33:51 -05:00 committed by GitHub
commit 67b9960d5a
2 changed files with 22 additions and 6 deletions

View File

@ -98,9 +98,17 @@ export default {
},
// target ui-views with name@inventoryManage state
'groupsList@inventoryManage': {
templateProvider: function(InventoryGroups, generateList, $templateRequest) {
templateProvider: function(InventoryGroups, generateList, $templateRequest, $stateParams, GetBasePath) {
let list = _.cloneDeep(InventoryGroups);
if($stateParams && $stateParams.group) {
list.basePath = GetBasePath('groups') + _.last($stateParams.group) + '/children';
}
else {
//reaches here if the user is on the root level group
list.basePath = GetBasePath('inventory') + $stateParams.inventory_id + '/root_groups';
}
let html = generateList.build({
list: InventoryGroups,
list: list,
mode: 'edit'
});
html = generateList.wrapPanel(html);
@ -112,9 +120,17 @@ export default {
controller: GroupsListController
},
'hostsList@inventoryManage': {
templateProvider: function(InventoryHosts, generateList) {
templateProvider: function(InventoryHosts, generateList, $stateParams, GetBasePath) {
let list = _.cloneDeep(InventoryHosts);
if($stateParams && $stateParams.group) {
list.basePath = GetBasePath('groups') + _.last($stateParams.group) + '/all_hosts';
}
else {
//reaches here if the user is on the root level group
list.basePath = GetBasePath('inventory') + $stateParams.inventory_id + '/hosts';
}
let html = generateList.build({
list: InventoryHosts,
list: list,
mode: 'edit'
});
return generateList.wrapPanel(html);

View File

@ -18,7 +18,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
return;
}
path = GetBasePath($scope.basePath) || $scope.basePath;
queryset = _.merge($stateParams[`${$scope.iterator}_search`], { page: page.toString() });
queryset = _.merge($stateParams[`${$scope.iterator}_search`], { page: page });
$state.go('.', {
[$scope.iterator + '_search']: queryset
});
@ -59,7 +59,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
return `1 - ${pageSize}`;
} else {
let floor = (($scope.current() - 1) * parseInt(pageSize)) + 1;
let ceil = floor + parseInt(pageSize);
let ceil = floor + parseInt(pageSize) < $scope.dataset.count ? floor + parseInt(pageSize) : $scope.dataset.count;
return `${floor} - ${ceil}`;
}
}