From c9325b6a78fe18c30d529800c63ab9ec5a31ff0b Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Mon, 13 May 2019 21:24:28 +0200 Subject: [PATCH] fix(admin-ui): Reset page when filters changed in product list --- .../components/product-list/product-list.component.ts | 4 ++-- admin-ui/src/app/common/base-list.component.ts | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/admin-ui/src/app/catalog/components/product-list/product-list.component.ts b/admin-ui/src/app/catalog/components/product-list/product-list.component.ts index 350bcab94d..c5ad9bcea1 100644 --- a/admin-ui/src/app/catalog/components/product-list/product-list.component.ts +++ b/admin-ui/src/app/catalog/components/product-list/product-list.component.ts @@ -79,13 +79,13 @@ export class ProductListComponent setSearchTerm(term: string) { this.searchTerm = term; - this.setQueryParam('q', term || null); + this.setQueryParam({ q: term || null, page: 1 }); this.refresh(); } setFacetValueIds(ids: string[]) { this.facetValueIds = ids; - this.setQueryParam('fvids', ids); + this.setQueryParam({ fvids: ids, page: 1 }); this.refresh(); } diff --git a/admin-ui/src/app/common/base-list.component.ts b/admin-ui/src/app/common/base-list.component.ts index 62ab7bae69..56a00f1613 100644 --- a/admin-ui/src/app/common/base-list.component.ts +++ b/admin-ui/src/app/common/base-list.component.ts @@ -93,9 +93,11 @@ export class BaseListComponent impleme this.refresh$.next(undefined); } - protected setQueryParam(key: string, value: any) { + protected setQueryParam(hash: { [key: string]: any }); + protected setQueryParam(key: string, value: any); + protected setQueryParam(keyOrHash: string | { [key: string]: any }, value?: any) { this.router.navigate(['./'], { - queryParams: { [key]: value }, + queryParams: typeof keyOrHash === 'string' ? { [keyOrHash]: value } : keyOrHash, relativeTo: this.route, queryParamsHandling: 'merge', });