rubyforgood/babywearing

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

Summary

Maintainability
Test Coverage
<div class="card">
  <header class="card-header d-flex align-items-center">
    <h3 class="mr-auto">Agreements</h3>
    <%= link_to '+ New Agreement', new_agreement_path, class: "btn btn-primary" %>
  </header>

  <section>
    <table class="table">
      <thead>
        <tr>
          <th scope="col">Name</th>
          <th scope="col">Active Version</th>
          <th scope="col">Updated</th>
          <th scope="col"></th>
        </tr>
      </thead>

      <tbody>
        <% if @agreements.empty? %>
          <tr><td colspan="100%">There are no agreements yet.</td></tr>
        <% else %>
          <% @agreements.each do |agreement| %>
            <tr>
              <td><%= link_to agreement.name, agreement %></td>
              <% active_version = agreement.active_version %>
              <td><%= active_version.nil? ?  "None" : (link_to active_version.version, agreement_version_path(agreement, active_version)) %></td>
              <td><%= agreement.updated_at.to_s(:db) %></td>
              <td align="right">
                <%= link_to 'View', agreement, class: 'btn btn-primary btn-sm' %> |
                <%= link_to 'Edit', edit_agreement_path(agreement), class: 'btn btn-primary btn-sm' %> |
                <%= link_to 'Destroy', agreement, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' %>
              </td>
            </tr>
          <% end %>
        <% end %>
      </tbody>
    </table>
  </section>
</div>