Fixed: Initial sorting for Next Airing

This commit is contained in:
Mark McDowall
2014-01-16 09:18:53 -08:00
parent 442ab2b7c4
commit 4962db3b6a
3 changed files with 36 additions and 28 deletions

View File

@@ -6,8 +6,9 @@ define(
'backbone.pageable',
'Series/SeriesModel',
'api!series',
'Mixins/AsPersistedStateCollection'
], function (_, Backbone, PageableCollection, SeriesModel, SeriesData, AsPersistedStateCollection) {
'Mixins/AsPersistedStateCollection',
'moment'
], function (_, Backbone, PageableCollection, SeriesModel, SeriesData, AsPersistedStateCollection, Moment) {
var Collection = PageableCollection.extend({
url : window.NzbDrone.ApiRoot + '/series',
model: SeriesModel,
@@ -19,6 +20,18 @@ 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 () {
@@ -49,5 +62,7 @@ define(
var MixedIn = AsPersistedStateCollection.call(Collection);
var collection = new MixedIn(SeriesData);
collection.initialSort();
return collection;
});