Update URL params when sorting on projects list

This commit is contained in:
Marliana Lara
2019-03-05 15:08:24 -05:00
parent aad185e785
commit 970a714291
3 changed files with 17 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ function projectsListController (
) { ) {
const vm = this || {}; const vm = this || {};
const [ProjectModel] = resolvedModels; const [ProjectModel] = resolvedModels;
let paginateQuerySet = null;
$scope.canAdd = ProjectModel.options('actions.POST'); $scope.canAdd = ProjectModel.options('actions.POST');
vm.strings = strings; vm.strings = strings;
@@ -75,14 +76,28 @@ function projectsListController (
vm.toolbarSortValue = toolbarSortDefault; vm.toolbarSortValue = toolbarSortDefault;
// Temporary hack to retrieve $scope.querySet from the paginate directive.
// Remove this event listener once the page and page_size params
// are represented in the url.
$scope.$on('updateDataset', (event, dataset, queryset) => {
paginateQuerySet = queryset;
});
vm.onToolbarSort = (sort) => { vm.onToolbarSort = (sort) => {
vm.toolbarSortValue = sort; vm.toolbarSortValue = sort;
const queryParams = Object.assign( const queryParams = Object.assign(
{},
$state.params.project_search, $state.params.project_search,
paginateQuerySet,
{ order_by: sort.value } { order_by: sort.value }
); );
// Update URL with params
$state.go('.', {
project_search: queryParams
}, { notify: false, location: 'replace' });
qs.search(GetBasePath(vm.list.basePath), queryParams) qs.search(GetBasePath(vm.list.basePath), queryParams)
.then(({ data }) => { .then(({ data }) => {
vm.dataset = data; vm.dataset = data;

View File

@@ -55,7 +55,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
} }
$scope.dataset = res.data; $scope.dataset = res.data;
$scope.collection = res.data.results; $scope.collection = res.data.results;
$scope.$emit('updateDataset', res.data); $scope.$emit('updateDataset', res.data, queryset);
}); });
}; };

View File

@@ -8,7 +8,7 @@ export default ['templateUrl',
dataset: '=', dataset: '=',
iterator: '@', iterator: '@',
basePath: '@', basePath: '@',
querySet: '=', querySet: '=?',
maxVisiblePages: '@', maxVisiblePages: '@',
hideViewPerPage: '=' hideViewPerPage: '='
}, },