openaustralia/planningalerts

View on GitHub
app/views/_tailwind/applications/search.html.erb

Summary

Maintainability
Test Coverage
<% content_for :page_title, @description %>

<%# TODO: This page needs a proper design %>

<%= form_with url: search_applications_path, method: :get, builder: FormBuilders::Tailwind, class: "my-24" do |f| %>
  <%= f.text_field :q, value: @q, class: "block w-full", size: 50, autofocus: @applications.nil?, placeholder: "Tree work" %>
  <div class="mt-5">
    <%= f.button "Search" %>
  </div>
<% end %>

<% if @applications %>
  <% if @applications.any? %>
    <%= render Tailwind::SimplePager.new(collection: @applications) %>
    <%# TODO: Extract list of applications as a component? %>
    <ul class="mt-12 divide-y divide-light-grey2 border-y border-light-grey2">
      <%# TODO: Make highlighting of search terms work %>
      <% @applications.each do |application| %>
        <li><%= render application %></li>
      <% end %>
    </ul>
    <%= render Tailwind::SimplePager.new(collection: @applications) %>
  <% else %>
    <p class="text-xl text-navy">Sorry, no results found!</p>
  <% end %>
<% end %>