BathHacked/energy-sparks

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

Summary

Maintainability
Test Coverage
<% content_for :head do %>
  <%= javascript_include_tag 'transport_surveys/charts' %>
<% end %>

<%= render 'header_nav' %>
<%= render 'tab_nav' %>

<% if @transport_survey.responses.any? %>

  <%= render 'equivalences' %>

  <h2 class="mt-3"><%= t('schools.transport_surveys.show.more_detail') %></h2>

  <div id="transport_surveys_pie" class="mb-3" data-error="<%= t('schools.transport_surveys.show.chart_load_error') %>"></div>

  <h4><%= t('schools.transport_surveys.show.transport_categories_title') %></h4>

  <table class="table" id="responses_per_category">
    <thead class="thead-light">
      <tr>
        <th class="col-md-4"><%= t('schools.transport_surveys.common.transport_category') %></th>
        <th class="col-md-4"><%= t('schools.transport_surveys.common.total_pupils_and_staff') %></th>
        <th class="col-md-4"><%= t('schools.transport_surveys.common.percentage_pupils_and_staff') %></th>
      </tr>
    </thead>
    <tbody>
      <% TransportSurvey::TransportType.categories_with_other.each do |cat, value| %>
        <tr>
          <td class="col-md-4"><%= TransportSurvey::TransportType.human_enum_name(:category, cat) %></td>
          <td class="col-md-4"><%= @transport_survey.responses_per_category[cat] %></td>
          <td class="col-md-4"><%= @transport_survey.percentage_per_category[cat].round %>%</td>
        </tr>
      <% end %>
    </tbody>
  </table>

  <h4><%= t('schools.transport_surveys.show.cars_title') %></h4>
  <p><%= t('schools.transport_surveys.show.cars_summary') %></p>

  <table class="table" id='time_travelled_by_car'>
    <thead class="thead-light">
      <tr>
        <th class="col-md-8"><%= t('schools.transport_surveys.show.time_travelled_by_car') %></th>
        <th class="col-md-4"><%= t('schools.transport_surveys.common.total_pupils_and_staff') %></th>
      </tr>
    </thead>
    <tbody>
      <% @transport_survey.responses_per_time_for_category_car.each do |time, value| %>
        <tr>
          <td class="col-md-8">
            <% if time == '30+' %>
              <%= t('schools.transport_surveys.show.30_or_more_minutes') %>
            <% else %>
              <%= t('common.units.minutes', count: time) %>
            <% end %>
          </td>
          <td class="col-md-4"><%= value %></td>
        </tr>
      <% end %>
    </tbody>
  </table>
<% else %>
  <h4><%= t('schools.transport_surveys.common.no_responses') %></h4>
<% end %>