noesya/osuny

View on GitHub
app/views/admin/dashboard/namespace.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, @namespace.model_name.human %>

<% content_for :realm do %>
  <div class="container-fluid">
    <div class="row gx-4">
      <div class="col-lg-6 pt-5 d-flex flex-column">
        <p class="realm__quote h1 mb-5">
          <%= t "#{@namespace.to_s.underscore}.description.text_html" %>
        </p>
        <p class="realm__author">
          <%= t "#{@namespace.to_s.underscore}.description.source" %>
        </p>
        <p class="realm__credit small text-lg-end mt-auto mb-5">
          Illustration de
          <a  href="https://publicdomainreview.org/collection/old-french-fairytales-illustrated-by-virginia-frances-sterrett-1920/" 
              target="_blank"
              rel="nofollow">
            Virginia Frances Sterrett
          </a>
        </p>
      </div>
      <div class="col-lg-6">
        <%= image_tag "admin/#{@namespace.to_s.underscore}.jpg", class: 'realm__image img-fluid' %>
      </div>
    </div>
  </div>
<% end %>

<div class="row g-5">
  <% @namespace.parts.each do |part| %>
    <%
    next unless can? :read, part.first
    class_name = part.first
    path = send part.last
    title = class_name.model_name.human(count: 2)
    # Exemples:
    # administration.description.parts.qualiopi
    # research.description.parts.researcher
    # research.hal.description.parts.publication
    key = "#{@namespace.to_s.underscore.gsub('/', '.')}.description.parts.#{class_name.to_s.demodulize.downcase}"
    description = t "#{key}.description"
    %>
    <div class="col-sm-6 col-xl-4 col-xxl-3">
      <div class="position-relative">
        <h2 class="h4"><%= title %></h2>
        <p><%= description %></p>
        <%= link_to t('manage'), path, class: 'stretched-link action' %>
      </div>
    </div>
  <% end %>
</div>