Sort by author
This commit is contained in:
@@ -95,6 +95,7 @@ export class BookBrowserComponent implements OnInit, AfterViewInit {
|
||||
|
||||
sortOptions: any[] = [
|
||||
{label: 'Title', icon: '', field: 'title', command: () => this.sortBooks('title')},
|
||||
{label: 'Author', icon: '', field: 'author', command: () => this.sortBooks('author')},
|
||||
{label: 'Publisher', icon: '', field: 'publisher', command: () => this.sortBooks('publisher')},
|
||||
{label: 'Published', icon: '', field: 'publishedDate', command: () => this.sortBooks('publishedDate')},
|
||||
{label: 'Pages', icon: '', field: 'pageCount', command: () => this.sortBooks('pageCount')},
|
||||
|
||||
@@ -9,6 +9,7 @@ export class SortService {
|
||||
|
||||
private readonly fieldExtractors: Record<string, (book: Book) => any> = {
|
||||
title: (book) => book.metadata?.title?.toLowerCase() || null,
|
||||
author: (book) => book.metadata?.authors?.map(a => a.toLowerCase()).join(", ") || null,
|
||||
publishedDate: (book) =>book.metadata?.publishedDate === null ? null : new Date(book.metadata?.publishedDate!).getTime(),
|
||||
publisher: (book) => book.metadata?.publisher || null,
|
||||
pageCount: (book) => book.metadata?.pageCount || null,
|
||||
|
||||
Reference in New Issue
Block a user