46 lines
1.7 KiB
CoffeeScript
46 lines
1.7 KiB
CoffeeScript
App.IndexController = Ember.ObjectController.extend
|
|
needs: ['application']
|
|
lists: (-> @store.all('list')).property()
|
|
orders: (-> @store.all('order')).property()
|
|
sections: (-> @store.all('section')).property()
|
|
active_lists: (->
|
|
if @get('controllers.application.active_section.id')
|
|
@get('lists').filter (l)=>( l.get('section.id') == @get('controllers.application.active_section.id') && l.get('state') == 'active' )
|
|
else
|
|
@get('lists').filterProperty('state', 'active')
|
|
).property('lists.@each.state', 'controllers.application.active_section.id')
|
|
|
|
active_section: (-> @get('controllers.application.active_section')).property('controllers.application.active_section')
|
|
active_orders: (->
|
|
if @get('active_section.id')
|
|
@get('orders').filter (o)=>( o.get('section.id') == @get('active_section.id') && o.get('needs_supplier_attention') )
|
|
else
|
|
@get('orders').filter (o)->( o.get('needs_supplier_attention') )
|
|
).property('orders.@each.state', 'active_section.id')
|
|
|
|
actions:
|
|
###
|
|
markListAsHelped: (id)->
|
|
if list = App.List.findCached(id)
|
|
list.is_helped()
|
|
|
|
closeList: (list)->
|
|
@send 'openModal', 'modal_close_list', list
|
|
# list.close()
|
|
###
|
|
|
|
markOrderDelivered: (id)->
|
|
$.post('/supplier/order_is_delivered', order_id: id)
|
|
if order = App.Order.findCached(id)
|
|
order.set('state', 'delivered')
|
|
|
|
markOrderActive: (id)->
|
|
$.post('/supplier/mark_order_in_process', order_id: id)
|
|
if order = App.Order.findCached(id)
|
|
order.set('state', 'active')
|
|
cancelOrder: (order)->
|
|
$.post "/supplier/orders/#{order.id}/cancel"
|
|
order.set 'state', 'cancelled'
|
|
showList: (id)->
|
|
@transitionToRoute 'list', id
|