Browse Source

fix(admin-ui): Prevent route change on collection contents list change

Relates to #1530
Michael Bromley 3 years ago
parent
commit
55896284b0

+ 6 - 3
packages/admin-ui/src/lib/catalog/src/components/collection-contents/collection-contents.component.ts

@@ -60,14 +60,14 @@ export class CollectionContentsComponent implements OnInit, OnChanges, OnDestroy
     constructor(private route: ActivatedRoute, private router: Router, private dataService: DataService) {}
 
     ngOnInit() {
-        this.contentsCurrentPage$ = this.route.paramMap.pipe(
+        this.contentsCurrentPage$ = this.route.queryParamMap.pipe(
             map(qpm => qpm.get('contentsPage')),
             map(page => (!page ? 1 : +page)),
             startWith(1),
             distinctUntilChanged(),
         );
 
-        this.contentsItemsPerPage$ = this.route.paramMap.pipe(
+        this.contentsItemsPerPage$ = this.route.queryParamMap.pipe(
             map(qpm => qpm.get('contentsPerPage')),
             map(perPage => (!perPage ? 10 : +perPage)),
             startWith(10),
@@ -167,8 +167,11 @@ export class CollectionContentsComponent implements OnInit, OnChanges, OnDestroy
     }
 
     private setParam(key: string, value: any) {
-        this.router.navigate(['./', { ...this.route.snapshot.params, [key]: value }], {
+        this.router.navigate(['./'], {
             relativeTo: this.route,
+            queryParams: {
+                [key]: value,
+            },
             queryParamsHandling: 'merge',
             replaceUrl: true,
         });

+ 3 - 3
packages/admin-ui/src/lib/catalog/src/components/collection-detail/collection-detail.component.ts

@@ -34,7 +34,7 @@ import {
 } from '@vendure/admin-ui/core';
 import { normalizeString } from '@vendure/common/lib/normalize-string';
 import { combineLatest, Observable } from 'rxjs';
-import { debounceTime, map, mergeMap, take, filter } from 'rxjs/operators';
+import { debounceTime, filter, map, mergeMap, take } from 'rxjs/operators';
 
 import { CollectionContentsComponent } from '../collection-contents/collection-contents.component';
 
@@ -101,8 +101,8 @@ export class CollectionDetailComponent
         this.destroy();
     }
 
-    getFilterDefinition(filter: ConfigurableOperation): ConfigurableOperationDefinition | undefined {
-        return this.allFilters.find(f => f.code === filter.code);
+    getFilterDefinition(_filter: ConfigurableOperation): ConfigurableOperationDefinition | undefined {
+        return this.allFilters.find(f => f.code === _filter.code);
     }
 
     assetsChanged(): boolean {

+ 0 - 1
packages/admin-ui/src/lib/core/src/common/base-detail.component.ts

@@ -9,7 +9,6 @@ import { ServerConfigService } from '../data/server-config';
 import { DeactivateAware } from './deactivate-aware';
 import { CustomFieldConfig, CustomFields, LanguageCode } from './generated-types';
 import { TranslationOf } from './utilities/find-translation';
-import { getDefaultUiLanguage } from './utilities/get-default-ui-language';
 
 /**
  * @description

+ 0 - 1
packages/admin-ui/src/lib/core/src/shared/providers/routing/can-deactivate-detail-guard.ts

@@ -17,7 +17,6 @@ export class CanDeactivateDetailGuard implements CanDeactivate<DeactivateAware>
         currentState: RouterStateSnapshot,
         nextState?: RouterStateSnapshot,
     ): boolean | Observable<boolean> {
-        console.log(currentRoute, currentState, nextState);
         if (!component.canDeactivate()) {
             return this.modalService
                 .dialog({