Qsupplier.App.ApplicationRoute = Ember.Route.extend
  beforeModel: ->
    # Preload only active lists and orders
    @store.find 'product_category'
    #@store.find 'order', state: 'active' included in list
  setupController: (controller)->
    # @set 'supplier', @store.find('supplier', supplier_id)
    supplier = @store.push 'supplier', supplier_object
    controller.set 'supplier', supplier

    @store.find 'list', state: 'active'
    @store.find 'section'

    controller.set 'product_categories', @store.all('product_category')
  actions:
    openModal: (modalName, model, options={})->
      controller_name = options.controller || modalName
      controller =  @controllerFor(controller_name)
      controller.set 'model', model
      controller.set 'modal_options', options
      @render modalName,
        into: 'application'
        outlet: 'modal'
        controller: controller_name
    closeModal: ->
      @disconnectOutlet
        outlet: 'modal'
        parentView: 'application'
    confirm: (options = {})->
      @send 'openModal', 'modal_confirm', Ember.Object.create
        title: options.title
        body: options.body
        cancel: options.cancel
        ok: options.ok
