From 6c30218a51687df09a080c94c9de26044cd27340 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 19 May 2024 17:36:05 +0100 Subject: [PATCH] fix: a few library filter bugs --- .../features/library/library.component.html | 6 ++-- .../app/features/library/library.component.ts | 30 +++++++------------ 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/frontend/src/app/features/library/library.component.html b/frontend/src/app/features/library/library.component.html index bcc86da..6c8bae7 100644 --- a/frontend/src/app/features/library/library.component.html +++ b/frontend/src/app/features/library/library.component.html @@ -50,7 +50,7 @@
+ [(ngModel)]="filterCriteria.matchAll" (click)="onFilterChange()" >
@@ -102,7 +102,7 @@
Total entries {{entriesCount}}
-
+
  • Previous @@ -125,7 +125,7 @@ -
    +
    • Previous diff --git a/frontend/src/app/features/library/library.component.ts b/frontend/src/app/features/library/library.component.ts index 752e799..27d8a46 100644 --- a/frontend/src/app/features/library/library.component.ts +++ b/frontend/src/app/features/library/library.component.ts @@ -105,6 +105,7 @@ export class LibraryComponent implements OnInit, AfterViewInit { }); } + // ! FILTER getQueryParameters() { this.route.queryParams.subscribe((params) => { this.currentPage = params['page'] ? parseInt(params['page'], 10) : 1; @@ -133,46 +134,38 @@ export class LibraryComponent implements OnInit, AfterViewInit { setQueryParameters() { let params = { page: this.currentPage } as LibraryQueryParams; + // ? title if (this.filterCriteria.title?.trim() != '') { params.title = this.filterCriteria.title?.trim(); - } else { - delete params.title; } + // ? years if (this.filterCriteria.years?.length) { params.years = this.filterCriteria.years.join(','); - } else { - delete params.years; } - + // ? genres if (this.filterCriteria.genres?.length) { params.genres = this.filterCriteria.genres.join(','); - } else { - delete params.genres; } + // ? type if (this.filterCriteria.type != 0) { params.type = this.filterCriteria.type; - } else { - delete params.type; } + // ? favorit if (this.filterCriteria.favorit != false) { params.favorit = this.filterCriteria.favorit; - } else { - delete params.favorit; } + // ? hidden if (this.filterCriteria.hidden != false) { params.hidden = this.filterCriteria.hidden; - } else { - delete params.hidden; } + // ? matchAll if (this.filterCriteria.matchAll != true) { params.matchAll = this.filterCriteria.matchAll; - } else { - delete params.matchAll; } this.router.navigate([], { @@ -182,7 +175,6 @@ export class LibraryComponent implements OnInit, AfterViewInit { }); } - // ! FILTER ngAfterViewInit() { $('#year-select') .select2({ @@ -244,14 +236,14 @@ export class LibraryComponent implements OnInit, AfterViewInit { const formattedTitle = this.filterCriteria.title?.toLowerCase().trim() || ''; temp = await this.entries.filter((entry) => { - // Type check + // * Type check let filterType = this.filterCriteria.type - 1 == 0 ? false : true; if (this.filterCriteria.type != 0 && filterType != entry.is_tvseries) { return false; // Skip entry if the type does not match, unless type is 'all' (0) } - // Hidden check - // skip hidden if show hidden is not check + // * Hidden check + // ? skip hidden if show hidden is not checked if (!this.filterCriteria.hidden && entry.hidden) { return false; }