From 529522cf74c0949aea69d19efeda6c8ad226d17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Staicu?= Date: Fri, 31 Oct 2025 09:23:47 +0200 Subject: [PATCH] close #1180 - add sort by fileName (#1482) --- .../book/components/book-browser/sorting/BookSorter.ts | 1 + booklore-ui/src/app/features/book/service/sort.service.ts | 3 ++- .../dashboard-settings/dashboard-settings.component.ts | 2 ++ .../view-preferences/view-preferences.component.ts | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts b/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts index 91588009b..ad9ffdf2a 100644 --- a/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts +++ b/booklore-ui/src/app/features/book/components/book-browser/sorting/BookSorter.ts @@ -6,6 +6,7 @@ export class BookSorter { sortOptions: SortOption[] = [ { label: 'Title', field: 'title', direction: SortDirection.ASCENDING }, { label: 'Title + Series', field: 'titleSeries', direction: SortDirection.ASCENDING }, + { label: 'File Name', field: 'fileName', direction: SortDirection.ASCENDING }, { label: 'Author', field: 'author', direction: SortDirection.ASCENDING }, { label: 'Last Read', field: 'lastReadTime', direction: SortDirection.ASCENDING }, { label: 'Added On', field: 'addedOn', direction: SortDirection.ASCENDING }, diff --git a/booklore-ui/src/app/features/book/service/sort.service.ts b/booklore-ui/src/app/features/book/service/sort.service.ts index e2080e768..75e26156a 100644 --- a/booklore-ui/src/app/features/book/service/sort.service.ts +++ b/booklore-ui/src/app/features/book/service/sort.service.ts @@ -38,7 +38,8 @@ export class SortService { .every((key) => book.metadata?.[key] === true), lastReadTime: (book) => book.lastReadTime ? new Date(book.lastReadTime).getTime() : null, addedOn: (book) => book.addedOn ? new Date(book.addedOn).getTime() : null, - fileSizeKb: (book) => book.fileSizeKb || null + fileSizeKb: (book) => book.fileSizeKb || null, + fileName:(book) => book.fileName, }; applySort(books: Book[], selectedSort: SortOption | null): Book[] { diff --git a/booklore-ui/src/app/features/dashboard/components/dashboard-settings/dashboard-settings.component.ts b/booklore-ui/src/app/features/dashboard/components/dashboard-settings/dashboard-settings.component.ts index 481d1cee9..243058581 100644 --- a/booklore-ui/src/app/features/dashboard/components/dashboard-settings/dashboard-settings.component.ts +++ b/booklore-ui/src/app/features/dashboard/components/dashboard-settings/dashboard-settings.component.ts @@ -7,6 +7,7 @@ import {CheckboxModule} from 'primeng/checkbox'; import {InputTextModule} from 'primeng/inputtext'; import {SelectModule} from 'primeng/select'; import {InputNumberModule} from 'primeng/inputnumber'; +import {SortDirection} from "../../../book/model/sort.model"; import {DashboardConfig, ScrollerConfig, ScrollerType} from '../../models/dashboard-config.model'; import {DashboardConfigService} from '../../services/dashboard-config.service'; import {MagicShelfService} from '../../../magic-shelf/service/magic-shelf.service'; @@ -56,6 +57,7 @@ export class DashboardSettingsComponent implements OnInit { sortFieldOptions = [ {label: 'Title', value: 'title'}, {label: 'Title + Series', value: 'titleSeries'}, + {label: 'File Name', field: 'fileName'}, {label: 'Date Added', value: 'addedOn'}, {label: 'Author', value: 'author'}, {label: 'Personal Rating', value: 'personalRating'}, diff --git a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts index 083ac0978..61078c0bf 100644 --- a/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts +++ b/booklore-ui/src/app/features/settings/view-preferences-parent/view-preferences/view-preferences.component.ts @@ -29,6 +29,7 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy { sortOptions = [ {label: 'Title', field: 'title'}, {label: 'Title + Series', field: 'titleSeries'}, + {label: 'File Name', field: 'fileName'}, {label: 'Author', field: 'author'}, {label: 'Last Read', field: 'lastReadTime'}, {label: 'Added On', field: 'addedOn'},