Backbone collection will not sort properly.... wtf

Sorting on the server now for calendar
pull/4/head
Mark McDowall 12 years ago
parent 06c1055b0d
commit 18d7963ade

@ -37,7 +37,7 @@ namespace NzbDrone.Api.Calendar
var resources = ToListResource(() => _episodeService.EpisodesBetweenDates(start, end)) var resources = ToListResource(() => _episodeService.EpisodesBetweenDates(start, end))
.LoadSubtype(e => e.SeriesId, _seriesRepository); .LoadSubtype(e => e.SeriesId, _seriesRepository);
return resources.ToList(); return resources.OrderBy(e => e.AirDate).ToList();
} }
} }
} }

@ -8,10 +8,24 @@ define(
url : window.ApiRoot + '/calendar', url : window.ApiRoot + '/calendar',
model: EpisodeModel, model: EpisodeModel,
comparator: function (model) { comparator: function (model1, model2) {
var date = new Date(model.get('airDate')); var airDate1 = model1.get('airDate');
var time = date.getTime(); var date1 = Date.create(airDate1);
return time; var time1 = date1.getTime();
var airDate2 = model2.get('airDate');
var date2 = Date.create(airDate2);
var time2 = date2.getTime();
if (time1 < time2){
return -1;
}
if (time1 > time2){
return 1;
}
return 0;
} }
}); });
}); });

@ -78,7 +78,6 @@
} }
h4 { h4 {
text-transform : none !important;
font-weight : 500; font-weight : 500;
color : #008dcd; color : #008dcd;
margin : 5px 0px; margin : 5px 0px;
@ -113,6 +112,7 @@
line-height : 1em; line-height : 1em;
color : #555555; color : #555555;
font-weight : 300; font-weight : 300;
text-transform: uppercase;
} }
h1 { h1 {

@ -14,7 +14,7 @@ define(
return Date.create(this.get('airDate')).format('{dd}'); return Date.create(this.get('airDate')).format('{dd}');
}, },
month : function () { month : function () {
return Date.create(this.get('airDate')).format('{MON}'); return Date.create(this.get('airDate')).format('{Mon}');
}, },
startTime : function () { startTime : function () {
var start = Date.create(this.get('airDate')); var start = Date.create(this.get('airDate'));

Loading…
Cancel
Save