From 1b6694739edd1205c230d877e773349285c398d0 Mon Sep 17 00:00:00 2001 From: ta264 Date: Tue, 23 Nov 2021 21:55:33 +0000 Subject: [PATCH] Fixed: Sorting by Series, Rating and Status on author details page Fixes #1315 --- frontend/src/Store/Actions/bookActions.js | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/frontend/src/Store/Actions/bookActions.js b/frontend/src/Store/Actions/bookActions.js index b20ac56aa..cf807dd40 100644 --- a/frontend/src/Store/Actions/bookActions.js +++ b/frontend/src/Store/Actions/bookActions.js @@ -109,6 +109,35 @@ export const sortPredicates = { const { statistics = {} } = item; return statistics.sizeOnDisk || 0; + }, + + series: function(item) { + return item.seriesTitle; + }, + + rating: function(item) { + return item.ratings.value; + }, + + status: function(item) { + let result = 0; + + const hasBookFile = !!item.statistics.bookFileCount; + const isAvailable = Date.parse(item.releaseDate) < new Date(); + + if (isAvailable) { + result++; + } + + if (item.monitored) { + result += 2; + } + + if (hasBookFile) { + result += 4; + } + + return result; } }; @@ -179,7 +208,8 @@ export const defaultState = { { name: 'status', label: 'Status', - isVisible: true + isVisible: true, + isSortable: true }, { name: 'actions',