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