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
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 17 additions and 2 deletions

View File

@ -13,6 +13,7 @@ function projectsListController (
) {
const vm = this || {};
const [ProjectModel] = resolvedModels;
let paginateQuerySet = null;
$scope.canAdd = ProjectModel.options('actions.POST');
vm.strings = strings;
@ -75,14 +76,28 @@ function projectsListController (
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.toolbarSortValue = sort;
const queryParams = Object.assign(
{},
$state.params.project_search,
paginateQuerySet,
{ order_by: sort.value }
);
// Update URL with params
$state.go('.', {
project_search: queryParams
}, { notify: false, location: 'replace' });
qs.search(GetBasePath(vm.list.basePath), queryParams)
.then(({ data }) => {
vm.dataset = data;

View File

@ -55,7 +55,7 @@ export default ['$scope', '$stateParams', '$state', '$filter', 'GetBasePath', 'Q
}
$scope.dataset = res.data;
$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: '=',
iterator: '@',
basePath: '@',
querySet: '=',
querySet: '=?',
maxVisiblePages: '@',
hideViewPerPage: '='
},