fix(ui): fix series page layout and grid (#1192)
This commit is contained in:
+4
-4
@@ -40,17 +40,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
@if (isSeriesViewActive()) {
|
@if (isSeriesViewActive()) {
|
||||||
<button type="button" class="p-button p-component p-button-rounded info-btn" (click)="openSeriesInfo()" [attr.aria-label]="'book.card.alt.viewSeriesInfo' | transloco">
|
<button pButton type="button" class="p-button p-component p-button-rounded info-btn" (click)="openSeriesInfo()" [attr.aria-label]="'book.card.alt.viewSeriesInfo' | transloco">
|
||||||
<i class="pi pi-info"></i>
|
<i class="pi pi-info"></i>
|
||||||
</button>
|
</button>
|
||||||
} @else {
|
} @else {
|
||||||
<button type="button" class="p-button p-component p-button-rounded info-btn" (click)="openBookInfo(book())" [attr.aria-label]="'book.card.alt.viewDetails' | transloco">
|
<button pButton type="button" class="p-button p-component p-button-rounded info-btn" (click)="openBookInfo(book())" [attr.aria-label]="'book.card.alt.viewDetails' | transloco">
|
||||||
<i class="pi pi-info"></i>
|
<i class="pi pi-info"></i>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
|
|
||||||
@if (!isSeriesViewActive() && hasDigitalFile()) {
|
@if (!isSeriesViewActive() && hasDigitalFile()) {
|
||||||
<a [routerLink]="readingUrl()" (click)="readBook(book())"
|
<a pButton [routerLink]="readingUrl()" (click)="readBook(book())"
|
||||||
class="p-button p-component p-button-rounded read-btn"
|
class="p-button p-component p-button-rounded read-btn"
|
||||||
[pTooltip]="isContinueReading() ? ('book.card.alt.continueReading' | transloco) : ''"
|
[pTooltip]="isContinueReading() ? ('book.card.alt.continueReading' | transloco) : ''"
|
||||||
tooltipPosition="bottom"
|
tooltipPosition="bottom"
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
{{ displayTitle() }}
|
{{ displayTitle() }}
|
||||||
</h4>
|
</h4>
|
||||||
<p-tieredmenu #menu [model]="items()" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()"></p-tieredmenu>
|
<p-tieredmenu #menu [model]="items()" [popup]="true" appendTo="body" (onShow)="onMenuShow()" (onHide)="onMenuHide()"></p-tieredmenu>
|
||||||
<button type="button"
|
<button pButton type="button"
|
||||||
class="p-button p-component p-button-text p-button-sm custom-button-padding"
|
class="p-button p-component p-button-text p-button-sm custom-button-padding"
|
||||||
(click)="onMenuToggle($event, menu)"
|
(click)="onMenuToggle($event, menu)"
|
||||||
[attr.aria-label]="'book.card.alt.bookMenu' | transloco">
|
[attr.aria-label]="'book.card.alt.bookMenu' | transloco">
|
||||||
|
|||||||
+2
-1
@@ -25,12 +25,13 @@ import {BookCardOverlayPreferenceService} from '../book-card-overlay-preference.
|
|||||||
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
|
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
|
||||||
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
import {TranslocoPipe, TranslocoService} from '@jsverse/transloco';
|
||||||
import {QueryClient} from '@tanstack/angular-query-experimental';
|
import {QueryClient} from '@tanstack/angular-query-experimental';
|
||||||
|
import {ButtonDirective} from 'primeng/button';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-book-card',
|
selector: 'app-book-card',
|
||||||
templateUrl: './book-card.component.html',
|
templateUrl: './book-card.component.html',
|
||||||
styleUrls: ['./book-card.component.scss'],
|
styleUrls: ['./book-card.component.scss'],
|
||||||
imports: [Checkbox, FormsModule, NgClass, TieredMenu, Tooltip, RouterLink, TranslocoPipe, CoverPlaceholderComponent],
|
imports: [ButtonDirective, Checkbox, FormsModule, NgClass, TieredMenu, Tooltip, RouterLink, TranslocoPipe, CoverPlaceholderComponent],
|
||||||
standalone: true,
|
standalone: true,
|
||||||
changeDetection: ChangeDetectionStrategy.OnPush
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -261,15 +261,15 @@
|
|||||||
<span>{{ t('synopsis') }}</span>
|
<span>{{ t('synopsis') }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="description-body">
|
<div class="description-body">
|
||||||
<div #descriptionContent [ngClass]="{ 'line-clamp-7': !isExpanded }"
|
<div #descriptionContent [ngClass]="{ 'line-clamp-7': !isExpanded() }"
|
||||||
class="description-content">
|
class="description-content">
|
||||||
<div class="description-html"
|
<div class="description-html"
|
||||||
[innerHTML]="firstDescription() || t('noDescription')"></div>
|
[innerHTML]="firstDescription() || t('noDescription')"></div>
|
||||||
</div>
|
</div>
|
||||||
@if (isExpanded || isOverflowing) {
|
@if (isExpanded() || isOverflowing()) {
|
||||||
<button class="expand-toggle" (click)="toggleExpand()">
|
<button class="expand-toggle" (click)="toggleExpand()">
|
||||||
{{ isExpanded ? t('showLess') : t('showMore') }}
|
{{ isExpanded() ? t('showLess') : t('showMore') }}
|
||||||
<i class="pi" [ngClass]="isExpanded ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
|
<i class="pi" [ngClass]="isExpanded() ? 'pi-chevron-up' : 'pi-chevron-down'"></i>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
@@ -279,34 +279,35 @@
|
|||||||
<i class="pi pi-objects-column"></i>
|
<i class="pi pi-objects-column"></i>
|
||||||
{{ t('booksInSeries') }}
|
{{ t('booksInSeries') }}
|
||||||
</h3>
|
</h3>
|
||||||
@let cardSize = currentCardSize;
|
<div
|
||||||
<div class="series-items-grid" #Container
|
#seriesGrid
|
||||||
[style.grid-template-columns]="'repeat(auto-fill, minmax(' + cardSize.width + 'px, 1fr))'">
|
class="series-items-grid"
|
||||||
@for (book of books; track book; let i = $index) {
|
[style.--series-grid-columns]="seriesGridColumns()"
|
||||||
<div class="grid-item"
|
[style.--series-grid-card-width.px]="seriesGridCardWidth()"
|
||||||
[style.width.px]="cardSize.width"
|
[style.--series-grid-card-height.px]="seriesGridCardHeight()"
|
||||||
[style.height.px]="cardSize.height">
|
[style.--series-grid-gap.px]="seriesGridGap()">
|
||||||
|
@for (book of books; track book.id; let index = $index) {
|
||||||
<app-book-card
|
<app-book-card
|
||||||
[index]="i"
|
[index]="index"
|
||||||
[book]="book"
|
[book]="book"
|
||||||
[isCheckboxEnabled]="true"
|
[isCheckboxEnabled]="true"
|
||||||
[isSelected]="isBookSelected(book)"
|
[seriesViewEnabled]="seriesViewEnabled"
|
||||||
|
[onBookSelect]="onSeriesBookCardSelect"
|
||||||
|
[isSeriesCollapsed]="seriesCardsCollapsed"
|
||||||
(checkboxClick)="onCheckboxClicked($event)"
|
(checkboxClick)="onCheckboxClicked($event)"
|
||||||
[onBookSelect]="handleBookSelect.bind(this)"
|
[isSelected]="isBookSelected(book)"
|
||||||
[isSeriesCollapsed]="false"
|
[useSquareCovers]="seriesCardsUseSquareCovers"
|
||||||
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
[overlayPreferenceService]="bookCardOverlayPreferenceService">
|
||||||
</app-book-card>
|
</app-book-card>
|
||||||
</div>
|
|
||||||
}
|
}
|
||||||
@if (books.length === 0) {
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
<div class="empty-state">{{ t('noBooksFound') }}</div>
|
<div class="empty-state">{{ t('noBooksFound') }}</div>
|
||||||
}
|
}
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
</p-tabpanel>
|
</p-tabpanel>
|
||||||
|
|
||||||
@@ -398,23 +399,23 @@
|
|||||||
|
|
||||||
</p-tabpanels>
|
</p-tabpanels>
|
||||||
</p-tabs>
|
</p-tabs>
|
||||||
@if (selectedBooks.size > 0) {
|
@if (selectedBooks().size > 0) {
|
||||||
@if (currentUser(); as user) {
|
@if (currentUser(); as user) {
|
||||||
<div class="book-browser-footer" [animate.enter]="'slide-in-up'" [animate.leave]="'slide-out-down'">
|
<div class="book-browser-footer" [animate.enter]="'slide-in-up'" [animate.leave]="'slide-out-down'">
|
||||||
<div class="footer-content">
|
<div class="footer-content">
|
||||||
<div class="footer-left">
|
<div class="footer-left">
|
||||||
<div class="selected-count-badge">
|
<div class="selected-count-badge">
|
||||||
<i class="pi pi-check-circle badge-icon"></i>
|
<i class="pi pi-check-circle badge-icon"></i>
|
||||||
<span class="badge-count" style="color: var(--primary-color)">{{ selectedBooks.size }}</span>
|
<span class="badge-count" style="color: var(--primary-color)">{{ selectedBooks().size }}</span>
|
||||||
<span class="badge-label">{{ t('selected') }}</span>
|
<span class="badge-label">{{ t('selected') }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer-center">
|
<div class="footer-center">
|
||||||
<div class="footer-action-group">
|
<div class="footer-action-group">
|
||||||
@if (hasMetadataMenuItems) {
|
@if (hasMetadataMenuItems) {
|
||||||
<p-tieredMenu #menu [model]="metadataMenuItems" [popup]="true" appendTo="body"/>
|
<p-tieredMenu #metadataMenu [model]="metadataMenuItems()" [popup]="true" appendTo="body"/>
|
||||||
<p-button
|
<p-button
|
||||||
(click)="menu.toggle($event)"
|
(click)="metadataMenu.toggle($event)"
|
||||||
[pTooltip]="t('tooltip.metadataActions')"
|
[pTooltip]="t('tooltip.metadataActions')"
|
||||||
tooltipPosition="top"
|
tooltipPosition="top"
|
||||||
outlined="true"
|
outlined="true"
|
||||||
@@ -453,14 +454,14 @@
|
|||||||
@if (hasMoreActionsItems) {
|
@if (hasMoreActionsItems) {
|
||||||
<div class="more-actions-wrapper">
|
<div class="more-actions-wrapper">
|
||||||
<p-button
|
<p-button
|
||||||
(click)="menu.toggle($event)"
|
(click)="moreActionsMenu.toggle($event)"
|
||||||
[pTooltip]="t('tooltip.moreActions')"
|
[pTooltip]="t('tooltip.moreActions')"
|
||||||
tooltipPosition="top"
|
tooltipPosition="top"
|
||||||
outlined="true"
|
outlined="true"
|
||||||
severity="info"
|
severity="info"
|
||||||
icon="pi pi-ellipsis-v">
|
icon="pi pi-ellipsis-v">
|
||||||
</p-button>
|
</p-button>
|
||||||
<p-tieredMenu #menu [model]="moreActionsMenuItems" [popup]="true" appendTo="body"/>
|
<p-tieredMenu #moreActionsMenu [model]="moreActionsMenuItems()" [popup]="true" appendTo="body"/>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@use "../../../../../assets/layout/styles/layout/variables";
|
||||||
|
|
||||||
.tabpanels-responsive {
|
.tabpanels-responsive {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
@@ -19,10 +21,21 @@
|
|||||||
min-height: 0;
|
min-height: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.series-wrapper > p-tabs > p-tablist {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.series-wrapper > p-tabs > p-tabpanels > p-tabpanel {
|
||||||
|
@media #{variables.$mobile-shell-media-query} {
|
||||||
|
padding-inline: var(--space-4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.series-main {
|
.series-main {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.series-details {
|
.series-details {
|
||||||
@@ -39,9 +52,10 @@
|
|||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
|
|
||||||
@media (width <= 767px) {
|
@media #{variables.$mobile-shell-media-query} {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: stretch;
|
||||||
|
padding-inline: 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -281,6 +295,10 @@
|
|||||||
&:hover {
|
&:hover {
|
||||||
box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
|
box-shadow: 0 2px 8px rgb(0 0 0 / 10%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media #{variables.$mobile-shell-media-query} {
|
||||||
|
margin-inline: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.description-header {
|
.description-header {
|
||||||
@@ -548,12 +566,29 @@
|
|||||||
// ── Book grid ──
|
// ── Book grid ──
|
||||||
|
|
||||||
.series-items-grid {
|
.series-items-grid {
|
||||||
|
--series-grid-columns: 1;
|
||||||
|
--series-grid-card-width: 135px;
|
||||||
|
--series-grid-card-height: 220px;
|
||||||
|
--series-grid-gap: 21px;
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(1px, 1fr));
|
grid-template-columns: repeat(var(--series-grid-columns), minmax(0, var(--series-grid-card-width)));
|
||||||
gap: 1rem;
|
gap: var(--series-grid-gap);
|
||||||
align-items: start;
|
align-items: start;
|
||||||
|
justify-content: start;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow-y: auto;
|
padding-inline: 0.5rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
@media #{variables.$mobile-shell-media-query} {
|
||||||
|
padding-inline: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.series-items-grid > app-book-card {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
height: var(--series-grid-card-height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Book list tab ──
|
// ── Book list tab ──
|
||||||
@@ -563,6 +598,7 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 0.5rem;
|
gap: 0.5rem;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
|
min-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.book-list-card {
|
.book-list-card {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import {Book, BookType, computeSeriesReadStatus, ReadStatus} from "../../model/b
|
|||||||
import {BookService} from "../../service/book.service";
|
import {BookService} from "../../service/book.service";
|
||||||
import {BookMetadataManageService} from "../../service/book-metadata-manage.service";
|
import {BookMetadataManageService} from "../../service/book-metadata-manage.service";
|
||||||
import {BookCardComponent} from "../book-browser/book-card/book-card.component";
|
import {BookCardComponent} from "../book-browser/book-card/book-card.component";
|
||||||
import {CoverScalePreferenceService} from "../book-browser/cover-scale-preference.service";
|
|
||||||
import {Tab, TabList, TabPanel, TabPanels, Tabs} from "primeng/tabs";
|
import {Tab, TabList, TabPanel, TabPanels, Tabs} from "primeng/tabs";
|
||||||
import {ProgressSpinner} from "primeng/progressspinner";
|
import {ProgressSpinner} from "primeng/progressspinner";
|
||||||
import {ProgressBar} from "primeng/progressbar";
|
import {ProgressBar} from "primeng/progressbar";
|
||||||
@@ -26,12 +25,13 @@ import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
|||||||
import {Tooltip} from "primeng/tooltip";
|
import {Tooltip} from "primeng/tooltip";
|
||||||
import {Divider} from "primeng/divider";
|
import {Divider} from "primeng/divider";
|
||||||
import {TagComponent} from "../../../../shared/components/tag/tag.component";
|
import {TagComponent} from "../../../../shared/components/tag/tag.component";
|
||||||
import {AfterViewChecked, Component, computed, effect, ElementRef, inject, ViewChild} from '@angular/core';
|
import {AfterViewChecked, ChangeDetectionStrategy, Component, computed, effect, ElementRef, inject, signal, viewChild} from '@angular/core';
|
||||||
import {BookCardOverlayPreferenceService} from '../book-browser/book-card-overlay-preference.service';
|
import {BookCardOverlayPreferenceService} from '../book-browser/book-card-overlay-preference.service';
|
||||||
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
import {UrlHelperService} from '../../../../shared/service/url-helper.service';
|
||||||
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
import {CoverPlaceholderComponent} from '../../../../shared/components/cover-generator/cover-generator.component';
|
||||||
import {injectQuery} from '@tanstack/angular-query-experimental';
|
import {injectQuery} from '@tanstack/angular-query-experimental';
|
||||||
import {AuthorService} from '../../../author-browser/service/author.service';
|
import {AuthorService} from '../../../author-browser/service/author.service';
|
||||||
|
import {LayoutService} from '../../../../shared/layout/layout.service';
|
||||||
|
|
||||||
interface ReadStatusSegment {
|
interface ReadStatusSegment {
|
||||||
status: ReadStatus;
|
status: ReadStatus;
|
||||||
@@ -68,6 +68,7 @@ interface SeriesStats {
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: "./series-page.component.html",
|
templateUrl: "./series-page.component.html",
|
||||||
styleUrls: ["./series-page.component.scss"],
|
styleUrls: ["./series-page.component.scss"],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||||
imports: [
|
imports: [
|
||||||
DecimalPipe,
|
DecimalPipe,
|
||||||
KeyValuePipe,
|
KeyValuePipe,
|
||||||
@@ -93,10 +94,14 @@ interface SeriesStats {
|
|||||||
})
|
})
|
||||||
export class SeriesPageComponent implements AfterViewChecked {
|
export class SeriesPageComponent implements AfterViewChecked {
|
||||||
|
|
||||||
|
private readonly DEFAULT_SERIES_CARD_WIDTH = 135;
|
||||||
|
private readonly DEFAULT_SERIES_CARD_HEIGHT = 220;
|
||||||
|
private readonly DESKTOP_SERIES_GRID_GAP = 21;
|
||||||
|
private readonly MOBILE_SERIES_GRID_GAP = 8;
|
||||||
|
private readonly MOBILE_GRID_COLUMNS = 2;
|
||||||
private route = inject(ActivatedRoute);
|
private route = inject(ActivatedRoute);
|
||||||
private bookService = inject(BookService);
|
private bookService = inject(BookService);
|
||||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||||
protected coverScalePreferenceService = inject(CoverScalePreferenceService);
|
|
||||||
private metadataCenterViewMode: "route" | "dialog" = "route";
|
private metadataCenterViewMode: "route" | "dialog" = "route";
|
||||||
private dialogRef?: DynamicDialogRef | null;
|
private dialogRef?: DynamicDialogRef | null;
|
||||||
private router = inject(Router);
|
private router = inject(Router);
|
||||||
@@ -112,22 +117,29 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
private readonly t = inject(TranslocoService);
|
private readonly t = inject(TranslocoService);
|
||||||
protected urlHelper = inject(UrlHelperService);
|
protected urlHelper = inject(UrlHelperService);
|
||||||
private authorService = inject(AuthorService);
|
private authorService = inject(AuthorService);
|
||||||
|
private layoutService = inject(LayoutService);
|
||||||
|
|
||||||
@ViewChild('descriptionContent') descriptionContentRef?: ElementRef<HTMLElement>;
|
private readonly descriptionContentRef = viewChild<ElementRef<HTMLElement>>('descriptionContent');
|
||||||
|
private readonly seriesGridElement = viewChild<ElementRef<HTMLElement>>('seriesGrid');
|
||||||
|
private readonly seriesGridWidth = signal(0);
|
||||||
tab: string = "view";
|
tab: string = "view";
|
||||||
isExpanded = false;
|
readonly isExpanded = signal(false);
|
||||||
isOverflowing = false;
|
readonly isOverflowing = signal(false);
|
||||||
protected appSettings = this.appSettingsService.appSettings;
|
protected appSettings = this.appSettingsService.appSettings;
|
||||||
protected currentUser = this.userService.currentUser;
|
protected currentUser = this.userService.currentUser;
|
||||||
protected isBooksLoading = this.bookService.isBooksLoading;
|
protected isBooksLoading = this.bookService.isBooksLoading;
|
||||||
|
|
||||||
// Selection state
|
// Selection state
|
||||||
selectedBooks = new Set<number>();
|
readonly selectedBooks = signal(new Set<number>());
|
||||||
lastSelectedIndex: number | null = null;
|
readonly lastSelectedIndex = signal<number | null>(null);
|
||||||
|
|
||||||
// Menu items
|
// Menu items
|
||||||
protected metadataMenuItems: MenuItem[] | undefined;
|
protected readonly metadataMenuItems = signal<MenuItem[] | undefined>(undefined);
|
||||||
protected moreActionsMenuItems: MenuItem[] | undefined;
|
protected readonly moreActionsMenuItems = signal<MenuItem[] | undefined>(undefined);
|
||||||
|
protected readonly seriesViewEnabled = false;
|
||||||
|
protected readonly seriesCardsCollapsed = false;
|
||||||
|
protected readonly seriesCardsUseSquareCovers = false;
|
||||||
|
protected readonly onSeriesBookCardSelect = this.handleBookSelect.bind(this);
|
||||||
|
|
||||||
private seriesParam = toSignal(this.route.paramMap.pipe(
|
private seriesParam = toSignal(this.route.paramMap.pipe(
|
||||||
map((params) => params.get("seriesName") || ""),
|
map((params) => params.get("seriesName") || ""),
|
||||||
@@ -145,6 +157,23 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
return aNum - bNum;
|
return aNum - bNum;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
protected readonly seriesGridColumns = computed(() => {
|
||||||
|
if (!this.layoutService.isDesktop()) {
|
||||||
|
return this.MOBILE_GRID_COLUMNS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.seriesGridColumnCount(this.seriesGridWidth());
|
||||||
|
});
|
||||||
|
protected readonly seriesGridGap = computed(() =>
|
||||||
|
this.layoutService.isDesktop() ? this.DESKTOP_SERIES_GRID_GAP : this.MOBILE_SERIES_GRID_GAP
|
||||||
|
);
|
||||||
|
protected readonly seriesGridCardWidth = computed(() => this.seriesGridItemWidth(
|
||||||
|
this.seriesGridWidth(),
|
||||||
|
this.seriesGridColumns()
|
||||||
|
));
|
||||||
|
protected readonly seriesGridCardHeight = computed(() =>
|
||||||
|
this.seriesCardSizeForWidth(this.seriesGridCardWidth()).height
|
||||||
|
);
|
||||||
|
|
||||||
coverBook = computed(() => this.filteredBooks()[0] ?? null);
|
coverBook = computed(() => this.filteredBooks()[0] ?? null);
|
||||||
private firstBookId = computed(() => this.coverBook()?.id ?? null);
|
private firstBookId = computed(() => this.coverBook()?.id ?? null);
|
||||||
@@ -347,7 +376,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.metadataMenuItems = this.bookMenuService.getMetadataMenuItems(
|
this.metadataMenuItems.set(this.bookMenuService.getMetadataMenuItems(
|
||||||
() => this.autoFetchMetadata(),
|
() => this.autoFetchMetadata(),
|
||||||
() => this.fetchMetadata(),
|
() => this.fetchMetadata(),
|
||||||
() => this.bulkEditMetadata(),
|
() => this.bulkEditMetadata(),
|
||||||
@@ -355,14 +384,60 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
() => this.regenerateCoversForSelected(),
|
() => this.regenerateCoversForSelected(),
|
||||||
() => this.generateCustomCoversForSelected(),
|
() => this.generateCustomCoversForSelected(),
|
||||||
user
|
user
|
||||||
);
|
));
|
||||||
this.moreActionsMenuItems = this.bookMenuService.getMoreActionsMenu(this.selectedBooks, this.currentUser());
|
this.moreActionsMenuItems.set(this.bookMenuService.getMoreActionsMenu(this.selectedBooks(), user));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
effect((onCleanup) => {
|
||||||
|
const element = this.seriesGridElement()?.nativeElement;
|
||||||
|
if (!element) return;
|
||||||
|
|
||||||
|
const updateGridWidth = () => {
|
||||||
|
this.seriesGridWidth.set(this.getElementContentWidth(element));
|
||||||
|
};
|
||||||
|
updateGridWidth();
|
||||||
|
|
||||||
|
if (typeof ResizeObserver === 'undefined') return;
|
||||||
|
|
||||||
|
const resizeObserver = new ResizeObserver(updateGridWidth);
|
||||||
|
resizeObserver.observe(element);
|
||||||
|
onCleanup(() => resizeObserver.disconnect());
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentCardSize() {
|
private getElementContentWidth(element: HTMLElement): number {
|
||||||
return this.coverScalePreferenceService.currentCardSize();
|
const style = getComputedStyle(element);
|
||||||
|
const horizontalPadding = parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
||||||
|
return Math.max(0, Math.round(element.clientWidth - horizontalPadding));
|
||||||
|
}
|
||||||
|
|
||||||
|
private seriesGridColumnCount(containerWidth: number): number {
|
||||||
|
if (containerWidth <= 0) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.max(
|
||||||
|
1,
|
||||||
|
Math.floor((containerWidth + this.seriesGridGap()) / (this.DEFAULT_SERIES_CARD_WIDTH + this.seriesGridGap()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private seriesGridItemWidth(containerWidth: number, columns: number): number {
|
||||||
|
if (containerWidth <= 0 || columns <= 0) {
|
||||||
|
return this.DEFAULT_SERIES_CARD_WIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
const totalGap = (columns - 1) * this.seriesGridGap();
|
||||||
|
return Math.max(1, (containerWidth - totalGap) / columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
private seriesCardSizeForWidth(width: number): { width: number; height: number } {
|
||||||
|
const cardWidth = Math.round(width);
|
||||||
|
const aspectRatio = this.DEFAULT_SERIES_CARD_HEIGHT / this.DEFAULT_SERIES_CARD_WIDTH;
|
||||||
|
return {
|
||||||
|
width: cardWidth,
|
||||||
|
height: Math.round(cardWidth * aspectRatio),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
goToAuthorBooks(author: string): void {
|
goToAuthorBooks(author: string): void {
|
||||||
@@ -412,14 +487,16 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewChecked(): void {
|
ngAfterViewChecked(): void {
|
||||||
if (!this.isExpanded && this.descriptionContentRef) {
|
if (!this.isExpanded()) {
|
||||||
const el = this.descriptionContentRef.nativeElement;
|
const el = this.descriptionContentRef()?.nativeElement;
|
||||||
this.isOverflowing = el.scrollHeight > el.clientHeight;
|
if (!el) return;
|
||||||
|
|
||||||
|
this.isOverflowing.set(el.scrollHeight > el.clientHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleExpand(): void {
|
toggleExpand(): void {
|
||||||
this.isExpanded = !this.isExpanded;
|
this.isExpanded.update(isExpanded => !isExpanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
getStatusLabel(value: string | ReadStatus | null | undefined): string {
|
getStatusLabel(value: string | ReadStatus | null | undefined): string {
|
||||||
@@ -522,26 +599,31 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isBookSelected(book: Book): boolean {
|
isBookSelected(book: Book): boolean {
|
||||||
return this.getSelectableBookIds(book).every(id => this.selectedBooks.has(id));
|
return this.getSelectableBookIds(book).every(id => this.selectedBooks().has(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBookSelection(book: Book, selected: boolean) {
|
handleBookSelection(book: Book, selected: boolean) {
|
||||||
const ids = this.getSelectableBookIds(book);
|
const ids = this.getSelectableBookIds(book);
|
||||||
|
this.selectedBooks.update(selectedBooks => {
|
||||||
|
const nextSelectedBooks = new Set(selectedBooks);
|
||||||
if (selected) {
|
if (selected) {
|
||||||
ids.forEach(id => this.selectedBooks.add(id));
|
ids.forEach(id => nextSelectedBooks.add(id));
|
||||||
} else {
|
} else {
|
||||||
ids.forEach(id => this.selectedBooks.delete(id));
|
ids.forEach(id => nextSelectedBooks.delete(id));
|
||||||
}
|
}
|
||||||
|
return nextSelectedBooks;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onCheckboxClicked(event: { index: number; book: Book; selected: boolean; shiftKey: boolean }) {
|
onCheckboxClicked(event: { index: number; book: Book; selected: boolean; shiftKey: boolean }) {
|
||||||
const {index, book, selected, shiftKey} = event;
|
const {index, book, selected, shiftKey} = event;
|
||||||
if (!shiftKey || this.lastSelectedIndex === null) {
|
const lastSelectedIndex = this.lastSelectedIndex();
|
||||||
|
if (!shiftKey || lastSelectedIndex === null) {
|
||||||
this.handleBookSelection(book, selected);
|
this.handleBookSelection(book, selected);
|
||||||
this.lastSelectedIndex = index;
|
this.lastSelectedIndex.set(index);
|
||||||
} else {
|
} else {
|
||||||
const start = Math.min(this.lastSelectedIndex, index);
|
const start = Math.min(lastSelectedIndex, index);
|
||||||
const end = Math.max(this.lastSelectedIndex, index);
|
const end = Math.max(lastSelectedIndex, index);
|
||||||
const isUnselectingRange = !selected;
|
const isUnselectingRange = !selected;
|
||||||
const books = this.filteredBooks();
|
const books = this.filteredBooks();
|
||||||
for (let i = start; i <= end; i++) {
|
for (let i = start; i <= end; i++) {
|
||||||
@@ -550,29 +632,30 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
this.handleBookSelection(book, !isUnselectingRange);
|
this.handleBookSelection(book, !isUnselectingRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.moreActionsMenuItems = this.bookMenuService.getMoreActionsMenu(this.selectedBooks, this.user());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleBookSelect(book: Book, selected: boolean): void {
|
handleBookSelect(book: Book, selected: boolean): void {
|
||||||
this.handleBookSelection(book, selected);
|
this.handleBookSelection(book, selected);
|
||||||
this.moreActionsMenuItems = this.bookMenuService.getMoreActionsMenu(this.selectedBooks, this.user());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
selectAllBooks(): void {
|
selectAllBooks(): void {
|
||||||
|
this.selectedBooks.update(selectedBooks => {
|
||||||
|
const nextSelectedBooks = new Set(selectedBooks);
|
||||||
for (const book of this.filteredBooks()) {
|
for (const book of this.filteredBooks()) {
|
||||||
this.getSelectableBookIds(book).forEach(id => this.selectedBooks.add(id));
|
this.getSelectableBookIds(book).forEach(id => nextSelectedBooks.add(id));
|
||||||
}
|
}
|
||||||
this.moreActionsMenuItems = this.bookMenuService.getMoreActionsMenu(this.selectedBooks, this.user());
|
return nextSelectedBooks;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deselectAllBooks(): void {
|
deselectAllBooks(): void {
|
||||||
this.selectedBooks.clear();
|
this.selectedBooks.set(new Set());
|
||||||
this.moreActionsMenuItems = this.bookMenuService.getMoreActionsMenu(this.selectedBooks, this.user());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmDeleteBooks(): void {
|
confirmDeleteBooks(): void {
|
||||||
|
const selectedBooks = this.selectedBooks();
|
||||||
this.confirmationService.confirm({
|
this.confirmationService.confirm({
|
||||||
message: this.t.translate('book.browser.confirm.deleteMessage', {count: this.selectedBooks.size}),
|
message: this.t.translate('book.browser.confirm.deleteMessage', {count: selectedBooks.size}),
|
||||||
header: this.t.translate('book.browser.confirm.deleteHeader'),
|
header: this.t.translate('book.browser.confirm.deleteHeader'),
|
||||||
icon: 'pi pi-exclamation-triangle',
|
icon: 'pi pi-exclamation-triangle',
|
||||||
acceptIcon: 'pi pi-trash',
|
acceptIcon: 'pi pi-trash',
|
||||||
@@ -582,31 +665,31 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
acceptButtonStyleClass: 'p-button-danger',
|
acceptButtonStyleClass: 'p-button-danger',
|
||||||
rejectButtonStyleClass: 'p-button-outlined',
|
rejectButtonStyleClass: 'p-button-outlined',
|
||||||
accept: () => {
|
accept: () => {
|
||||||
const count = this.selectedBooks.size;
|
const count = selectedBooks.size;
|
||||||
const loader = this.loadingService.show(this.t.translate('book.browser.loading.deleting', {count}));
|
const loader = this.loadingService.show(this.t.translate('book.browser.loading.deleting', {count}));
|
||||||
|
|
||||||
this.bookService.deleteBooks(this.selectedBooks)
|
this.bookService.deleteBooks(selectedBooks)
|
||||||
.pipe(finalize(() => this.loadingService.hide(loader)))
|
.pipe(finalize(() => this.loadingService.hide(loader)))
|
||||||
.subscribe(() => {
|
.subscribe(() => {
|
||||||
this.selectedBooks.clear();
|
this.deselectAllBooks();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
openShelfAssigner(): void {
|
openShelfAssigner(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openShelfAssignerDialog(null, this.selectedBooks());
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.pipe(take(1)).subscribe(result => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(result => {
|
||||||
if (result.assigned) {
|
if (result?.assigned) {
|
||||||
this.selectedBooks.clear();
|
this.deselectAllBooks();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lockUnlockMetadata(): void {
|
lockUnlockMetadata(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openLockUnlockMetadataDialog(this.selectedBooks());
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.deselectAllBooks();
|
this.deselectAllBooks();
|
||||||
@@ -615,19 +698,20 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
autoFetchMetadata(): void {
|
autoFetchMetadata(): void {
|
||||||
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
|
const selectedBooks = this.selectedBooks();
|
||||||
|
if (selectedBooks.size === 0) return;
|
||||||
this.taskHelperService.refreshMetadataTask({
|
this.taskHelperService.refreshMetadataTask({
|
||||||
refreshType: MetadataRefreshType.BOOKS,
|
refreshType: MetadataRefreshType.BOOKS,
|
||||||
bookIds: Array.from(this.selectedBooks),
|
bookIds: Array.from(selectedBooks),
|
||||||
}).subscribe();
|
}).subscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchMetadata(): void {
|
fetchMetadata(): void {
|
||||||
this.dialogHelperService.openMetadataRefreshDialog(this.selectedBooks);
|
this.dialogHelperService.openMetadataRefreshDialog(this.selectedBooks());
|
||||||
}
|
}
|
||||||
|
|
||||||
bulkEditMetadata(): void {
|
bulkEditMetadata(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openBulkMetadataEditDialog(this.selectedBooks());
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.deselectAllBooks();
|
this.deselectAllBooks();
|
||||||
@@ -636,7 +720,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
multiBookEditMetadata(): void {
|
multiBookEditMetadata(): void {
|
||||||
this.dialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks);
|
this.dialogRef = this.dialogHelperService.openMultibookMetadataEditorDialog(this.selectedBooks());
|
||||||
if (this.dialogRef) {
|
if (this.dialogRef) {
|
||||||
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
this.dialogRef.onClose.pipe(take(1)).subscribe(() => {
|
||||||
this.deselectAllBooks();
|
this.deselectAllBooks();
|
||||||
@@ -645,8 +729,9 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
regenerateCoversForSelected(): void {
|
regenerateCoversForSelected(): void {
|
||||||
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
|
const selectedBooks = this.selectedBooks();
|
||||||
const count = this.selectedBooks.size;
|
if (selectedBooks.size === 0) return;
|
||||||
|
const count = selectedBooks.size;
|
||||||
this.confirmationService.confirm({
|
this.confirmationService.confirm({
|
||||||
message: this.t.translate('book.browser.confirm.regenCoverMessage', {count}),
|
message: this.t.translate('book.browser.confirm.regenCoverMessage', {count}),
|
||||||
header: this.t.translate('book.browser.confirm.regenCoverHeader'),
|
header: this.t.translate('book.browser.confirm.regenCoverHeader'),
|
||||||
@@ -662,7 +747,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
severity: 'secondary'
|
severity: 'secondary'
|
||||||
},
|
},
|
||||||
accept: () => {
|
accept: () => {
|
||||||
this.bookMetadataManageService.regenerateCoversForBooks(Array.from(this.selectedBooks)).subscribe({
|
this.bookMetadataManageService.regenerateCoversForBooks(Array.from(selectedBooks)).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -685,8 +770,9 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
generateCustomCoversForSelected(): void {
|
generateCustomCoversForSelected(): void {
|
||||||
if (!this.selectedBooks || this.selectedBooks.size === 0) return;
|
const selectedBooks = this.selectedBooks();
|
||||||
const count = this.selectedBooks.size;
|
if (selectedBooks.size === 0) return;
|
||||||
|
const count = selectedBooks.size;
|
||||||
this.confirmationService.confirm({
|
this.confirmationService.confirm({
|
||||||
message: this.t.translate('book.browser.confirm.customCoverMessage', {count}),
|
message: this.t.translate('book.browser.confirm.customCoverMessage', {count}),
|
||||||
header: this.t.translate('book.browser.confirm.customCoverHeader'),
|
header: this.t.translate('book.browser.confirm.customCoverHeader'),
|
||||||
@@ -702,7 +788,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
severity: 'secondary'
|
severity: 'secondary'
|
||||||
},
|
},
|
||||||
accept: () => {
|
accept: () => {
|
||||||
this.bookMetadataManageService.generateCustomCoversForBooks(Array.from(this.selectedBooks)).subscribe({
|
this.bookMetadataManageService.generateCustomCoversForBooks(Array.from(selectedBooks)).subscribe({
|
||||||
next: () => {
|
next: () => {
|
||||||
this.messageService.add({
|
this.messageService.add({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
@@ -725,7 +811,7 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
moveFiles() {
|
moveFiles() {
|
||||||
this.dialogHelperService.openFileMoverDialog(this.selectedBooks);
|
this.dialogHelperService.openFileMoverDialog(this.selectedBooks());
|
||||||
}
|
}
|
||||||
|
|
||||||
user() {
|
user() {
|
||||||
@@ -733,10 +819,10 @@ export class SeriesPageComponent implements AfterViewChecked {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get hasMetadataMenuItems(): boolean {
|
get hasMetadataMenuItems(): boolean {
|
||||||
return (this.metadataMenuItems?.length ?? 0) > 0;
|
return (this.metadataMenuItems()?.length ?? 0) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasMoreActionsItems(): boolean {
|
get hasMoreActionsItems(): boolean {
|
||||||
return (this.moreActionsMenuItems?.length ?? 0) > 0;
|
return (this.moreActionsMenuItems()?.length ?? 0) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user