fix: a few library filter bugs
This commit is contained in:
1 parent
29d6e3f503
commit
6c30218a51
2 files changed
+14
-22
No files matched your search
@@ -50,7 +50,7 @@
|
||||
<!-- Match All Criteria -->
|
||||
<div class="form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="matchAllSwitch"
|
||||
[(ngModel)]="filterCriteria.matchAll" (ngModelChange)="onFilterChange()">
|
||||
[(ngModel)]="filterCriteria.matchAll" (click)="onFilterChange()" >
|
||||
<label class="form-check-label" for="matchAllSwitch">Match All Criteria</label>
|
||||
</div>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<div class="dataTables_info" role="status" aria-live="polite">
|
||||
Total entries {{entriesCount}}
|
||||
</div>
|
||||
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage != 1 && entries.length != 0">
|
||||
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage > 1 && entries.length != 0">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li class="page-item" [class.disabled]="currentPage === 1">
|
||||
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage - 1)">Previous</a>
|
||||
@@ -125,7 +125,7 @@
|
||||
|
||||
|
||||
<!-- Pagination -->
|
||||
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage != 1 && entries.length != 0">
|
||||
<div class="pagination-container d-flex justify-content-end" *ngIf="maxPage > 1 && entries.length != 0">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li class="page-item" [class.disabled]="currentPage === 1">
|
||||
<a class="page-link" href="javascript:;" (click)="goToPage(currentPage - 1)">Previous</a>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user