<h2><%= l(:label_ux_toolkit_project_health) %></h2>

<p><%= l(:text_ux_toolkit_project_health_help, count: @stale_days) %></p>

<%= form_tag ux_toolkit_project_health_path, method: :get, class: 'query-form' do %>
  <fieldset id="filters" class="collapsible">
    <legend><%= l(:label_filter_plural) %></legend>

    <p>
      <label class="inline">
        <%= hidden_field_tag :active_projects_only, '0', id: nil %>
        <%= check_box_tag :active_projects_only, '1', @active_projects_only %>
        <%= l(:label_ux_toolkit_active_projects_only) %>
      </label>
    </p>

    <p>
      <label class="inline">
        <%= check_box_tag :include_archived, '1', @include_archived %>
        <%= l(:label_ux_toolkit_include_archived_projects) %>
      </label>
    </p>

    <p class="buttons">
      <%= submit_tag l(:button_apply), name: nil, class: 'small' %>
      <%= link_to l(:button_clear), ux_toolkit_project_health_path, class: 'icon icon-reload' %>
    </p>
  </fieldset>
<% end %>

<% if @project_health_rows.any? %>
  <table class="list ux-toolkit-project-health">
    <thead>
      <tr>
        <th><%= l(:field_project) %></th>
        <th><%= l(:label_ux_toolkit_health_open) %></th>
        <th><%= l(:label_ux_toolkit_health_overdue) %></th>
        <th><%= l(:label_ux_toolkit_health_due_today) %></th>
        <th><%= l(:label_ux_toolkit_health_unassigned) %></th>
        <th><%= l(:label_ux_toolkit_health_stale) %></th>
        <th><%= l(:label_ux_toolkit_health_open_checklist_items) %></th>
        <th><%= l(:label_ux_toolkit_health_open_subtasks) %></th>
      </tr>
    </thead>
    <tbody>
      <% @project_health_rows.each do |row| %>
        <tr>
          <td class="project"><%= link_to_project(row.project) %></td>
          <td class="count"><%= ux_toolkit_project_health_count_link(row.open_count, row.project, :open) %></td>
          <td class="count"><%= ux_toolkit_project_health_count_link(row.overdue_count, row.project, :overdue) %></td>
          <td class="count"><%= ux_toolkit_project_health_count_link(row.due_today_count, row.project, :due_today) %></td>
          <td class="count"><%= ux_toolkit_project_health_count_link(row.unassigned_count, row.project, :unassigned) %></td>
          <td class="count"><%= ux_toolkit_project_health_count_link(row.stale_count, row.project, :stale) %></td>
          <td class="count"><%= ux_toolkit_project_health_count_link(row.open_checklist_items_count, row.project, :open_checklist_items) %></td>
          <td class="count"><%= ux_toolkit_project_health_count_link(row.open_subtasks_count, row.project, :open_subtasks) %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <p class="nodata"><%= l(:text_ux_toolkit_no_project_health) %></p>
<% end %>

<% html_title(l(:label_ux_toolkit_project_health)) %>
