BathHacked/energy-sparks

View on GitHub
app/views/resource_files/index.html.erb

Summary

Maintainability
Test Coverage
<h1>Resources</h1>

<p>This page provides quick links to commonly requested resources such as induction guides for new schools or new users, printable energy monitoring sheets for pupils, switch off posters and Energy Sparks flyers. All the resources can be downloaded to your own computer or printed.</p>

<table class="table">
  <% @resource_file_types.each do |type| %>
    <% unless type.resource_files.empty? %>
      <thead>
        <tr>
          <th colspan="3" class="h2"><%= type.title %></th>
        </tr>
      </thead>
    <% end %>
    <% type.resource_files.order(:title).each do |resource_file| %>
      <tr class="resource-download-links" data-event-value="<%= resource_file.id %>">
        <th scope="row">
          <%= link_to resource_file.title, controller: :resource_files, action: :download, serve: :inline, id: resource_file.id %>
        </th>
        <td><%= resource_file.description %></td>
        <td>
          <%= link_to url_for( controller: :resource_files, action: :download, serve: :download, id: resource_file.id ), class: 'btn' do %>
            Download <i class="fas fa-file-download"></i>
          <% end %>
        </td>
      </tr>
    <% end %>
  <% end %>
  <% unless @other_resource_files.empty? %>
    <thead>
      <tr>
        <th colspan="3" class="h2">Other</th>
      </tr>
    </thead>
  <% end %>
  <% @other_resource_files.order(:title).each do |resource_file| %>
    <tr>
      <th scope="row">
        <%= link_to resource_file.title, controller: :resource_files, action: :download, serve: :inline, id: resource_file.id %>
      </th>
      <td><%= resource_file.description %></td>
      <td>
        <%= link_to url_for( controller: :resource_files, action: :download, serve: :download, id: resource_file.id ), class: 'btn' do %>
          Download <i class="fas fa-file-download"></i>
        <% end %>

      </td>
    </tr>
  <% end %>
</table>