AyuntamientoMadrid/participacion

View on GitHub
app/views/admin/site_customization/documents/index.html.erb

Summary

Maintainability
Test Coverage
<h2 class="inline-block"><%= t("admin.documents.index.title") %></h2>

<%= link_to t("admin.documents.index.new_link"),
            new_admin_site_customization_document_path,
            class: "button float-right" %>

<% if @documents.any? %>
  <h3><%= page_entries_info @documents %></h3>

  <table>
    <thead>
      <tr>
        <th scope="col"><%= t("admin.shared.title") %></th>
        <th scope="col"><%= t("admin.documents.index.format") %></th>
        <th scope="col"><%= t("admin.documents.index.size") %></th>
        <th scope="col"><%= t("admin.shared.actions") %></th>
      </tr>
    </thead>
    <tbody id="documents">
      <% @documents.each do |document| %>
        <tr id="<%= dom_id(document) %>" class="document-row">
          <td><%= document.title %></td>
          <td><%= document.attachment.content_type %></td>
          <td><%= number_to_human_size(document.attachment.byte_size) %></td>
          <td>
            <%= render Admin::TableActionsComponent.new(
              document,
              actions: [:destroy],
              destroy_path: admin_site_customization_document_path(document)
            ) do |actions| %>
              <%= actions.action(:download,
                                 text: t("documents.buttons.download_document"),
                                 path: document.attachment,
                                 rel: "nofollow") %>
            <% end %>
          </td>
        </tr>
      <% end %>
    </tbody>
  <table>
<% else %>
  <div class="callout primary">
    <%= t("admin.documents.index.no_documents") %>
  </div>
<% end %>

<%= paginate @documents %>