From 7f6202c89716fd3a3b20ccf3d8126a141eba0c74 Mon Sep 17 00:00:00 2001 From: X4Lo Date: Sun, 16 Feb 2025 13:38:34 +0100 Subject: [PATCH] F: changed filter multi select in library pages --- frontend/package.json | 1 + frontend/pnpm-lock.yaml | 22 +++++++++ .../collections-page.component.html | 12 ++--- .../entries-display.component.css | 26 ++++------- .../entries-display.component.html | 45 ++++++++++++++----- .../entries-display.component.ts | 44 ++++++++++++++---- .../favorit-page/favorit.component.css | 36 --------------- .../library-page/library-page.component.css | 42 ++++------------- .../library-page/library-page.component.html | 44 +++++++++++++----- .../library-page/library-page.component.ts | 45 +++++++++++++++---- .../directives/stop-scroll.directive.ts | 16 +++---- 11 files changed, 193 insertions(+), 140 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index 19189f7..d08304f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -34,6 +34,7 @@ "@fullcalendar/core": "^6.1.15", "@fullcalendar/daygrid": "^6.1.15", "@fullcalendar/interaction": "^6.1.15", + "@ng-bootstrap/ng-bootstrap": "^18.0.0", "angular-star-rating": "^7.0.0", "apexcharts": "^3.49.0", "axios": "^1.6.8", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 444de67..1e617bf 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -50,6 +50,9 @@ importers: '@fullcalendar/interaction': specifier: ^6.1.15 version: 6.1.15(@fullcalendar/core@6.1.15) + '@ng-bootstrap/ng-bootstrap': + specifier: ^18.0.0 + version: 18.0.0(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(@angular/forms@17.3.12(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(@angular/platform-browser@17.3.12(@angular/animations@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(rxjs@7.8.1))(@popperjs/core@2.11.8)(rxjs@7.8.1) angular-star-rating: specifier: ^7.0.0 version: 7.0.0(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(@angular/forms@17.3.12(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(@angular/platform-browser@17.3.12(@angular/animations@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(rxjs@7.8.1))(css-star-rating@1.3.1)(rxjs@7.8.1) @@ -1398,6 +1401,16 @@ packages: '@material/typography@15.0.0-canary.7f224ddd4.0': resolution: {integrity: sha512-kBaZeCGD50iq1DeRRH5OM5Jl7Gdk+/NOfKArkY4ksBZvJiStJ7ACAhpvb8MEGm4s3jvDInQFLsDq3hL+SA79sQ==} + '@ng-bootstrap/ng-bootstrap@18.0.0': + resolution: {integrity: sha512-GeSAz4yiGq49psdte8kcf+Y562wB3jK/qKRAkh6iA32lcXmy2sfQXVAmlHdjZ3AyP+E8lf3yMwuPdSKiYcDgSg==} + peerDependencies: + '@angular/common': ^19.0.0 + '@angular/core': ^19.0.0 + '@angular/forms': ^19.0.0 + '@angular/localize': ^19.0.0 + '@popperjs/core': ^2.11.8 + rxjs: ^6.5.3 || ^7.4.0 + '@ngtools/webpack@17.3.9': resolution: {integrity: sha512-2+NvEQuYKRWdZaJbRJWEnR48tpW0uYbhwfHBHLDI9Kazb3mb0oAwYBVXdq+TtDLBypXnMsFpCewjRHTvkVx4/A==} engines: {node: ^18.13.0 || >=20.9.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'} @@ -6255,6 +6268,15 @@ snapshots: '@material/theme': 15.0.0-canary.7f224ddd4.0 tslib: 2.7.0 + '@ng-bootstrap/ng-bootstrap@18.0.0(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(@angular/forms@17.3.12(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(@angular/platform-browser@17.3.12(@angular/animations@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(rxjs@7.8.1))(@popperjs/core@2.11.8)(rxjs@7.8.1)': + dependencies: + '@angular/common': 17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1) + '@angular/core': 17.3.12(rxjs@7.8.1)(zone.js@0.14.10) + '@angular/forms': 17.3.12(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(@angular/platform-browser@17.3.12(@angular/animations@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(@angular/common@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10))(rxjs@7.8.1))(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(rxjs@7.8.1) + '@popperjs/core': 2.11.8 + rxjs: 7.8.1 + tslib: 2.7.0 + '@ngtools/webpack@17.3.9(@angular/compiler-cli@17.3.12(@angular/compiler@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.2.2))(typescript@5.2.2)(webpack@5.94.0(esbuild@0.20.1))': dependencies: '@angular/compiler-cli': 17.3.12(@angular/compiler@17.3.12(@angular/core@17.3.12(rxjs@7.8.1)(zone.js@0.14.10)))(typescript@5.2.2) diff --git a/frontend/src/app/features/collections/collections/collections-page/collections-page.component.html b/frontend/src/app/features/collections/collections/collections-page/collections-page.component.html index 90a819d..cd0c8f7 100644 --- a/frontend/src/app/features/collections/collections/collections-page/collections-page.component.html +++ b/frontend/src/app/features/collections/collections/collections-page/collections-page.component.html @@ -17,7 +17,7 @@
-
+
search @@ -28,10 +28,10 @@
-
- + @@ -42,7 +42,7 @@
-
+
diff --git a/frontend/src/app/features/library/entries-display/entries-display.component.css b/frontend/src/app/features/library/entries-display/entries-display.component.css index 9a2353a..35862f4 100644 --- a/frontend/src/app/features/library/entries-display/entries-display.component.css +++ b/frontend/src/app/features/library/entries-display/entries-display.component.css @@ -14,8 +14,6 @@ } .custom-group .btn-group .left-btn { - /* border-top-left-radius: 0.25rem; */ - /* border-bottom-left-radius: 0.25rem; */ border-left: 0; border-right: 0; } @@ -54,20 +52,14 @@ a.clear-filter-link { margin-left: auto; } - -/* ! ng multi select */ -::ng-deep .p-multiselect { - width: 100% !important; +/* ! filter multi select style */ +button[ngbDropdownToggle]::after { + display: none; } -::ng-deep .p-multiselect-items-wrapper{ - width: 100% !important; -} -.p-multiselect-label-container { - padding: 8px 12px !important; /* Adjust for better fit */ -} - -::ng-deep ol, -::ng-deep ul:not(.metismenu) { - padding-left: 0 !important; -} +.dropdown-menu { + max-height: 200px; + width: calc(100% - 23px); + overflow-y: auto; + box-sizing: border-box; +} \ No newline at end of file diff --git a/frontend/src/app/features/library/entries-display/entries-display.component.html b/frontend/src/app/features/library/entries-display/entries-display.component.html index 98d692f..7824f49 100644 --- a/frontend/src/app/features/library/entries-display/entries-display.component.html +++ b/frontend/src/app/features/library/entries-display/entries-display.component.html @@ -15,8 +15,9 @@
+
-
+
All({{entries.length}}) Movies
-
+
@@ -64,17 +65,41 @@
-
- - +
+ + + + +
-
- - +
+ + + + +
diff --git a/frontend/src/app/features/library/entries-display/entries-display.component.ts b/frontend/src/app/features/library/entries-display/entries-display.component.ts index a70da6e..3a818b0 100644 --- a/frontend/src/app/features/library/entries-display/entries-display.component.ts +++ b/frontend/src/app/features/library/entries-display/entries-display.component.ts @@ -295,6 +295,26 @@ export class EntriesDisplayComponent .map((year) => ({ label: year.toString(), value: year.toString() })); } + 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 getDefaultViewMode() { @@ -353,23 +373,31 @@ export class EntriesDisplayComponent } // * 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 diff --git a/frontend/src/app/features/library/favorit-page/favorit.component.css b/frontend/src/app/features/library/favorit-page/favorit.component.css index 2709cf5..e69de29 100644 --- a/frontend/src/app/features/library/favorit-page/favorit.component.css +++ b/frontend/src/app/features/library/favorit-page/favorit.component.css @@ -1,36 +0,0 @@ -.custom-group .form-select { - border-top-right-radius: 0; - border-bottom-right-radius: 0; -} - -.custom-group .form-select, -.custom-group .input-group-text { - border: 1px black solid; -} - -.custom-group .btn-group .btn { - border-radius: 0; -} - -.custom-group .btn-group .left-btn { - /* border-top-left-radius: 0.25rem; */ - /* border-bottom-left-radius: 0.25rem; */ - border-left: 0; - border-right: 0; -} - -.custom-group .btn-group .right-btn { - border-top-right-radius: 0.25rem; - border-bottom-right-radius: 0.25rem; - border-left: 0; - -} - -.custom-group .form-select, -.custom-group .btn-outline-dark { - margin-right: -1px; -} - -#single-select-field { - max-width: 120px; -} \ No newline at end of file diff --git a/frontend/src/app/features/library/library-page/library-page.component.css b/frontend/src/app/features/library/library-page/library-page.component.css index c421615..35862f4 100644 --- a/frontend/src/app/features/library/library-page/library-page.component.css +++ b/frontend/src/app/features/library/library-page/library-page.component.css @@ -14,8 +14,6 @@ } .custom-group .btn-group .left-btn { - /* border-top-left-radius: 0.25rem; */ - /* border-bottom-left-radius: 0.25rem; */ border-left: 0; border-right: 0; } @@ -54,38 +52,14 @@ a.clear-filter-link { margin-left: auto; } -/* ! filter title, year, genre */ -.select2 .select2-container .select2-container--default { - height: 50px !important; +/* ! filter multi select style */ +button[ngbDropdownToggle]::after { + display: none; } -.select2 .select2-container .select2-container--default .selection span .select2-selection .select2-selection--multiple { - padding: 0 !important; -} - - -/* ! ng multi select */ -::ng-deep .p-multiselect { - width: 100% !important; -} - -::ng-deep .p-multiselect-items-wrapper { - width: 100% !important; -} - -.p-multiselect-label-container { - padding: 8px 12px !important; - /* Adjust for better fit */ -} - -::ng-deep ol, -::ng-deep ul:not(.metismenu) { - padding-left: 0 !important; -} - - -.form-check-input, -.form-check-input .form-check-label, -.clear-filter-link { - cursor: pointer; +.dropdown-menu { + max-height: 200px; + width: calc(100% - 23px); + overflow-y: auto; + box-sizing: border-box; } \ No newline at end of file diff --git a/frontend/src/app/features/library/library-page/library-page.component.html b/frontend/src/app/features/library/library-page/library-page.component.html index d92f361..00bda1c 100644 --- a/frontend/src/app/features/library/library-page/library-page.component.html +++ b/frontend/src/app/features/library/library-page/library-page.component.html @@ -15,12 +15,10 @@
- -
-
- - +
+ + + + +
-
- - +
+ + + + +
diff --git a/frontend/src/app/features/library/library-page/library-page.component.ts b/frontend/src/app/features/library/library-page/library-page.component.ts index 47fda07..7db2a1b 100644 --- a/frontend/src/app/features/library/library-page/library-page.component.ts +++ b/frontend/src/app/features/library/library-page/library-page.component.ts @@ -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 diff --git a/frontend/src/app/shared/directives/stop-scroll.directive.ts b/frontend/src/app/shared/directives/stop-scroll.directive.ts index dd25abe..9f36c1a 100644 --- a/frontend/src/app/shared/directives/stop-scroll.directive.ts +++ b/frontend/src/app/shared/directives/stop-scroll.directive.ts @@ -8,17 +8,13 @@ export class StopScrollDirective { @HostListener('wheel', ['$event']) onWheel(event: WheelEvent) { - const element = this.el.nativeElement; + event.stopPropagation(); + event.preventDefault(); - // Check if scrolling is at the top or bottom of the element - const atTop = element.scrollTop === 0; - const atBottom = - element.scrollHeight - element.scrollTop === element.clientHeight; - - // Prevent scrolling the page if scrolling is within the dropdown - if ((atTop && event.deltaY < 0) || (atBottom && event.deltaY > 0)) { - event.stopPropagation(); - event.preventDefault(); + // Manually scroll the dropdown menu + const target = event.target as HTMLElement; + if (target instanceof HTMLElement) { + target.scrollBy({ top: event.deltaY, left: 0, behavior: 'smooth' }); } } }