vol1ura/Sat_9am_5km

View on GitHub
app/views/activities/show.html.erb

Summary

Maintainability
Test Coverage
<% head_info :og_image, '/images/protocol.png' %>
<% head_info :title, t('.title', activity: human_activity_name(@activity)) %>
<% head_info :description, t('.description', activity: human_activity_name(@activity)) %>
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item">
      <%= link_to t('.main_page'), root_path %>
    </li>
    <li class="breadcrumb-item">
      <%= link_to @activity.event_name, event_path(@activity.event.code_name) %>
    </li>
    <li class="breadcrumb-item active" aria-current="page"><%= l @activity.date, format: :long %></li>
  </ol>
</nav>

<% if @activity.description.present? %>
  <h4><%= t '.short_report' %></h4>
  <%= sanitized_text @activity.description %>
<% end %>

<ul class="list-group list-group-flush">
  <li class="list-group-item">
    <span class="badge bg-primary rounded-pill"><%= @results.size %></span>
    <%= t '.total_runners_count' %>
  </li>
  <% if @personal_best_count.positive? %>
    <li class="list-group-item">
      <span class="badge bg-primary rounded-pill"><%= @personal_best_count %></span>
      <%= t '.personal_bests_count' %>&nbsp;<i class="fa-solid fa-bolt"></i>
    </li>
  <% end %>
  <% s95_first_run_count = @results_count.count { |_, c| c == 1 } %>
  <% if @first_run_count > s95_first_run_count %>
    <li class="list-group-item">
      <span class="badge bg-primary rounded-pill"><%= @first_run_count - s95_first_run_count %></span>
      <%= t '.first_runners_count' %> <%= @activity.event_name %>&nbsp;<i class="fa-solid fa-heart"></i>
    </li>
  <% end %>
  <% if s95_first_run_count.positive? %>
    <li class="list-group-item">
      <span class="badge bg-primary rounded-pill"><%= s95_first_run_count %></span>
      <%= t '.first_s95_count' %>&nbsp;<i class="fa-solid fa-heart text-success"></i>
    </li>
  <% end %>
</ul>

<h4><%= t '.protocol' %></h4>

<ul class="nav nav-tabs" id="protocol" role="tablist">
  <li class="nav-item" role="presentation">
    <button class="nav-link active" id="absolute-tab" data-bs-toggle="tab" data-bs-target="#absolute-tab-pane" type="button" role="tab" aria-controls="absolute-tab-pane" aria-selected="true"><%= t '.common' %></button>
  </li>
  <li class="nav-item" role="presentation">
    <button class="nav-link" id="male-tab" data-bs-toggle="tab" data-bs-target="#male-tab-pane" type="button" role="tab" aria-controls="male-tab-pane" aria-selected="false"><%= t '.men' %></button>
  </li>
  <li class="nav-item" role="presentation">
    <button class="nav-link" id="female-tab" data-bs-toggle="tab" data-bs-target="#female-tab-pane" type="button" role="tab" aria-controls="female-tab-pane" aria-selected="false"><%= t '.women' %></button>
  </li>
</ul>

<div class="tab-content" data-controller="protocol">
  <div class="tab-pane fade show active" id="absolute-tab-pane" role="tabpanel" aria-labelledby="absolute-tab" tabindex="0" data-protocol-target="absolute">
    <%= render partial: 'protocol', locals: { results: @results } %>
  </div>
  <div class="tab-pane fade" id="male-tab-pane" role="tabpanel" aria-labelledby="male-tab" tabindex="0" data-protocol-target="male"></div>
  <div class="tab-pane fade" id="female-tab-pane" role="tabpanel" aria-labelledby="female-tab" tabindex="0" data-protocol-target="female"></div>
</div>

<h4><%= t '.volunteers' %></h4>
<p><%= t '.about_volunteers' %></p>
<table class="table">
  <thead>
    <tr>
      <th><%= t '.volunteer' %></th>
      <th><%= t '.role' %></th>
    </tr>
  </thead>
  <tbody class="table-group-divider">
    <% @activity.volunteers_roster.includes(:athlete).each do |volunteer| %>
      <tr>
        <td>
          <div>
            <%= link_to volunteer.name, athlete_path(volunteer.athlete), class: 'athlete-link' %>
          </div>
          <div class="athlete-details fw-lighter">
            <%= t '.total_volunteering', count: @volunteering_v_count[volunteer.athlete_id] %>
          </div>
        </td>
        <td class="align-middle">
          <%= human_volunteer_role volunteer.role %>
          <% if @volunteering_v_count[volunteer.athlete_id] == 1 %>
            <i class="fa-solid fa-heart text-danger" title="Первое волонтёрство!"></i>
          <% end %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>