Derive filter type from filterStreams
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
<div *ngIf="showFilters" class="w-[225px] ml-4 h-[calc(100vh-6.5rem)] rounded-xl bg-[var(--card-background)] overflow-hidden">
|
||||
<p class="text-xl p-4">Filters:</p>
|
||||
<p-accordion [value]="0">
|
||||
<p-accordion-panel *ngFor="let filterType of ['author', 'category', 'award', 'publisher', 'series']; let i = index" [value]="i">
|
||||
<p-accordion-panel *ngFor="let filterType of filterTypes; let i = index" [value]="i">
|
||||
<p-accordion-header>{{ filterType | titlecase }}</p-accordion-header>
|
||||
<p-accordion-content class="h-[40rem] !overflow-y-auto">
|
||||
<div *ngIf="filterStreams[filterType] | async as filters">
|
||||
|
||||
@@ -39,6 +39,7 @@ export class BookFilterComponent implements OnInit {
|
||||
|
||||
activeFilter: { type: string; value: any | null } = {type: '', value: null};
|
||||
filterStreams: Record<string, Observable<Filter<any>[]>> = {};
|
||||
filterTypes: string[] = [];
|
||||
|
||||
bookService = inject(BookService);
|
||||
|
||||
@@ -52,6 +53,7 @@ export class BookFilterComponent implements OnInit {
|
||||
award: this.getFilterStream((book) => book.metadata?.awards?.filter((award) => award.designation === 'WINNER'), 'name', 'name'),
|
||||
publisher: this.getFilterStream((book) => (book.metadata?.publisher ? [{id: book.metadata.publisher, name: book.metadata.publisher}] : []), 'id', 'name'),
|
||||
};
|
||||
this.filterTypes = Object.keys(this.filterStreams);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user