BathHacked/energy-sparks

View on GitHub
app/views/schools/consent_documents/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for :page_title do %>
  <%= @school.name %><%= t('consent_documents.index.title') %>
<% end %>

<h1><%= t('consent_documents.index.title') %></h1>

<% if @consent_documents.any? %>
  <p>
    <%= t('consent_documents.index.description') %>
  </p>

  <p>
    <%= link_to t('consent_documents.index.upload_new_bill'), new_school_consent_document_path(@school), class: 'btn btn-primary' %>
  </p>

  <table class="table">
    <thead>
      <tr>
        <th class="w-25"><%= t('consent_documents.index.document_uploaded_date') %></th>
        <th class="w-50"><%= t('consent_documents.document_title') %></th>
        <th class="w-25"><%= t('consent_documents.index.document_link') %></th>
      </tr>
    </thead>
    <tbody>
      <% @consent_documents.each do |bill| %>
        <tr>
          <td><%= nice_date_times(bill.created_at) %></td>
          <td><%= link_to bill.title, school_consent_document_path(@school, bill) %></td>
          <td>
            <%= link_to url_for(bill.file), class: 'btn btn-primary' do %>
              <%= t('common.labels.download') %> <i class="fas fa-file-download"></i>
            <% end%>
            <%= link_to t('common.labels.edit'), edit_school_consent_document_path(@school, bill), class: 'btn' %>
            <% if can?(:delete, bill) %>
              <%= link_to t('common.labels.delete'), school_consent_document_path(@school, bill), method: :delete, data: {confirm: t('common.confirm')}, class: 'btn btn-danger'  %>
            <% end %>
          </td>
        </tr>
      <% end %>
    </tbody>
  </table>

<% else %>
  <p>
    <%= t('consent_documents.index.no_documents_provided') %>
  </p>

  <p>
    <%= t('consent_documents.index.document_required') %>
  </p>

  <%= t('consent_documents.document_details_html') %>

  <p>
    <%= link_to t('consent_documents.index.upload_bill'), new_school_consent_document_path(@school), class: 'btn btn-primary' %>
  </p>
<% end %>