BathHacked/energy-sparks

View on GitHub
app/views/schools/audits/index.html.erb

Summary

Maintainability
Test Coverage
<% content_for :page_title, "#{@school.name} " + t('schools.audits.index.title') %>

<div class="row">
  <div class="col-md-12">
    <h1><%= t('schools.audits.index.energy_audits') %></h1>
  </div>
</div>

<% if @audits.any? %>
  <div class="row">
    <div class="col-md-12">
      <p><%= t('schools.audits.index.message') %>.</p>

      <table class="table" id="audits">
        <thead>
          <tr>
            <th><%= t('schools.audits.index.name') %></th>
            <th><%= t('schools.audits.index.completed_on') %></th>
            <% if can? :manage, @activity %>
              <th><%= t('common.labels.actions') %></th>
            <% end %>
          </tr>
        </thead>
        <tbody>
          <% @audits.each do |audit| %>
            <tr class="<%= can?(:manage, audit) ? active(audit.published) : '' %>" scope="row">
              <td><%= link_to audit.title, school_audit_path(@school, audit) %></td>
              <td><%= audit.created_at.strftime("%A, %d %B %Y") %></td>
              <% if can? :manage, audit %>
                <td>
                  <div class="btn-group">
                    <%= link_to t('common.labels.edit'), edit_school_audit_path(@school, audit), class: 'btn btn-warning btn-sm' %>
                    <%= link_to t('common.labels.remove'), school_audit_path(@school, audit), method: :delete, data: { confirm: t('common.confirm') }, class: 'btn btn-warning btn-sm' %>
                  </div>
                </td>
              <% end %>
            </tr>
          <% end %>
        </tbody>
      </table>
    </div>
  </div>
  <div class="row mt-2">
    <%= link_to t('schools.audits.index.book_another_audit'), energy_audits_path, class: 'btn btn-primary btn-sm'%>
  </div>
<% else %>
  <div class="row">
    <div class="col-md-12">
      <p><%= t('schools.audits.index.no_audits_exist_for_this_school') %>.</p>
    </div>
  </div>
<% end %>

<% if can? :manage, Audit %>
  <div class="row mt-2">
    <%= link_to t('schools.audits.index.new_audit'), new_school_audit_path(@school), class: 'btn btn-primary btn-sm'%>
  </div>
<% end %>