From d89d9e67c2a3df1cecea6f7f5d29661c7172d6ae Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 16 Jan 2014 12:37:31 -0800 Subject: [PATCH] NextAiring sorting is not as drunk anymore --- src/UI/Mixins/AsPersistedStateCollection.js | 4 +++- src/UI/Series/Index/SeriesIndexLayout.js | 4 ++-- src/UI/Series/SeriesCollection.js | 23 ++++++++++----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/UI/Mixins/AsPersistedStateCollection.js b/src/UI/Mixins/AsPersistedStateCollection.js index 0a3be931d..879c05427 100644 --- a/src/UI/Mixins/AsPersistedStateCollection.js +++ b/src/UI/Mixins/AsPersistedStateCollection.js @@ -68,9 +68,11 @@ define( var key = this.state.sortKey; var order = this.state.order; - if (this.sorters && this.sorters[key] && this.mode === 'client') { + if (this[key] && this.mode === 'client') { var sortValue = this[key]; + this.setSorting(key, order, { sortValue: sortValue }); + var comparator = this._makeComparator(key, order, sortValue); this.fullCollection.comparator = comparator; this.fullCollection.sort(); diff --git a/src/UI/Series/Index/SeriesIndexLayout.js b/src/UI/Series/Index/SeriesIndexLayout.js index 52f382e02..416d1ec1a 100644 --- a/src/UI/Series/Index/SeriesIndexLayout.js +++ b/src/UI/Series/Index/SeriesIndexLayout.js @@ -75,7 +75,7 @@ define( name : 'nextAiring', label : 'Next Airing', cell : RelativeDateCell, - sortValue : SeriesCollection.sorters.nextAiring + sortValue : SeriesCollection.nextAiring }, { name : 'percentOfEpisodes', @@ -152,7 +152,7 @@ define( { title : 'Next Airing', name : 'nextAiring', - sortValue : SeriesCollection.sorters.nextAiring + sortValue : SeriesCollection.nextAiring }, { title: 'Episodes', diff --git a/src/UI/Series/SeriesCollection.js b/src/UI/Series/SeriesCollection.js index 1b48ba6e5..629ed799e 100644 --- a/src/UI/Series/SeriesCollection.js +++ b/src/UI/Series/SeriesCollection.js @@ -20,18 +20,6 @@ define( pageSize: 1000 }, - sorters: { - nextAiring: function (model) { - var nextAiring = model.get('nextAiring'); - - if (!nextAiring) { - return Number.MAX_VALUE; - } - - return Moment(nextAiring).unix(); - } - }, - mode: 'client', save: function () { @@ -57,6 +45,17 @@ define( }); return proxy.save(); + }, + + //Sorters + nextAiring: function (model, attr) { + var nextAiring = model.get(attr); + + if (!nextAiring) { + return Number.MAX_VALUE; + } + + return Moment(nextAiring).unix(); } });