BathHacked/energy-sparks

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

Summary

Maintainability
Test Coverage
<%= render 'schools/transport_surveys/header_nav' %>
<%= render 'schools/transport_surveys/tab_nav' %>

<% if @transport_survey.responses.any? %>
  <div class="table-responsive mt-2">
    <table class="table table-striped">
      <thead>
        <tr>
          <th><%= t('schools.transport_surveys.common.weather') %></th>
          <th><%= t('schools.transport_surveys.common.journey_time') %></th>
          <th><%= t('schools.transport_surveys.common.transport_method') %></th>
          <th><%= t('schools.transport_surveys.common.pupils_and_staff_sharing') %></th>
          <th><%= t('schools.transport_surveys.common.carbon') %></th>
          <th><%= t('schools.transport_surveys.common.survey_time') %></th>
          <% if can? :delete, TransportSurvey::Response %>
            <th><%= t('common.labels.actions') %></th>
          <% end %>
        </tr>
      </thead>
      <tbody>
        <% @responses.each do |response| %>
          <tr scope="row">
            <td><%= response.weather_image %></td>
            <td><%= response.journey_minutes %> <%= t('schools.transport_surveys.common.mins') %></td>
            <td><%= response.transport_type.image %> <%= response.transport_type.name %></td>
            <td><%= response.passengers > 1 ? response.passengers : "" %></td>
            <td><%= response.carbon_kg_co2 %>kg CO2</td>
            <td><%= nice_date_times response.surveyed_at, localtime: true %></td>
            <% if can? :delete, response %>
              <td><%= link_to t('common.labels.delete'), school_transport_survey_response_path(@school, @transport_survey, response), method: :delete, data: { confirm:  t('common.confirm') }, class: 'btn btn-sm btn-danger' %></td>
            <% end %>
          </tr>
        <% end %>
      </tbody>
    </table>
  </div>

  <%= link_to(t('schools.transport_surveys.common.download_responses'), school_transport_survey_responses_path(@school, @transport_survey, format: :csv), class: 'btn' ) %>

<% else %>
  <h4><%= t('schools.transport_surveys.common.no_responses') %></h4>
<% end %>

<%= render "shared/pagy_footer" %>