Remove matrix URL notation in PaginationComponent

This commit is contained in:
Giuseppe Digilio
2017-06-12 16:35:14 +02:00
parent d4b7f5f9ce
commit e3778afd45
3 changed files with 14 additions and 12 deletions

View File

@@ -57,6 +57,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* Current page.
*/
public currentPage = 1;
public currentQueryParams = {};
/**
* An observable of HostWindowState type
@@ -121,14 +122,15 @@ export class PaginationComponent implements OnDestroy, OnInit {
this.pageSize = this.paginationOptions.pageSize;
this.pageSizeOptions = this.paginationOptions.pageSizeOptions;
this.routeSubscription = this.route.params
.map(params => params)
.subscribe(params => {
if(this.id == params['pageId']
&& (this.paginationOptions.currentPage != params['page']
|| this.paginationOptions.pageSize != params['pageSize'])
this.routeSubscription = this.route.queryParams
.map(queryParams => queryParams)
.subscribe(queryParams => {
this.currentQueryParams = queryParams;
if(this.id == queryParams['pageId']
&& (this.paginationOptions.currentPage != queryParams['page']
|| this.paginationOptions.pageSize != queryParams['pageSize'])
) {
this.validateParams(params['page'], params['pageSize']);
this.validateParams(queryParams['page'], queryParams['pageSize']);
}
});
this.setShowingDetail();
@@ -162,7 +164,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* The page being navigated to.
*/
public doPageChange(page: number) {
this.router.navigate([{ pageId: this.id, page: page, pageSize: this.pageSize }]);
this.router.navigate([], { queryParams: Object.assign({}, this.currentQueryParams, { pageId: this.id, page: page, pageSize: this.pageSize }) });
this.currentPage = page;
this.setShowingDetail();
this.pageChange.emit(page);
@@ -175,7 +177,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
* The new page size.
*/
public setPageSize(pageSize: number) {
this.router.navigate([{ pageId: this.id, page: this.currentPage, pageSize: pageSize }]);
this.router.navigate([], { queryParams: Object.assign({}, this.currentQueryParams, { pageId: this.id, page: this.currentPage, pageSize: pageSize }) });
this.pageSize = pageSize;
this.setShowingDetail();
this.pageSizeChange.emit(pageSize);