Browse Source

fix(admin-ui): Reset page when filters changed in product list

Michael Bromley 6 years ago
parent
commit
c9325b6a78

+ 2 - 2
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();
     }
 

+ 4 - 2
admin-ui/src/app/common/base-list.component.ts

@@ -93,9 +93,11 @@ export class BaseListComponent<ResultType, ItemType, VariableType = any> 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',
         });