feat(filter): add audiobook narrator filter and sort option
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@
|
||||
optionValue="value"
|
||||
class="filter-mode-select"
|
||||
allowEmpty="false"
|
||||
class="h-8"></p-selectButton>
|
||||
></p-selectButton>
|
||||
</div>
|
||||
|
||||
<div class="filter-content">
|
||||
|
||||
-2
@@ -118,7 +118,6 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
this.updateExpandedPanels();
|
||||
}
|
||||
|
||||
// Template Helpers
|
||||
getVirtualScrollHeight = (itemCount: number): number => Math.min(itemCount * 28, 440);
|
||||
|
||||
trackByFilterType = (_: number, type: FilterType): string => type;
|
||||
@@ -167,7 +166,6 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private updateVisibleFilterTypes(): void {
|
||||
// Filter and order filterTypes based on user's visible filter preferences
|
||||
this.visibleFilterTypes = this._visibleFilters.filter(
|
||||
vf => this.filterTypes.includes(vf as FilterType)
|
||||
) as FilterType[];
|
||||
|
||||
+4
@@ -21,6 +21,7 @@ export type FilterType =
|
||||
| 'shelfStatus' | 'tag' | 'publishedDate' | 'fileSize' | 'amazonRating'
|
||||
| 'goodreadsRating' | 'hardcoverRating' | 'language' | 'pageCount' | 'mood'
|
||||
| 'ageRating' | 'contentRating'
|
||||
| 'narrator'
|
||||
| 'comicCharacter' | 'comicTeam' | 'comicLocation' | 'comicCreator';
|
||||
|
||||
export type SortMode = 'count' | 'sortIndex';
|
||||
@@ -158,6 +159,7 @@ export const FILTER_LABELS: Readonly<Record<FilterType, string>> = {
|
||||
mood: 'Mood',
|
||||
ageRating: 'Age Rating',
|
||||
contentRating: 'Content Rating',
|
||||
narrator: 'Narrator',
|
||||
comicCharacter: 'Comic Character',
|
||||
comicTeam: 'Comic Team',
|
||||
comicLocation: 'Comic Location',
|
||||
@@ -236,6 +238,7 @@ export const FILTER_EXTRACTORS: Readonly<Record<Exclude<FilterType, 'library'>,
|
||||
const label = CONTENT_RATING_LABELS[rating] ?? rating;
|
||||
return [{id: rating, name: label}];
|
||||
},
|
||||
narrator: (book) => extractSingleString(book.metadata?.narrator),
|
||||
comicCharacter: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.characters),
|
||||
comicTeam: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.teams),
|
||||
comicLocation: (book) => extractStringsAsFilters(book.metadata?.comicMetadata?.locations),
|
||||
@@ -288,6 +291,7 @@ export const FILTER_CONFIGS: Readonly<Record<Exclude<FilterType, 'library'>, Omi
|
||||
mood: {label: 'Mood', sortMode: 'count'},
|
||||
ageRating: {label: 'Age Rating', sortMode: 'sortIndex', isNumericId: true},
|
||||
contentRating: {label: 'Content Rating', sortMode: 'count'},
|
||||
narrator: {label: 'Narrator', sortMode: 'count'},
|
||||
comicCharacter: {label: 'Comic Character', sortMode: 'count'},
|
||||
comicTeam: {label: 'Comic Team', sortMode: 'count'},
|
||||
comicLocation: {label: 'Comic Location', sortMode: 'count'},
|
||||
|
||||
@@ -128,6 +128,8 @@ export function doesBookMatchFilter(
|
||||
});
|
||||
case 'contentRating':
|
||||
return filterValues.includes(book.metadata?.contentRating);
|
||||
case 'narrator':
|
||||
return filterValues.includes(book.metadata?.narrator);
|
||||
case 'comicCharacter':
|
||||
return mode === 'or'
|
||||
? filterValues.some(val => book.metadata?.comicMetadata?.characters?.includes(val as string))
|
||||
|
||||
@@ -30,6 +30,7 @@ export class BookSorter {
|
||||
{label: 'Hardcover Rating', field: 'hardcoverRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Hardcover #', field: 'hardcoverReviewCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Ranobedb Rating', field: 'ranobedbRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Narrator', field: 'narrator', direction: SortDirection.ASCENDING},
|
||||
{label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Random', field: 'random', direction: SortDirection.ASCENDING},
|
||||
];
|
||||
|
||||
@@ -111,6 +111,7 @@ export class SortService {
|
||||
?? book.koboProgress?.percentage
|
||||
?? null,
|
||||
bookType: (book) => book.primaryFile?.bookType || null,
|
||||
narrator: (book) => book.metadata?.narrator?.toLowerCase() || null,
|
||||
};
|
||||
|
||||
applySort(books: Book[], selectedSort: SortOption | null): Book[] {
|
||||
|
||||
@@ -194,6 +194,7 @@ export type VisibleFilterType =
|
||||
| 'shelfStatus' | 'tag' | 'publishedDate' | 'fileSize' | 'amazonRating'
|
||||
| 'goodreadsRating' | 'hardcoverRating' | 'language' | 'pageCount' | 'mood'
|
||||
| 'ageRating' | 'contentRating'
|
||||
| 'narrator'
|
||||
| 'comicCharacter' | 'comicTeam' | 'comicLocation' | 'comicCreator';
|
||||
|
||||
export const DEFAULT_VISIBLE_FILTERS: VisibleFilterType[] = [
|
||||
@@ -225,6 +226,7 @@ export const ALL_FILTER_OPTIONS: { label: string; value: VisibleFilterType }[] =
|
||||
{label: 'Amazon Rating', value: 'amazonRating'},
|
||||
{label: 'Goodreads Rating', value: 'goodreadsRating'},
|
||||
{label: 'Hardcover Rating', value: 'hardcoverRating'},
|
||||
{label: 'Narrator', value: 'narrator'},
|
||||
{label: 'Comic Character', value: 'comicCharacter'},
|
||||
{label: 'Comic Team', value: 'comicTeam'},
|
||||
{label: 'Comic Location', value: 'comicLocation'},
|
||||
|
||||
+1
@@ -70,6 +70,7 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
|
||||
{label: 'Hardcover Rating', field: 'hardcoverRating', translationKey: 'sortHardcoverRating'},
|
||||
{label: 'Hardcover #', field: 'hardcoverReviewCount', translationKey: 'sortHardcoverCount'},
|
||||
{label: 'Ranobedb Rating', field: 'ranobedbRating', translationKey: 'sortRanobedbRating'},
|
||||
{label: 'Narrator', field: 'narrator', translationKey: 'sortNarrator'},
|
||||
{label: 'Pages', field: 'pageCount', translationKey: 'sortPages'},
|
||||
{label: 'Random', field: 'random', translationKey: 'sortRandom'},
|
||||
];
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"sortDateFinished": "Date Finished",
|
||||
"sortReadingProgress": "Reading Progress",
|
||||
"sortBookType": "Book Type",
|
||||
"sortNarrator": "Narrator",
|
||||
"sortPages": "Pages",
|
||||
"sortRandom": "Random",
|
||||
"entityLibrary": "Library",
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"sortDateFinished": "Fecha de finalización",
|
||||
"sortReadingProgress": "Progreso de lectura",
|
||||
"sortBookType": "Tipo de libro",
|
||||
"sortNarrator": "Narrador",
|
||||
"sortPages": "Páginas",
|
||||
"sortRandom": "Aleatorio",
|
||||
"entityLibrary": "Biblioteca",
|
||||
|
||||
Reference in New Issue
Block a user