diff --git a/artifacts/docs/consolidate_feature.md b/artifacts/docs/consolidate_feature.md index 3282cb083..c24b348c6 100644 --- a/artifacts/docs/consolidate_feature.md +++ b/artifacts/docs/consolidate_feature.md @@ -11,7 +11,7 @@ The standard consolidation format is: - **Single File Support**: Automatically creates a folder for single-file books (e.g., `.m4b` or `.mp3` files located in the root) and moves the file into it. - **Batch Consolidation**: Allows selecting multiple books in the library listing to consolidate them all at once. - **Metadata Synchronization**: When a book is consolidated (or its metadata is updated), ABS ensures that denormalized database fields (Title, Author) are synchronized with the media record. -- **Automatic Status Tracking**: Every book's consolidation status is recalculated on-the-fly for display. While a flag exists in the database for SQL filtering, both the backend API and the frontend UI recompute the "real" status based on current metadata and paths. +- **Interactive Indicators**: Books that are not consolidated display a yellow "Not Consolidated" button/badge. For authorized users, this badge acts as a shortcut to trigger the consolidation process directly from the bookshelf. - **Empty Directory Cleanup**: After moving an item, the feature recursively deletes any parent directories that have become empty. ## How it Works @@ -19,12 +19,12 @@ The standard consolidation format is: ### 1. Folder Name Generation The target folder name is generated using the first author listed and the book title, sanitized to be valid for the local filesystem. This logic is mirrored on both the server and the client for real-time UI updates. - **Pattern**: `Author - Title` -- **Sanitization**: Special characters are removed or replaced to ensure compatibility across different operating systems. +- **Sanitization**: Special characters are removed or replaced to ensure compatibility across different operating systems, including handling character-based truncation for long filenames. -### 2. Status Recalculation -- **Frontend**: Computed properties in `LazyBookCard.vue` and `item/_id/index.vue` use local metadata to determine if the item is consolidated. This means indicators update instantly when metadata is edited. -- **Backend API**: The `LibraryItem` model's serialization methods (`toOldJSON`) call `checkIsNotConsolidated()` dynamically, ensuring the client receives fresh status information. -- **Database Hook**: A `beforeSave` hook synchronizes denormalized metadata and the `isNotConsolidated` flag, ensuring that SQL-based filters (like "Show Not Consolidated") remain accurate. +### 2. Status Tracking +- **Database Hook**: A `beforeSave` hook in `LibraryItem.js` synchronizes denormalized metadata and recalculates the `isNotConsolidated` flag using `checkIsNotConsolidated()`. This ensures that SQL-based filters (like "Not Consolidated") are always accurate. +- **Backend API**: The `LibraryItem` model's serialization methods (`toOldJSON`) return the persisted `isNotConsolidated` flag. This maintains perfect parity between the items shown in a filtered listing and the status indicators visible on their cards. +- **Frontend**: Computed properties in `LazyBookCard.vue` and `item/_id/index.vue` rely on the server-provided `isNotConsolidated` property, ensuring consistent behavior across the application. ### 3. Path Validation Before moving any files, the system checks if the destination folder already exists. If it exists and is not the current folder, the operation will fail to prevent overwriting or merging items unintentionally. @@ -38,11 +38,16 @@ The system identifies the previous parent directory of the book. If that directo ## Usage -### Single Item +### Single Item (Detail View) 1. Open a book in the web interface. 2. If the book is not consolidated, a **"Not Consolidated"** warning icon will appear next to the title. 3. Click the **Consolidate** button (folder icon) in the action bar. +### Bookshelf View (Shortcut) +- For items that are not consolidated, a yellow **Consolidate Button** (folder icon) appears in the bottom-left of the book card. +- Clicking this button triggers the consolidation confirmation dialog immediately. +- The button is positioned to avoid overlapping with selection controls and adapts if the book is an ebook. + ### Context Menu - Right-click any book card in the library listing and select **Consolidate**. @@ -53,4 +58,5 @@ The system identifies the previous parent directory of the book. If that directo ## Technical Notes - **File System**: Requires write permissions on the library directories. - **Watcher**: The system temporarily ignores the moving directories in the file watcher to prevent duplicate scanning during the move. -- **Socket Events**: UI updates are triggered via `item_updated` socket events. +- **Socket Events**: UI updates are triggered via `item_updated` socket events, ensuring the "Not Consolidated" indicator disappears immediately after a successful operation. +- **Cross-Platform**: Path detection logic uses POSIX-style normalization to ensure consistent behavior on both Linux and Windows servers. diff --git a/client/components/cards/LazyBookCard.vue b/client/components/cards/LazyBookCard.vue index db060c5e8..068002736 100644 --- a/client/components/cards/LazyBookCard.vue +++ b/client/components/cards/LazyBookCard.vue @@ -116,11 +116,11 @@
{{ numEpisodesIncomplete }}
- -