feat: add grouped field dropdown and composite fields to magic shelf (#2750)

This commit is contained in:
ACX
2026-02-14 15:47:34 -07:00
committed by GitHub
parent 8c319122bb
commit 218befb3b5
17 changed files with 4796 additions and 120 deletions
@@ -165,8 +165,9 @@ export class BookBrowserEntityService {
if (!bookState.loaded || bookState.error || !magicShelf?.filterJson) {
return bookState;
}
const filteredBooks: Book[] | undefined = bookState.books?.filter(book =>
this.bookRuleEvaluatorService.evaluateGroup(book, JSON.parse(magicShelf.filterJson!) as GroupRule)
const allBooks = bookState.books ?? [];
const filteredBooks = allBooks.filter(book =>
this.bookRuleEvaluatorService.evaluateGroup(book, JSON.parse(magicShelf.filterJson!) as GroupRule, allBooks)
);
const sortedBooks = this.sortService.applySort(filteredBooks ?? [], sortOption);
return {...bookState, books: sortedBooks};
@@ -204,7 +204,7 @@ export class BookFilterService {
if (!magicShelf.filterJson) return [];
try {
const groupRule = JSON.parse(magicShelf.filterJson) as GroupRule;
return books.filter(book => this.bookRuleEvaluatorService.evaluateGroup(book, groupRule));
return books.filter(book => this.bookRuleEvaluatorService.evaluateGroup(book, groupRule, books));
} catch {
console.warn('Invalid filterJson for MagicShelf');
return [];