lundi 4 mars 2019

Ember.JS When I create a new record, how can it be Sorted

I have a view showing a ticket and it's replies.

The replies are reiceved ordered_by Created_at DESC

When I save a new reply here is what I do :

route :

model(params) {
return hash({
  ticket: this.store.findRecord(
    'ticket',params.ticket_id,{include: 'replies'}
  ),
  owners: this.get('store').query('adminUser',{filter: 'supporters'}),
  reply: this.store.createRecord('ticket/reply')
})
}

And the controller :

saveReply(reply){
  reply.set('ticket',this.get('model.ticket'))
  let promise=reply.save()
  promise.then(
    (reply)=>{
      this.set('model.reply',this.store.createRecord('ticket/reply'))
      return reply
    }
  )
  return promise
}

Instead of having the reply at the top of the list, it's at the bottom. How can I order the ticket.replies ?




Aucun commentaire:

Enregistrer un commentaire