BathHacked/energy-sparks

View on GitHub
app/views/admin/consent_grants/index.html.erb

Summary

Maintainability
Test Coverage
<h1>Consents Granted</h1>

<p>
Find consent records by school name, reference code provided to n3rgy or meter mpxn.
</p>

<%= simple_form_for :search, url: admin_consent_grants_path, method: "GET", html: { class: 'form' } do |f| %>
  <%= f.input :school, input_html: {value: params[:search].present? ? params[:search]["school"]: ''} %>
  <%= f.input :reference, input_html: {value: params[:search].present? ? params[:search]["reference"]: ''} %>
  <%= f.input :mpxn, input_html: {value: params[:search].present? ? params[:search]["mpxn"]: ''} %>
  <%= f.submit "Search", class: "btn btn-primary" %>
<% end %>

<% if @consent_grants.any? %>

<h3>Search results</h3>

<table class="table table-sorted">
  <thead>
    <tr>
      <th>School</th>
      <th>Name</th>
      <th>Job Title</th>
      <th>Consent</th>
      <th>Reference</th>
      <th>Date</th>
      <th>Actions</th>
    </tr>
  </thead>

  <tbody>
    <% @consent_grants.each do |consent_grant| %>
      <tr>
        <td><%= consent_grant.school.name %></td>
        <td><%= consent_grant.name %></td>
        <td><%= consent_grant.job_title %></td>
        <td><%= consent_grant.consent_statement.title %></td>
        <td><%= consent_grant.guid %></td>
        <td><%= nice_dates(consent_grant.created_at) %></td>
        <td>
          <div class="btn-group">
            <%= link_to 'View', admin_consent_grant_path(consent_grant), class: 'btn' %>
          </div>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<% else %>
  <p>No results were found using the provided search parameters</p>
<% end %>