13 lines
500 B
CoffeeScript
13 lines
500 B
CoffeeScript
attr = DS.attr
|
|
App.Order = DS.Model.extend
|
|
state: attr 'string'
|
|
list: DS.belongsTo('list')
|
|
table: DS.belongsTo('table')
|
|
product_orders: DS.hasMany('product_order', embedded: 'always')
|
|
total: (->
|
|
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
|
).property('product_orders.@each.quantity')
|
|
display: (->
|
|
@get('product_orders').map((po) -> "#{po.get('quantity')} x #{po.get('product.name')}").join(', ')
|
|
).property('product_orders.@each.quantity')
|