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_action'
= page-title 'models.plural.project_instance_action'
  = pagination-progress content=filtered_project_instance_actions class='between-brackets'
  .ui.top-right.pagination.menu= page-numbers content=filtered_project_instance_actions showFL=true
  = ui-dropdown class='violet button pull-right'
    .default.text Export
    i.dropdown.icon
    .menu
      .item
        a href=export_human_url: span Human
      .item
        a href=export_technical_url: span Technical
table.ui.bottom.attached.stiped.table
  thead
    tr
      th= t 'models.organization'
      th= t 'models.project_instance_group'
      th= t 'models.workflow_action_definition'
      th= t 'models.project_instance'
      th= t 'attributes.project_instance_action.state'
      th= t 'attributes.project_instance_action.notes'
      /  ui-dropdown class='right basic labeled icon' action='nothing'
          i.dropdown.icon
          span.ui.tiny.header class=filter.state_in.length:active-filter
            = t 'attributes.project_instance_action.state'
          .menu
            each globals.project_instance_action.states as |state|
              ui-checkbox class='item' label=state onChange=(action 'toggle_filter' 'state_in' state)
      th= t 'attributes.project_instance_action.target_date'
      th= t 'attributes.project_instance_action.value'
    table-filters content=model filters=filters as |filter|
      = filter.dropdown-select key='workflow_action_definition_organization_id_eq' options=organizations labelPath='name'
      = filter.dropdown-select key='project_instance_group_workflow_group_id' options=project.sorted_workflow_groups labelPath='name'
      /  ui-dropdown class='right basic labeled icon' action='nothing'
          i.dropdown.icon
          span.ui.tiny.header class=filter.project_instance_group_workflow_group_id_in.length:active-filter
            = t 'models.project_instance_group'
          .menu
            each project.sorted_workflow_groups as |workflow_group|
              ui-checkbox class='item' label=workflow_group.name onChange=(action 'toggle_filter' 'project_instance_group_workflow_group_id_in' workflow_group.id)
      /th class=filters.workflow_action_definition_id_in.length:active-filter
        ui-dropdown class='right basic labeled icon' action='nothing' fullTextSearch=true
          /i.dropdown.icon
          /== workflow_action_definitions_filter_html
          if filters.workflow_action_definition_id_in.length
            ui-popup html=(join '<br><hr>' (map-by 'title' filter_workflow_action_definitions)) position='bottom center'
              span= filters.workflow_action_definition_id_in.length
              '
              if (eq filters.workflow_action_definition_id_in.length 1) (t 'models.workflow_action_definition') (t 'models.plural.workflow_action_definition')
          else
            i.filter.icon
          .menu
            .ui.icon.search.input
              i.search.icon
              input type='text' name='search' placeholder='Search&hellip;'
            .scrolling.menu
              each project.workflow_action_definitions as |workflow_action_definition|
                ui-checkbox class='item' checked=(contains workflow_action_definition.id filters.workflow_action_definition_id_in) label=workflow_action_definition.title onChange=(action 'toggle_filter' 'workflow_action_definition_id_in' workflow_action_definition.id)
        if filters.workflow_action_definition_id_in.length
          i.remove.icon{action 'clear_filter' 'workflow_action_definition_id_in'}
      = filter.dropdown-select-multiple key='workflow_action_definition_id_in' options=project.sorted_workflow_action_definitions labelPath='title'
      = filter.input key='project_instance_client_identifier_cont'
      = filter.dropdown-select-multiple key='state_in' options=globals.project_instance_action.states translationPath='attributes.state'
      = filter.input key='notes_cont'
      = filter.date-range key='target_date' expandingTime=true weekSelector=true
      /th class=date_filter_active:active-filter
        ui-dropdown class='right basic labeled top right pointing icon' action='nothing'
          = date_filter_text
          .menu
            .item= ui-calendar-moment type='date' momentValue=filter.date_gteq onChange=(action (mut filter.date_gteq)) allowClear=true
            .divider
            .item= ui-calendar-moment type='date' momentValue=filter.date_lteq onChange=(action (mut filter.date_lteq)) allowClear=true
            .divider
            .item
              button.ui.primary.button{action 'set_filter_date_today'}= t 'date.today'
              button.ui.primary.button{action 'set_filter_date_this_week'}= t 'date.this_week'
        if date_filter_active
          i.remove.icon{action 'clear_filter' 'date_gteq' 'date_lteq'}
      th
  tbody
    each filtered_project_instance_actions as |project_instance_action|
      tr
        td= project_instance_action.workflow_action_definition.organization.name
        td
          if project_instance_action.project_instance_group.id
            = link-to 'project.show.project-instance-group.show' project_instance_action.project_instance.project.id project_instance_action.project_instance_group.id
              span= project_instance_action.project_instance_group.workflow_group.name
        td= project_instance_action.workflow_action_definition.title
        td= link-to 'project.show.project-instance.show' project_instance_action.project_instance.project.id project_instance_action.project_instance.id
          span= project_instance_action.project_instance.client_identifier
        td= state-badge project_instance_action.state
        td= project-instance-action/compact-notes-display record=project_instance_action
        td= format-date project_instance_action.target_date format=globals.date_formatting
        td= project/instance-action-value-display project_instance_action=project_instance_action
