Fix new product orders display for users

This commit is contained in:
2015-08-28 22:05:19 +02:00
parent 08a8de0edc
commit 5d1ecd81c8
8 changed files with 11 additions and 11 deletions
@@ -10,4 +10,4 @@ App.MenuItemProductOrdersComponent = Ember.Component.extend
#orderTotal: Ember.computed 'product_orders.@each.total', -> #orderTotal: Ember.computed 'product_orders.@each.total', ->
# debugger # debugger
click: -> click: ->
@get('targetObject').transitionToRoute 'product_orders' @get('targetObject').transitionToRoute 'product-orders'
@@ -1,8 +1,10 @@
App.ProductOrdersListComponent = Ember.Component.extend App.NewProductOrdersListComponent = Ember.Component.extend
orderTotal: (-> orderTotal: (->
#Math.round(Math.random()*100) #Math.round(Math.random()*100)
@get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0) @get('product_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
).property('product_orders.@each.quantity') ).property('product_orders.@each.quantity')
all_product_orders: Ember.computed -> @store.peekAll('product_order')
product_orders: Ember.computed 'all_product_orders.@each.isNew', -> @get('all_product_orders').filterBy('isNew')
#product_orders: (->@get('model')).property('model') #product_orders: (->@get('model')).property('model')
#product_orders: -> @store.peekAll('product_order') #product_orders: -> @store.peekAll('product_order')
showTotal: (-> if @get('product_orders.length') && @get('product_orders.length') > 1 then true else false ).property('product_orders.length') showTotal: (-> if @get('product_orders.length') && @get('product_orders.length') > 1 then true else false ).property('product_orders.length')
@@ -16,8 +16,6 @@ App.TableController = Ember.Controller.extend
return false if @get('globals.list') # if you already have an active list, do not join another return false if @get('globals.list') # if you already have an active list, do not join another
if @get('model.occupied') then true else false # no point in joining tables that are not occupied if @get('model.occupied') then true else false # no point in joining tables that are not occupied
).property('globals.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'globals.list.table.id') ).property('globals.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'globals.list.table.id')
all_product_orders: Ember.computed -> @store.peekAll('product_order')
new_product_orders: Ember.computed 'all_product_orders.@each.isNew', -> @get('all_product_orders').filterBy('isNew')
actions: actions:
joinOccupiedTable: -> joinOccupiedTable: ->
Ember.$.post("#{$data_host}/user/join_occupied_table.json", table_id: @get('model.id')) Ember.$.post("#{$data_host}/user/join_occupied_table.json", table_id: @get('model.id'))
@@ -18,9 +18,9 @@ App.Product = DS.Model.extend
addOrderItem: (options = {})-> addOrderItem: (options = {})->
#if existing = @store.all('product_order').find((po)-> po.get('product') == product and not po.get('order')) #if existing = @store.all('product_order').find((po)-> po.get('product') == product and not po.get('order'))
if options.product_variant if options.product_variant
existing = @get('product_orders').find( (po)-> !po.get('isNew') and po.get('product_variant') is options.product_variant ) existing = @get('product_orders').find( (po)-> po.get('isNew') and po.get('product_variant') is options.product_variant )
else else
existing = @get('product_orders').find( (po)-> !po.get('isNew') ) existing = @get('product_orders').find( (po)-> po.get('isNew') )
if existing if existing
existing.increment() existing.increment()
@@ -13,7 +13,7 @@ App.Router.map ->
@resource 'lists', -> @resource 'lists', ->
@resource 'list', path: ':list_id' @resource 'list', path: ':list_id'
@route 'settings' @route 'settings'
@route 'product_orders' @route 'product-orders'
@route 'error' @route 'error'
@route 'about' @route 'about'
@route 'scanning' @route 'scanning'
@@ -0,0 +1 @@
= new-product-orders-list
@@ -1,4 +1,4 @@
.row .row: .small-12.columns
h3 h3
span.supplier-name= supplier.name span.supplier-name= supplier.name
span.table-number span.table-number
@@ -11,10 +11,9 @@
span=t 'join_request.requestor.waiting_for_approval' span=t 'join_request.requestor.waiting_for_approval'
else else
button.join-table-button{action "joinOccupiedTable"}=t 'join_request.requestor.join_this_table' button.join-table-button{action "joinOccupiedTable"}=t 'join_request.requestor.join_this_table'
.row
if tableCanTakeOrders if tableCanTakeOrders
.large-6.columns= menu-product-categories product_categories=supplier.product_categories orderProducts=true .large-6.columns= menu-product-categories product_categories=supplier.product_categories orderProducts=true
.large-6.columns= product-orders-list table=model product_orders=new_product_orders .large-6.columns= new-product-orders-list table=model
else else
.large12= menu-product-categories product_categories=supplier.product_categories orderProducts=false .large12= menu-product-categories product_categories=supplier.product_categories orderProducts=false
each new_product_orders as |po|
.row: b=po.display