checkChildren in toggleFilter method

This commit is contained in:
Edi Cziszter 2022-01-17 11:52:57 +02:00
parent d90392f402
commit 8931369d14

View File

@ -37,7 +37,7 @@ export class FilterService {
this._refresh$.next(true);
}
toggleFilter(filterGroupSlug: string, key: string): void {
toggleFilter(filterGroupSlug: string, key: string, checkChildren = false): void {
const filters = this.filterGroups.find(group => group.slug === filterGroupSlug)?.filters;
if (!filters) {
return console.error(`Cannot find filter group "${filterGroupSlug}"`);
@ -53,6 +53,12 @@ export class FilterService {
if (found) {
found.checked = !found.checked;
if (checkChildren && found.checked) {
if (found instanceof NestedFilter) {
found.children.forEach(c => c.checked);
}
}
}
this.refresh();