+ [ngStyle]="{'grid-template-columns': 'repeat(auto-fill, minmax(' + gridColumnMinWidth + ', 1fr))'}">
@for (book of scroll.viewPortItems; track book) {
= {};
+ if (rawFilterParam) {
+ rawFilterParam.split(',').forEach(pair => {
+ const [key, ...valueParts] = pair.split(':');
+ const value = valueParts.join(':');
+ if (key && value) {
+ parsedFilters[key] = value.split('|').map(v => v.trim()).filter(Boolean);
+ }
+ });
+ this.selectedFilter.next(parsedFilters);
+ this.bookFilterComponent.setFilters?.(parsedFilters);
+ }
this.userService.userState$
.pipe(
@@ -633,26 +648,39 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
};
const userSortKey = effectivePrefs.sortKey;
- const userSortDir = effectivePrefs.sortDir?.toUpperCase() === 'DESC' ? SortDirection.DESCENDING : SortDirection.ASCENDING;
+ const userSortDir = effectivePrefs.sortDir?.toUpperCase() === 'DESC'
+ ? SortDirection.DESCENDING
+ : SortDirection.ASCENDING;
- const matchedSort = this.sortOptions.find(opt => opt.field === sortParam) || this.sortOptions.find(opt => opt.field === userSortKey);
+ const matchedSort = this.sortOptions.find(opt => opt.field === sortParam)
+ || this.sortOptions.find(opt => opt.field === userSortKey);
this.selectedSort = matchedSort ? {
label: matchedSort.label,
field: matchedSort.field,
- direction: directionParam ? (directionParam === SORT_DIRECTION.DESCENDING ? SortDirection.DESCENDING : SortDirection.ASCENDING) : userSortDir
+ direction: directionParam?.toUpperCase() === SORT_DIRECTION.DESCENDING
+ ? SortDirection.DESCENDING
+ : SortDirection.ASCENDING
} : {
label: 'Added On',
field: 'addedOn',
direction: SortDirection.DESCENDING
};
- this.currentViewMode = (viewParam === VIEW_MODES.TABLE || viewParam === VIEW_MODES.GRID) ? viewParam : effectivePrefs.view?.toLowerCase() ?? VIEW_MODES.GRID;
- this.bookFilterComponent.showFilters = filterParam === 'true' || (filterParam === null && this.filterVisibility);
+ this.currentViewMode = (viewParam === VIEW_MODES.TABLE || viewParam === VIEW_MODES.GRID)
+ ? viewParam
+ : effectivePrefs.view?.toLowerCase() ?? VIEW_MODES.GRID;
+
+ this.bookFilterComponent.showFilters = sidebarParam === 'true'
+ || (sidebarParam === null && this.filterVisibility);
+
this.updateSortOptions();
- if (this.lastAppliedSort?.field !== this.selectedSort.field || this.lastAppliedSort?.direction !== this.selectedSort.direction) {
- this.lastAppliedSort = {...this.selectedSort};
+ if (
+ this.lastAppliedSort?.field !== this.selectedSort.field ||
+ this.lastAppliedSort?.direction !== this.selectedSort.direction
+ ) {
+ this.lastAppliedSort = { ...this.selectedSort };
this.applySortOption(this.selectedSort);
}
@@ -660,17 +688,16 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
[QUERY_PARAMS.VIEW]: this.currentViewMode,
[QUERY_PARAMS.SORT]: this.selectedSort.field,
[QUERY_PARAMS.DIRECTION]: this.selectedSort.direction === SortDirection.ASCENDING ? SORT_DIRECTION.ASCENDING : SORT_DIRECTION.DESCENDING,
- [QUERY_PARAMS.FILTER]: this.bookFilterComponent.showFilters.toString()
+ [QUERY_PARAMS.SIDEBAR]: this.bookFilterComponent.showFilters.toString(),
+ [QUERY_PARAMS.FILTER]: Object.entries(parsedFilters)
+ .map(([k, v]) => `${k}:${v.join('|')}`)
+ .join(',')
};
const currentParams = this.activatedRoute.snapshot.queryParams;
+ const changed = Object.keys(queryParams).some(k => currentParams[k] !== queryParams[k]);
- if (
- currentParams[QUERY_PARAMS.VIEW] !== queryParams[QUERY_PARAMS.VIEW] ||
- currentParams[QUERY_PARAMS.SORT] !== queryParams[QUERY_PARAMS.SORT] ||
- currentParams[QUERY_PARAMS.DIRECTION] !== queryParams[QUERY_PARAMS.DIRECTION] ||
- currentParams[QUERY_PARAMS.FILTER] !== queryParams[QUERY_PARAMS.FILTER]
- ) {
+ if (changed) {
this.router.navigate([], {
queryParams,
replaceUrl: true
diff --git a/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.scss b/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.scss
index 4d6e15634..880183e6a 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.scss
+++ b/booklore-ui/src/app/book/components/book-browser/book-card/book-card.component.scss
@@ -92,11 +92,11 @@
}
.info-btn {
- top: 18%;
+ top: 21%;
}
.read-btn {
- bottom: 18%;
+ bottom: 21%;
}
.cover-container:hover .info-btn,
diff --git a/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts b/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts
index 963b3efb2..015718866 100644
--- a/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts
+++ b/booklore-ui/src/app/book/components/book-browser/book-filter/book-filter.component.ts
@@ -238,7 +238,25 @@ export class BookFilterComponent implements OnInit {
this.activeFilters[filterType].push(value);
}
- this.filterSelected.emit({...this.activeFilters});
+ if (Object.keys(this.activeFilters).length === 0) {
+ this.filterSelected.emit(null);
+ } else {
+ this.filterSelected.emit({ ...this.activeFilters });
+ }
+ }
+
+ setFilters(filters: Record) {
+ this.activeFilters = {};
+
+ for (const [key, value] of Object.entries(filters)) {
+ if (Array.isArray(value)) {
+ this.activeFilters[key] = [...value];
+ } else {
+ this.activeFilters[key] = [value];
+ }
+ }
+
+ this.filterSelected.emit({ ...this.activeFilters });
}
clearActiveFilter() {
diff --git a/booklore-ui/src/app/book/metadata/book-metadata-center/metadata-viewer/metadata-viewer.component.html b/booklore-ui/src/app/book/metadata/book-metadata-center/metadata-viewer/metadata-viewer.component.html
index 175154365..24fbdf701 100644
--- a/booklore-ui/src/app/book/metadata/book-metadata-center/metadata-viewer/metadata-viewer.component.html
+++ b/booklore-ui/src/app/book/metadata/book-metadata-center/metadata-viewer/metadata-viewer.component.html
@@ -38,7 +38,22 @@
tooltipPosition="top">
-
{{ getAuthorNames(metadata?.authors || []) }}
+
+ @for (author of metadata?.authors; track author; let isLast = $last) {
+ {{ author }}
+ @if (!isLast) {, }
+ }
+