From 78ee6afbae94d403cc79d4c0309551f33cc74136 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 15 Aug 2019 18:12:19 -0700 Subject: [PATCH] Fixed: Episode Progress custom filtering on series list page --- .../src/Store/Actions/seriesIndexActions.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/frontend/src/Store/Actions/seriesIndexActions.js b/frontend/src/Store/Actions/seriesIndexActions.js index 5eb07ce2f..64a356ba7 100644 --- a/frontend/src/Store/Actions/seriesIndexActions.js +++ b/frontend/src/Store/Actions/seriesIndexActions.js @@ -1,7 +1,7 @@ import moment from 'moment'; import { createAction } from 'redux-actions'; import sortByName from 'Utilities/Array/sortByName'; -import { filterBuilderTypes, filterBuilderValueTypes, sortDirections } from 'Helpers/Props'; +import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, sortDirections } from 'Helpers/Props'; import createSetTableOptionReducer from './Creators/Reducers/createSetTableOptionReducer'; import createSetClientSideCollectionSortReducer from './Creators/Reducers/createSetClientSideCollectionSortReducer'; import createSetClientSideCollectionFilterReducer from './Creators/Reducers/createSetClientSideCollectionFilterReducer'; @@ -246,7 +246,27 @@ export const defaultState = { selectedFilterKey: 'all', filters, - filterPredicates, + + filterPredicates: { + ...filterPredicates, + + episodeProgress: function(item, filterValue, type) { + const { statistics = {} } = item; + + const { + episodeCount = 0, + episodeFileCount + } = statistics; + + const progress = episodeCount ? + episodeFileCount / episodeCount * 100 : + 100; + + const predicate = filterTypePredicates[type]; + + return predicate(progress, filterValue); + } + }, filterBuilderProps: [ {