vol1ura/Sat_9am_5km

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

Summary

Maintainability
Test Coverage
<% head_info :og_image, url_for(@badge.image) %>
<% head_info :title, "#{@badge.name} #{'-' if params[:page]} #{params[:page]}".strip %>
<% head_info :description, strip_tags(@badge.conditions).squish %>

<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 t('navbars.top.badges'), badges_path %>
    </li>
    <li class="breadcrumb-item active" aria-current="page"><%= @badge.name %></li>
  </ol>
</nav>

<div class="row g-0">
  <div class="col-sm-4 col-md-3 p-3 d-flex justify-content-center align-items-start">
    <%= image_tag @badge.image.variant(:web), class: 'img-badge', alt: @badge.name %>
  </div>
  <div class="col-sm-8 col-md-9">
    <h2><%= @badge.name %></h2>
    <p class="card-text"><%= sanitized_text @badge.conditions %></p>
    <% if @badge.funrun_kind? && @badge.received_date %>
      <p class="text-muted"><%= t '.event_date' %>: <%= l @badge.received_date %></p>
    <% end %>
  </div>
</div>

<% if @trophies.exists? %>
  <table class="table table-striped">
    <thead>
      <tr>
        <td><%= t '.athlete' %></td>
        <% if @badge.record_kind? %>
          <td><%= t '.event' %></td>
          <td><%= t '.result' %></td>
          <td class="hidden-on-phone">Дата</td>
        <% elsif !@badge.funrun_kind? %>
          <td><%= t '.received_date' %></td>
        <% end %>
        <% tag.td class: ('hidden-on-phone' unless @badge.funrun_kind?) do %>
          <%= t '.club' %>
        <% end %>
      </tr>
    </thead>
    <tbody class="table-group-divider">
      <%= render partial: 'trophy', collection: @trophies %>
    </tbody>
  </table>
  <%= paginate @trophies %>
<% elsif @badge.funrun_kind? %>
  <p><%= t '.soon' %></p>
<% else %>
  <p><%= t '.nobody_has' %></p>
<% end %>