Random sort option for libraries and shelves (#1817)
This commit is contained in:
@@ -22,6 +22,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: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING },
|
{ label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING },
|
||||||
|
{ label: 'Random', field: 'random', direction: SortDirection.ASCENDING },
|
||||||
];
|
];
|
||||||
|
|
||||||
constructor(private applySortOption: (sort: SortOption) => void) {}
|
constructor(private applySortOption: (sort: SortOption) => void) {}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export class SortService {
|
|||||||
addedOn: (book) => book.addedOn ? new Date(book.addedOn).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,
|
fileName: (book) => book.fileName,
|
||||||
|
random: (book) => Math.random(),
|
||||||
};
|
};
|
||||||
|
|
||||||
applySort(books: Book[], selectedSort: SortOption | null): Book[] {
|
applySort(books: Book[], selectedSort: SortOption | null): Book[] {
|
||||||
|
|||||||
+2
-1
@@ -44,7 +44,8 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
|
|||||||
{label: 'Goodreads #', field: 'goodreadsReviewCount'},
|
{label: 'Goodreads #', field: 'goodreadsReviewCount'},
|
||||||
{label: 'Hardcover Rating', field: 'hardcoverRating'},
|
{label: 'Hardcover Rating', field: 'hardcoverRating'},
|
||||||
{label: 'Hardcover #', field: 'hardcoverReviewCount'},
|
{label: 'Hardcover #', field: 'hardcoverReviewCount'},
|
||||||
{label: 'Pages', field: 'pageCount'}
|
{label: 'Pages', field: 'pageCount'},
|
||||||
|
{label: 'Random', field: 'random'},
|
||||||
];
|
];
|
||||||
|
|
||||||
entityTypeOptions = [
|
entityTypeOptions = [
|
||||||
|
|||||||
Reference in New Issue
Block a user