BathHacked/energy-sparks

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

Summary

Maintainability
Test Coverage
<h1>Find schools by URN</h1>

<p>
Use this form to find the school based on a URN. You can include a partial URN to do a wildcard search.
A maximum of 20 schools will be returned.
</p>

<%= simple_form_for admin_schools_search_find_school_by_urn_index_path, method: :get, html: { class: 'form' } do |f| %>
  <%= f.input :urn, label: 'URN', autofocus: true, input_html: { name: :query, value: params[:query] } %>
  <%= f.submit :Search, class: 'btn btn-primary' %>
<% end %>

<% if @schools.any? %>
  <table class="table">
    <thead>
      <th>URN</th>
      <th>School</th>
      <th>Group</th>
    </thead>
    <tbody>
      <% @schools.each do |school| %>
        <tr>
          <td><%= link_to school.urn, school_path(school) %></td>
          <td><%= link_to school.name, school_path(school) %></td>
          <td><%= school.school_group.name if school.school_group.present? %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <% if params[:query].present? %>
    <p>No schools were found using this URN</p>
  <% end %>
<% end %>