F: changed filter multi select in library pages
This commit is contained in:
1 parent
4c5a355dc6
commit
7f6202c897
11 files changed
+193
-140
No files matched your search
@@ -368,6 +368,27 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
|
||||
this.loadNext();
|
||||
}
|
||||
}
|
||||
|
||||
clearSelection(type: string) {
|
||||
this.currentPage = 1;
|
||||
|
||||
if (type == 'years') {
|
||||
this.filterCriteria.years = [];
|
||||
} else if (type == 'genres') {
|
||||
this.filterCriteria.genres = [];
|
||||
}
|
||||
|
||||
this.filterEntries();
|
||||
this.setQueryParameters();
|
||||
}
|
||||
|
||||
isYearSelected(value: string): boolean {
|
||||
return this.filterCriteria.years?.includes(value) || false;
|
||||
}
|
||||
|
||||
isGenreSelected(value: string): boolean {
|
||||
return this.filterCriteria.genres?.includes(value) || false;
|
||||
}
|
||||
// + FILTER END
|
||||
|
||||
private loadNext(): void {
|
||||
@@ -423,23 +444,31 @@ export class LibraryPageComponent implements OnInit, AfterViewInit {
|
||||
}
|
||||
|
||||
// * filter events
|
||||
onYearsChange(event: any) {
|
||||
onYearsChange(year: string) {
|
||||
this.currentPage = 1;
|
||||
|
||||
// const selected = $(event.target).val();
|
||||
// this.filterCriteria.years = Array.isArray(selected)
|
||||
// ? selected.map(Number)
|
||||
// : [Number(selected)];
|
||||
if (this.filterCriteria.years?.includes(year)) {
|
||||
this.filterCriteria.years = this.filterCriteria.years.filter(
|
||||
(y) => y != year
|
||||
);
|
||||
} else {
|
||||
this.filterCriteria.years?.push(year);
|
||||
}
|
||||
|
||||
this.filterEntries();
|
||||
this.setQueryParameters(); // * update url query
|
||||
}
|
||||
|
||||
onGenresChange(event: any) {
|
||||
onGenresChange(genre: string) {
|
||||
this.currentPage = 1;
|
||||
|
||||
// const selected = $(event.target).val();
|
||||
// this.filterCriteria.genres = Array.isArray(selected) ? selected : [];
|
||||
if (this.filterCriteria.genres?.includes(genre)) {
|
||||
this.filterCriteria.genres = this.filterCriteria.genres.filter(
|
||||
(y) => y != genre
|
||||
);
|
||||
} else {
|
||||
this.filterCriteria.genres?.push(genre);
|
||||
}
|
||||
|
||||
this.filterEntries();
|
||||
this.setQueryParameters(); // * update url query
|
||||
|
||||
Reference in new issue
Block a user