TechLadies/home-web

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

Summary

Maintainability
Test Coverage
<script src="assets/jquery.tablesort.js"></script>
<script>
  $(document).on('ready page:load', function() {
    $('table').tablesort();
  });
</script>

<div class='page-header'>
  <div class='container'>
    <h1 class='pull-left'>People</h1>
    <div class='pull-right'>
      <%= link_to 'New Person', new_person_path, class: 'btn btn-primary' %>
    </div>
  </div>
</div>

<div class='container'>
  <div class='panel panel-default'>
    <div class='panel-body'>
      <%= simple_form_for @query, as: :search, url: people_path , method: :get do |form| %>
        <div class='row'>
          <%= form.input :query, as: :string, wrapper_html: { class: 'col-md-10' }, placeholder: 'Name' %>
          <div class="col-md-2 pull-left">
            <br />
            <%= form.submit 'Search', class: 'btn btn-primary btn-block btn-lg' %>
          </div>
        </div>
      <% end %>
    </div>
  </div>
</div>

<div class='container'>
  <div class='panel panel-default'>

    <div class='panel-heading'>
      <h2>All People</h2>
    </div>

    <div class='panel-body table-responsive'>
      <table class='table table-default'>

        <thead>
          <tr>
            <th>Name<span class="glyphicon glyphicon-sort" aria-hidden="true"></span></th>
            <th>Phone</th>
            <th>Address</th>
            <th>Email<span class="glyphicon glyphicon-sort" aria-hidden="true"></span></th>
            <th>DOB</th>
            <th>Gender<span class="glyphicon glyphicon-sort" aria-hidden="true"></span></th>
            <th>Pending Cases</th>
            <th>Closed Cases</th>
          </tr>
        </thead>

        <tbody>
          <%- @people.each do |person| %>
            <tr>
              <td class='col-md-2'><%= link_to person.name, person %></td>
              <td><%= person.phone %></td>
              <td class='col-md-2'><%= person.address %></td>
              <td><%= person.email %> </td>
              <td><%= person.date_of_birth.to_formatted_s(:rfc822) unless person.date_of_birth == nil %></td>
              <td><%= person.gender.titleize %></td>
              <td><%= person.case_files.pending.count %></td>
              <td><%= person.case_files.closed.count %></td>
            </tr>
          <% end %>
        </tbody>

      </table>
    </div>

  </div>
</div>