Im using Ember v1.0.0,
Ember-Data v1.0.0-beta.3
and building using Ember-tools.
Inside my order_controller
, I've got an action called: delivered
. Once triggered, I want to make some changes to the current object (no problems here) -- but I also want to query an object from this same model and make some changes to it.
Heres my ObjectController:
var OrderController = Ember.ObjectController.extend({
actions: {
edit: function(){
this.transitionToRoute('order.edit');
},
delivered: function(){
// orders are sorted by "sequence" attr.
var current_sequence = this.get('sequence');
// find the next order in pipeline
var next_sequence = current_sequence+=1;
// HERE is the challenge!
var next_order = App.Order.find({sequence: next_sequence});
this.set('up_next', false);
next_order.set('up_next', true);
this.transitionToRoute('order', next_order.id)
}
}
});
module.exports = OrderController;
Im using FIXTURES:
Order.FIXTURES = [
{
id: 1,
name: "John Doe",
email: "john@doe.com",
telephone: "263663636",
address: "123 Example Rd.",
......
sequence: 4,
done: false,
up_next: false
},
Basically Im looking for a way to query records from inside the ObjectController with more specific attributes than just ID.
Thanks!