d-breadcrumbs as |breadcrumb|
  breadcrumb.item
    = link-to 'project.index': span= t 'models.plural.project'
  breadcrumb.item
    span= t 'models.project'
    span : 
    = link-to 'project.show' project: span= project.name
  breadcrumb.item active=true
   span= t 'models.plural.project_instance'
.ui.right.floated.pagination.menu= page-numbers content=filtered_project_instances showFL=true
= page-title 'models.plural.project_instance'
  = pagination-progress content=filtered_project_instances class='between-brackets'
table.ui.table
  thead
    tr
      th= t 'attributes.project_instance.client_identifier'
      th= t 'attributes.project_instance.state'
      th= t 'models.project_scenario'
      th= t 'attributes.project_instance.reference_date'
      if project.instance_scope_batch
        th= t 'attributes.project_instance.batch_size'
      th.actions
        = push-action type='new' action=(route-action 'new_project_instance')
        button.ui.small.icon.button{action 'openModal' 'project/load-project-instances' (hash model=project)}
          i.upload.icon
    table-filters content=model filters=filters as |filter|
      = filter.input key='client_identifier_cont'
      = filter.dropdown-select-multiple key='state_in' options=globals.project_instance.states translationPath='attributes.state'
      = filter.dropdown-select key='project_scenario_id' options=project.sorted_project_scenarios labelPath='name'
      = filter.date-range key='reference_date'
      if project.instance_scope_batch
        th
      th= pagination-progress content=filtered_project_instances


    /tr.filters
      th
      th
        ui-dropdown class='right basic labeled icon' action='nothing'
          /i.dropdown.icon
          span.ui.tiny.header class=filter.project_scenario_id_in.length:active-filter
            if filter.project_scenario_id_in.length
              ui-popup html=(join '<br><hr>' (map-by 'name' filter_project_scenarios)) position='bottom center'
                span= filter.project_scenario_id_in.length
                '
                if (eq filter.project_scenario_id_in.length 1) (t 'models.project_scenario') (t 'models.plural.project_scenario')
                '
                i.remove.icon{action 'clear_filter' 'project_scenario_id_in'}
            else
              i.filter.icon
          .menu
            each project.sorted_project_scenarios as |project_scenario|
              ui-checkbox class='item' checked=(contains project_scenario.id filter.project_scenario_id_in) label=project_scenario.name onChange=(action 'toggle_filter' 'project_scenario_id_in' project_scenario.id)
      th
        ui-dropdown class='right basic labeled top right pointing icon' action='nothing'
          span.ui.tiny.header class=reference_date_filter_active:active-filter
            = reference_date_filter_text
          i.dropdown.icon
          .menu
            .item= ui-calendar-moment type='date' momentValue=filter.reference_date_gteq onChange=(action (mut filter.reference_date_gteq)) allowClear=true
            .divider
            .item= ui-calendar-moment type='date' momentValue=filter.reference_date_lteq onChange=(action (mut filter.reference_date_lteq)) allowClear=true
      if project.instance_scope_batch
        th
      th.actions

  tbody
    each filtered_project_instances as |project_instance|
      tr
        td
          = link-to 'project.show.project-instance.show' project.id project_instance.id
            = project_instance.client_identifier
        td= state-badge project_instance.state
        td= project_instance.project_scenario.name
        td= date project_instance.reference_date
        if project.instance_scope_batch
          td= project_instance.batch_size
        td.actions
