diff --git a/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.html b/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.html index 4e1bd0d878..e405307abb 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.html +++ b/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.html @@ -19,7 +19,7 @@
{{ preset.name }}
diff --git a/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.ts b/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.ts index b3f9c1d984..4cd584294b 100644 --- a/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.ts +++ b/packages/admin-ui/src/lib/core/src/shared/components/data-table-filter-presets/data-table-filter-presets.component.ts @@ -53,6 +53,23 @@ export class DataTableFilterPresetsComponent implements OnInit, OnDestroy { ); } + getQueryParamsForPreset(preset: string, serializedActiveFilters: string): Record { + // Clone the current query params to avoid mutating them directly + const currentParams = { ...this.route.snapshot.queryParams }; + + if (preset === serializedActiveFilters) { + // Toggling off: remove 'filters' and 'page' params + delete currentParams['filters']; + delete currentParams['page']; + } else { + // Toggling on: set 'filters' and 'page' params + currentParams['filters'] = preset; + currentParams['page'] = 1; + } + + return currentParams; + } + ngOnDestroy() { this.destroy$.next(); this.destroy$.complete();