.side-filters
  = form_tag project_entities_path, method: 'get' do
    - if current_user
      %fieldset
        %ul.nav.nav-pills.nav-stacked
          %li{class: ("active" if params[:scope] == 'all')}
            = link_to project_filter_path(scope: 'all') do
              Everyone's
              %span.pull-right
                = authorized_entities_count(current_user, entity, @project)
          %li{class: ("active" if params[:scope] == 'assigned-to-me')}
            = link_to project_filter_path(scope: 'assigned-to-me') do
              Assigned to me
              %span.pull-right
                = assigned_entities_count(current_user, entity, @project)
          %li{class: ("active" if params[:scope] == 'created-by-me')}
            = link_to project_filter_path(scope: 'created-by-me') do
              Created by me
              %span.pull-right
                = authored_entities_count(current_user, entity, @project)

    %fieldset
      %legend State
      %ul.nav.nav-pills
        %li{class: ("active" if params[:state] == 'opened')}
          = link_to project_filter_path(state: 'opened') do
            Open
        %li{class: ("active" if params[:state] == 'closed')}
          = link_to project_filter_path(state: 'closed') do
            Closed
        %li{class: ("active" if params[:state] == 'all')}
          = link_to project_filter_path(state: 'all') do
            All

    - if defined?(labels)
      %fieldset
        %legend
          Labels
          %small.pull-right
            = link_to project_labels_path(@project), class: 'light' do
              %i.fa.fa-pencil-square-o
        %ul.nav.nav-pills.nav-stacked.nav-small.labels-filter
          - @project.labels.order_by_name.each do |label|
            %li{class: label_filter_class(label.name)}
              = link_to labels_filter_path(label.name) do
                = render_colored_label(label)
                - if selected_label?(label.name)
                  .pull-right
                    %i.fa.fa-times

        - if @project.labels.empty?
          .light-well
            Create first label at
            = link_to 'labels page', project_labels_path(@project)
            %br
            or #{link_to 'generate', generate_project_labels_path(@project, redirect: redirect), method: :post} default set of labels

    %fieldset
      - if %w(state scope milestone_id assignee_id label_name).select { |k| params[k].present? }.any?
        = link_to project_entities_path, class: 'cgray pull-right' do
          %i.fa.fa-times
          %strong Clear filter


