Naming fixes
This commit is contained in:
@@ -3,7 +3,9 @@ Qsupplier.App.Order = DS.Model.extend
|
||||
state: attr('string')
|
||||
list: DS.belongsTo('Qsupplier.App.List')
|
||||
total_amount: attr('number')
|
||||
#products: attr('object')
|
||||
products: DS.hasMany('Qsupplier.App.Product')
|
||||
product_orders: attr('object')
|
||||
active: (-> @get('state') == 'active').property('state')
|
||||
delivered: (-> @get('state') == 'delivered').property('state')
|
||||
display: (->
|
||||
@get('product_orders').map((po)-> "#{po.product_name} (#{po.quantity})").join(',')
|
||||
).property('product_orders')
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
td {{view.content.display}}
|
||||
td.numeric.table_number {{view.content.table_number}}
|
||||
td.section_title {{view.content.section_title}}
|
||||
td.currency {{currency total_amount}}
|
||||
td.currency {{currency view.content.total_amount}}
|
||||
td.actions
|
||||
/*<button id="order-in-process-button-{{id}}" class="btn btn-success {{^can_process}}hide{{/can_process}}" onclick="Qsupplier.mark_order_in_process('{{id}}')" data-t="order.being_processed"></button>*/
|
||||
/*<button class="btn btn-inverse" onclick="Qsupplier.mark_order_delivered('{{id}}')" data-t="order.being_served"></button>*/
|
||||
|
||||
@@ -2,5 +2,3 @@ Qsupplier.App.ActiveOrderView = Ember.View.extend
|
||||
tagName: 'tr'
|
||||
templateName: 'active_order'
|
||||
classNameBindings: ['content.active:active', 'content.delivered:delivered']
|
||||
didInsertElement: ->
|
||||
debugger
|
||||
|
||||
+5
-3
@@ -110,12 +110,14 @@ class Order
|
||||
return @with_products_as_json if @with_products_as_json.present?
|
||||
product_orders.include_relation(:product)
|
||||
ho = as_json
|
||||
ho[:products] = []
|
||||
# products are depricated. It is a name for something it is not!!!!!
|
||||
ho[:products] = []
|
||||
ho[:product_orders] = []
|
||||
order_total = 0.0
|
||||
for product_order in product_orders
|
||||
order_total += (product_order.amount * product_order.price).round(2)
|
||||
# Use product order id as id since the price can be different for products and the state should be preserved
|
||||
ho[:products] << {name: product_order.product.name, id: product_order.id, number: product_order.amount, price: product_order.price}
|
||||
ho[:products] << {name: product_order.product.name, id: product_order.product_id, number: product_order.amount, price: product_order.price}
|
||||
ho[:product_orders] << {product_name: product_order.product.name, id: product_order.id, quantity: product_order.amount, price: product_order.price}
|
||||
end
|
||||
ho[:total_amount] = order_total.round(2)
|
||||
@with_products_as_json = ho
|
||||
|
||||
Reference in New Issue
Block a user