import Ember from 'ember'
import PagedRemoteArray from 'ember-cli-dunlop/utils/paged-remote-array'
export filters = Ember.Object.create
  workflow_group_id_in: []
  state_in: []
  s: 'project_instance_reference_date asc'
export default Ember.Route.extend
  modelName: 'panda/project-instance-group'
  queryParams:
    state:   {refreshModel: true}
    page:    {refreshModel: true}
    perPage: {refreshModel: true}

  setupController: (controller, model) ->
    controller.set 'filters', filters
    controller.set 'project', @modelFor('project.show')
    @_super arguments...

  model: (params) ->
    project = @modelFor 'project.show'
    filters.set('project_id', project.id)
    filters.set('state_in', params.state.split(',')) if params.state
    PagedRemoteArray.create
      modelName: @modelName
      store:       @store
      filters: filters
      page:        params.page || 1
      perPage:     params.perPage || 30
