vol1ura/Sat_9am_5km

View on GitHub
app/views/clubs/last_week.html.erb

Summary

Maintainability
Test Coverage
<% head_info :title, t('.title', club: @club.name) %>

<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item">
      <%= link_to t('.main'), root_path %>
    </li>
    <li class="breadcrumb-item">
      <%= link_to t('.clubs'), clubs_path %>
    </li>
    <li class="breadcrumb-item">
      <%= link_to @club.name, club_path(@club) %>
    </li>
    <li class="breadcrumb-item active" aria-current="page"><%= t '.participants_activity' %></li>
  </ol>
</nav>

<h2><%= t '.participants_activity' %></h2>

<p>
  <%= t '.description', club: @club.name %>
  <% if Date.current.saturday? %>
    <%= t '.disclaimer' %>
  <% end %>
</p>

<ul class="nav nav-tabs" id="protocol" role="tablist">
  <li class="nav-item" role="presentation">
    <button class="nav-link active" id="results-tab" data-bs-toggle="tab" data-bs-target="#results-tab-pane" type="button" role="tab" aria-controls="results-tab-pane" aria-selected="true">
      <%= t '.activities' %>
    </button>
  </li>
  <li class="nav-item" role="presentation">
    <button class="nav-link" id="volunteerings-tab" data-bs-toggle="tab" data-bs-target="#volunteerings-tab-pane" type="button" role="tab" aria-controls="volunteerings-tab-pane" aria-selected="false">
      <%= t '.volunteering' %>
    </button>
  </li>
</ul>

<div class="tab-content">
  <div class="tab-pane fade show active" id="results-tab-pane" role="tabpanel" aria-labelledby="results-tab" tabindex="0">
    <table class="table table-striped">
      <thead>
        <tr>
          <th><%= t '.position' %></th>
          <th><%= t '.name' %></th>
          <th><%= t '.total_time' %></th>
        </tr>
      </thead>
      <tbody class="table-group-divider">
        <% @activities_with_results.each do |activity| %>
          <tr>
            <th colspan="3" class="table-warning table-active">
              <%= link_to activity.event_name, activity_path(activity) %>
            </th>
          </tr>
          <% activity.results.includes(:athlete).where(athlete: { club: @club }).order(:position).each do |result| %>
            <tr>
              <td><%= result.position %></td>
              <td><%= link_to result.athlete.name, athlete_path(result.athlete) %></td>
              <td><%= human_result_time result.total_time %></td>
            </tr>
          <% end %>
        <% end %>
      </tbody>
    </table>
  </div>
  <div class="tab-pane fade" id="volunteerings-tab-pane" role="tabpanel" aria-labelledby="volunteerings-tab" tabindex="0">
    <table class="table table-striped">
      <thead>
        <tr>
          <th><%= t '.name' %></th>
          <th><%= t '.role' %></th>
        </tr>
      </thead>
      <tbody class="table-group-divider">
        <% @activities_with_volunteers.each do |activity| %>
          <tr>
            <th colspan="2" class="table-warning table-active">
              <%= link_to activity.event_name, activity_path(activity) %>
            </th>
          </tr>
          <% activity.volunteers_roster.includes(:athlete).where(athlete: { club: @club }).each do |volunteer| %>
            <tr>
              <td><%= link_to volunteer.name, athlete_path(volunteer.athlete) %></td>
              <td><%= human_volunteer_role volunteer.role %></td>
            </tr>
          <% end %>
        <% end %>
      </tbody>
    </table>
  </div>
</div>