Allow physical and digital book states to coexist (#3238)
This commit is contained in:
@@ -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 {
|
||||
|
||||
+1
-1
@@ -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>
|
||||
|
||||
+13
@@ -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) {
|
||||
|
||||
@@ -327,6 +327,8 @@
|
||||
"menuSendBook": "Send Book",
|
||||
"menuQuickSend": "Quick Send",
|
||||
"menuCustomSend": "Custom Send",
|
||||
"menuMarkPhysical": "Mark as Physical",
|
||||
"menuUnmarkPhysical": "Unmark as Physical",
|
||||
"menuAttachToAnotherBook": "Attach to Another Book",
|
||||
"menuDeleteFileFormats": "Delete File Formats",
|
||||
"menuDeleteSupplementaryFiles": "Delete Supplementary Files",
|
||||
|
||||
@@ -327,6 +327,8 @@
|
||||
"menuSendBook": "Enviar libro",
|
||||
"menuQuickSend": "Envío rápido",
|
||||
"menuCustomSend": "Envío personalizado",
|
||||
"menuMarkPhysical": "Marcar como físico",
|
||||
"menuUnmarkPhysical": "Desmarcar como físico",
|
||||
"menuAttachToAnotherBook": "Adjuntar a otro libro",
|
||||
"menuDeleteFileFormats": "Eliminar formatos de archivo",
|
||||
"menuDeleteSupplementaryFiles": "Eliminar archivos complementarios",
|
||||
|
||||
Reference in New Issue
Block a user