I have the following computed property
dailyAvailabilities: Ember.computed('availabilities@each.weekday', 'day', function() {
let day = moment(this.get('day')).format('dddd');
return this.get('availabilities').filterBy('weekday', day);
}),
the availability model looks like this
/models/availability.js
export default Model.extend({
weekday: attr('weekday'),
start: attr(),
end: attr()
});
where weekday
is a custom transform
/transforms/weekday.js
export default DS.Transform.extend({
deserialize(serialized) {
return moment().isoWeekday(serialized).format('dddd');
},
serialize(deserialized) {
return moment(deserialized).format('d');
}
});
Now when I go to a specific day, from a previous route I need to click once, go back and click again for the values to appear in the template. And if I reload the page all the values are gone. This doesn't happen if I filterBy()
other model attributes like start
or end
. So it's clearly something wrong with the weekday
but not sure what. Any directions on this are much appreciated.
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire