BathHacked/energy-sparks

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

Summary

Maintainability
Test Coverage
<%= render "header_nav" %>

<% if @transport_surveys.any? %>
  <div class="table-responsive mt-2">
    <table class="table table-striped">
      <thead>
        <tr>
          <th><%= t('schools.transport_surveys.common.survey_date') %></th>
          <th><%= t('schools.transport_surveys.common.total_pupils_and_staff') %></th>
          <th><%= t('schools.transport_surveys.common.total_carbon') %></th>
          <th><%= t('common.labels.actions') %></th>
        </tr>
      </thead>
      <tbody>
      <% @transport_surveys.each do |transport_survey| %>
        <tr>
          <td><%= link_to nice_dates(transport_survey.run_on), school_transport_survey_url(@school, transport_survey) %></td>
          <td><%= transport_survey.total_responses %></td>
          <td><%= transport_survey.total_carbon.round(2) %>kg CO2</td>
          <td>
            <%= link_to t('common.labels.view_results'), school_transport_survey_url(@school, transport_survey), class: 'btn btn-sm' %>
            <%= link_to t('common.labels.manage'), school_transport_survey_responses_url(@school, transport_survey), class: 'btn btn-sm' if can? :manage, TransportSurvey::Response %>
            <%= link_to t('common.labels.delete'), school_transport_survey_url(@school, transport_survey), method: :delete, data: { confirm: t('common.confirm') }, class: 'btn btn-sm btn-danger' if can? :delete, transport_survey %>
          </td>
        </tr>
      <% end %>
      </tbody>
    </table>
  </div>
  <%= render "shared/pagy_footer" %>
<% else %>
  <h4><%= t('schools.transport_surveys.index.no_surveys') %></h4>
<% end %>

<% if can?(:start, TransportSurvey) %>
  <%= link_to t('schools.transport_surveys.index.start_surveying'), start_school_transport_surveys_url(@school), class: 'btn' %>
<% end %>