I am trying to use Emberjs sortProperties to sort content by date in this jsfiddle. My model has a startTime property which I tried to sort by but it didn't work. I then created a computed property called todayEvent in the controller which returns events that match the passed in date and I tried to sort that but it also didn't work. All I am trying to do is list events occurring on same day but in such a way that time of the day in chich event occurs is sorted in ascending order for example, an event occurring by 10am should be listed before those occurring by say 12pm.
This is the jsfiddle
The model:
App.TimeSlot = DS.Model.extend( {
startTime: DS.attr('date'),
endTime: DS.attr('date'),
allDay: DS.attr('boolean'),
soldOut: DS.attr('boolean')
});
The controller
App.TimeSlotController = Ember.ArrayController.extend({
content: [ ],
sortProperties: ['todayEvent'],
sortAscending: true,
day: Ember.A(['2013-10-25']),
todayEvent: function(){
self = this;
u = self.get('content');
console.log('u', u);
kl = u.filter(function(availableSlot) {
console.log ('a', availableSlot.get('startTime') );
return (moment(availableSlot.get('startTime')).format("YYYY-MM-DD") == self.get('day').toString() );
});
return kl;
}.property('day', 'content@each'),
});
The fixtureAdapter
App.TimeSlot.FIXTURES = [
{
id: 3,
startTime: moment.utc('2013-10-25T12:30:00+01:00',"YYYY-MM-DD HH:mm:ss" ),
allDay: true
},
{
id: 4,
startTime: moment.utc('2013-10-25T10:10:00+01:00',"YYYY-MM-DD HH:mm:ss" ),
allDay: true
},
{
id: 5,
startTime: moment.utc('2013-10-23 00:00 +01:00', "YYYY-MM-DD HH:mm"),
allDay: true
}
];