Allow physical and digital book states to coexist (#3238)

This commit is contained in:
ACX
2026-03-07 17:59:24 -07:00
committed by GitHub
parent 4965f1811c
commit c3ecf49984
14 changed files with 67 additions and 35 deletions
@@ -257,6 +257,16 @@ export class BookService {
);
}
togglePhysicalFlag(bookId: number, physical: boolean): Observable<Book> {
return this.http.patch<Book>(`${this.url}/${bookId}/physical`, null, {params: {physical}}).pipe(
tap(updatedBook => {
const currentState = this.bookStateService.getCurrentBookState();
const updatedBooks = (currentState.books || []).map(b => b.id === bookId ? {...b, isPhysical: physical} : b);
this.bookStateService.updateBookState({...currentState, books: updatedBooks});
})
);
}
/*------------------ Reading & Viewer Settings ------------------*/
readBook(bookId: number, reader?: 'epub-streaming', explicitBookType?: BookType): void {
@@ -153,7 +153,7 @@
</app-tag>
</span>
}
@if (!book?.primaryFile?.filePath && !book?.alternativeFormats?.length) {
@if (book?.isPhysical) {
<app-tag size="3xs" variant="pill" [customBgColor]="'var(--book-type-physical-color)'" customTextColor="#fff">{{ t('physicalBadge') }}</app-tag>
}
</div>
@@ -235,6 +235,19 @@ export class MetadataViewerComponent implements OnInit, OnChanges, AfterViewChec
command: () => this.assignShelf(book.id)
});
if (userState?.user?.permissions.canManageLibrary || userState?.user?.permissions.admin) {
const isPhysical = book.isPhysical ?? false;
items.push({
label: isPhysical
? this.t.translate('metadata.viewer.menuUnmarkPhysical')
: this.t.translate('metadata.viewer.menuMarkPhysical'),
icon: isPhysical ? 'pi pi-times-circle' : 'pi pi-book',
command: () => {
this.bookService.togglePhysicalFlag(book.id, !isPhysical).subscribe();
}
});
}
// Add allowed submenus based on user permissions
if (userState?.user?.permissions.canUpload || userState?.user?.permissions.admin) {