vol1ura/Sat_9am_5km

View on GitHub
app/views/events/volunteering.html.erb

Summary

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

<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 @event.name, event_path(@event.code_name) %>
    </li>
    <li class="breadcrumb-item active" aria-current="page"><%= t '.main_title' %></li>
  </ol>
</nav>

<h1><%= t '.main_title' %></h1>

<p><%= t '.acknowledgements' %></p>
<p>
  <% unless @activities.empty? %>
    <%= t '.about_roster_html' %>
  <% end %>
  <% if @tg_chat %>
    <%= t '.how_to_participate_html', tg_chat_link: @tg_chat.link %>
  <% end %>
  <%= t '.additional_positions' %>
</p>

<ul class="nav nav-tabs" id="protocol" role="tablist">
  <% @activities.each_with_index do |activity, idx| %>
    <li class="nav-item" role="presentation">
      <button class="nav-link <%= 'active' if idx.zero? %>" id="tab-<%= idx %>" data-bs-toggle="tab" data-bs-target="#tab-<%= idx %>-pane" type="button" role="tab" aria-controls="tab-<%= idx %>-pane" aria-selected="true">
        <%= l activity.date, format: :brief %>
      </button>
    </li>
  <% end %>
</ul>
<div class="tab-content" id="protocolContent">
  <% @activities.each_with_index do |activity, idx| %>
    <div class="tab-pane fade show <%= 'active' if idx.zero? %>" id="tab-<%= idx %>-pane" role="tabpanel" aria-labelledby="tab-<%= idx %>" tabindex="0">
      <table class="table">
        <thead>
          <tr>
            <th><%= t '.role' %></th>
            <th><%= t '.volunteer' %></th>
          </tr>
        </thead>
        <tbody class="table-group-divider" data-turbo-prefetch="false">
          <% @event.volunteering_positions.each do |position| %>
            <% volunteers = activity.volunteers.includes(:athlete).public_send("#{position.role}_role").order(:comment).to_a %>
            <% [position.number, volunteers.size].max.times.each do |i| %>
              <%
                volunteer = volunteers[i]
                idx = "#{position.role}-#{i}-#{activity.id}"
              %>
              <tr>
                <td><%= render partial: 'role', locals: { volunteer: volunteer, role: position.role, idx: idx } %></td>
                <td><%= render partial: 'volunteer', locals: { volunteer: volunteer, role: position.role, idx: idx, activity: activity } %></td>
              </tr>
            <% end %>
          <% end %>
        </tbody>
      </table>
    </div>
  <% end %>
</div>