Backbone collection will not sort properly.... wtf

Sorting on the server now for calendar
This commit is contained in:
Mark McDowall 2013-07-01 11:25:06 -07:00
parent 06c1055b0d
commit 18d7963ade
4 changed files with 21 additions and 7 deletions

View File

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

View File

@ -8,10 +8,24 @@ define(
url : window.ApiRoot + '/calendar',
model: EpisodeModel,
comparator: function (model) {
var date = new Date(model.get('airDate'));
var time = date.getTime();
return time;
comparator: function (model1, model2) {
var airDate1 = model1.get('airDate');
var date1 = Date.create(airDate1);
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;
}
});
});

View File

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

View File

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