From 2fa0729158aa8f9a8db6edc87bf5ac191a6c5d98 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 19 Jun 2016 00:28:01 +0200 Subject: [PATCH] Fixed series filter 'missing' since percentOfEpisodes isn't always set. --- src/UI/Mixins/AsFilteredCollection.js | 21 +++++---------------- src/UI/Series/SeriesCollection.js | 6 +++--- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/UI/Mixins/AsFilteredCollection.js b/src/UI/Mixins/AsFilteredCollection.js index 8e7329514..4b3fd3272 100644 --- a/src/UI/Mixins/AsFilteredCollection.js +++ b/src/UI/Mixins/AsFilteredCollection.js @@ -31,27 +31,16 @@ module.exports = function() { self.shadowCollection = originalMakeFullCollection.call(this, models, options); var filterModel = function(model) { - if (!self.state.filterKey || !self.state.filterValue) { + if (_.isFunction(self.state.filterType)) { + return self.state.filterType(model); + } + + if (!self.state.filterKey) { return true; } else if (self.state.filterType === 'contains') { return model.get(self.state.filterKey).toLowerCase().indexOf(self.state.filterValue.toLowerCase()) > -1; } - else if (self.state.filterType === 'lt') { - return model.get(self.state.filterKey) < self.state.filterValue; - } - else if (self.state.filterType === 'gt') { - return model.get(self.state.filterKey) > self.state.filterValue; - } - else if (self.state.filterType === 'le') { - return model.get(self.state.filterKey) <= self.state.filterValue; - } - else if (self.state.filterType === 'ge') { - return model.get(self.state.filterKey) >= self.state.filterValue; - } - else if (self.state.filterType === 'ne') { - return model.get(self.state.filterKey) !== self.state.filterValue; - } else { return model.get(self.state.filterKey) === self.state.filterValue; } diff --git a/src/UI/Series/SeriesCollection.js b/src/UI/Series/SeriesCollection.js index 8dfaf0d99..bef8fe338 100644 --- a/src/UI/Series/SeriesCollection.js +++ b/src/UI/Series/SeriesCollection.js @@ -65,9 +65,9 @@ var Collection = PageableCollection.extend({ true ], 'missing' : [ - 'percentOfEpisodes', - 100, - 'lt' + null, + null, + function(model) { return model.get('episodeCount') !== model.get('episodeFileCount'); } ] },