Naming fixes

This commit is contained in:
2013-09-24 09:18:48 +02:00
parent 5650ada04c
commit faec08c26b
4 changed files with 10 additions and 8 deletions
@@ -3,7 +3,9 @@ Qsupplier.App.Order = DS.Model.extend
state: attr('string') state: attr('string')
list: DS.belongsTo('Qsupplier.App.List') list: DS.belongsTo('Qsupplier.App.List')
total_amount: attr('number') total_amount: attr('number')
#products: attr('object') product_orders: attr('object')
products: DS.hasMany('Qsupplier.App.Product')
active: (-> @get('state') == 'active').property('state') active: (-> @get('state') == 'active').property('state')
delivered: (-> @get('state') == 'delivered').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 {{view.content.display}}
td.numeric.table_number {{view.content.table_number}} td.numeric.table_number {{view.content.table_number}}
td.section_title {{view.content.section_title}} td.section_title {{view.content.section_title}}
td.currency {{currency total_amount}} td.currency {{currency view.content.total_amount}}
td.actions 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 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>*/ /*<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' tagName: 'tr'
templateName: 'active_order' templateName: 'active_order'
classNameBindings: ['content.active:active', 'content.delivered:delivered'] classNameBindings: ['content.active:active', 'content.delivered:delivered']
didInsertElement: ->
debugger
+5 -3
View File
@@ -110,12 +110,14 @@ class Order
return @with_products_as_json if @with_products_as_json.present? return @with_products_as_json if @with_products_as_json.present?
product_orders.include_relation(:product) product_orders.include_relation(:product)
ho = as_json 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 order_total = 0.0
for product_order in product_orders for product_order in product_orders
order_total += (product_order.amount * product_order.price).round(2) 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.product_id, number: product_order.amount, price: product_order.price}
ho[:products] << {name: product_order.product.name, id: product_order.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 end
ho[:total_amount] = order_total.round(2) ho[:total_amount] = order_total.round(2)
@with_products_as_json = ho @with_products_as_json = ho