Save progress
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
App.TableController = Ember.ObjectController.extend
|
||||
join_request_sent: false
|
||||
tableCanTakeOrders: (->
|
||||
return false unless @get('supplier.can_take_orders')
|
||||
list = @get('controllers.application.list')
|
||||
if list
|
||||
return false unless list.get('supplier.id') == @get('supplier.id')
|
||||
return false unless list.get('table.id') == @get('model.id')
|
||||
true
|
||||
else
|
||||
# no list and open supplier
|
||||
if @get('model.occupied') then false else true
|
||||
).property('controllers.application.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'controllers.application.list.table.id')
|
||||
showJoinButton: (->
|
||||
return false unless @get('supplier.can_take_orders')
|
||||
return false if @get('controllers.application.list') # if you already have an active list, do not join another
|
||||
if @get('model.occupied') then true else false
|
||||
).property('controllers.application.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'controllers.application.list.table.id')
|
||||
actions:
|
||||
addProduct: (product)->
|
||||
if existing = @store.all('product_order').find((po)-> po.get('product') == product and not po.get('order'))
|
||||
existing.increment()
|
||||
else
|
||||
@store.createRecord 'product_order', product: product
|
||||
joinOccupiedTable: ->
|
||||
#@secured =>
|
||||
$.post('/user/join_occupied_table.json', table_id: @get('model.id'))
|
||||
@set 'join_request_sent', true
|
||||
Reference in New Issue
Block a user