.issues-filters
  .issues-state-filters
    %ul.center-top-menu
      %li{class: ("active" if params[:state] == 'opened')}
        = link_to page_filter_path(state: 'opened') do
          #{state_filters_text_for(:opened, @project)}

      - if defined?(type) && type == :merge_requests
        %li{class: ("active" if params[:state] == 'merged')}
          = link_to page_filter_path(state: 'merged') do
            #{state_filters_text_for(:merged, @project)}

        %li{class: ("active" if params[:state] == 'closed')}
          = link_to page_filter_path(state: 'closed') do
            #{state_filters_text_for(:closed, @project)}
      - else
        %li{class: ("active" if params[:state] == 'closed')}
          = link_to page_filter_path(state: 'closed') do
            #{state_filters_text_for(:closed, @project)}

      %li{class: ("active" if params[:state] == 'all')}
        = link_to page_filter_path(state: 'all') do
          #{state_filters_text_for(:all, @project)}

  .issues-details-filters.gray-content-block
    = form_tag page_filter_path(without: [:assignee_id, :author_id, :milestone_title, :label_name]), method: :get, class: 'filter-form' do
      - if controller.controller_name == 'issues' && can?(current_user, :admin_issue, @project)
        .check-all-holder
          = check_box_tag "check_all_issues", nil, false,
            class: "check_all_issues left"
      .issues-other-filters
        .filter-item.inline
          = users_select_tag(:assignee_id, selected: params[:assignee_id],
            placeholder: 'Assignee', class: 'trigger-submit', any_user: "Any Assignee", null_user: true, first_user: true, current_user: true)

        .filter-item.inline
          = users_select_tag(:author_id, selected: params[:author_id],
            placeholder: 'Author', class: 'trigger-submit', any_user: "Any Author", first_user: true, current_user: true)

        .filter-item.inline.milestone-filter
          = select_tag('milestone_title', projects_milestones_options,
            class: 'select2 trigger-submit', include_blank: true,
            data: {placeholder: 'Milestone'})

        .filter-item.inline.labels-filter
          = select_tag('label_name', projects_labels_options,
            class: 'select2 trigger-submit', include_blank: true,
            data: {placeholder: 'Label'})

        .pull-right
          = render 'shared/sort_dropdown'

    - if controller.controller_name == 'issues'
      .issues_bulk_update.hide
        = form_tag bulk_update_namespace_project_issues_path(@project.namespace, @project), method: :post  do
          .filter-item.inline
            = select_tag('update[state_event]', options_for_select([['Open', 'reopen'], ['Closed', 'close']]), include_blank: true, data: { placeholder: "Status" })
          .filter-item.inline
            = users_select_tag('update[assignee_id]', placeholder: 'Assignee', null_user: true, first_user: true, current_user: true)
          .filter-item.inline
            = select_tag('update[milestone_id]', bulk_update_milestone_options, include_blank: true, data: { placeholder: "Milestone" })
          = hidden_field_tag 'update[issues_ids]', []
          = hidden_field_tag :state_event, params[:state_event]
          .filter-item.inline
            = button_tag "Update issues", class: "btn update_selected_issues btn-save"

:javascript
  new UsersSelect();
  $('form.filter-form').on('submit', function (event) {
    event.preventDefault();
    Turbolinks.visit(this.action + '&' + $(this).serialize());
  });
