24 lines
1.4 KiB
CoffeeScript
24 lines
1.4 KiB
CoffeeScript
App.TableController = Ember.Controller.extend
|
|
join_request_sent: (-> @get('controllers.application.join_request_sent')).property('controllers.application.join_request_sent')
|
|
tableCanTakeOrders: (->
|
|
return false unless @get('supplier.can_take_orders')
|
|
list = @get('globals.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')
|
|
supplier: Ember.computed 'model.supplier', -> @get('model.supplier')
|
|
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 # no point in joining tables that are not occupied
|
|
).property('controllers.application.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'controllers.application.list.table.id')
|
|
actions:
|
|
joinOccupiedTable: ->
|
|
Ember.$.post("#{$data_host}/user/join_occupied_table.json", table_id: @get('model.id'))
|
|
@set 'controllers.application.join_request_sent', true # keeps the button deactivated
|