BathHacked/energy-sparks

View on GitHub
app/views/schools/advice/index/_priority_table.html.erb

Summary

Maintainability
Test Coverage
<table class="table table-borderless table-sorted advice-table advice-priority-table">
  <thead>
    <tr>
      <th colspan="2"></th>
      <th colspan="3" class='text-center'><%= t('advice_pages.index.priorities.table.columns.savings') %></th>
    </tr>
    <tr>
      <th><%= t('advice_pages.index.priorities.table.columns.fuel_type') %></th>
      <th data-orderable="false"></th>
      <th><%= t('advice_pages.index.priorities.table.columns.kwh_saving') %></th>
      <th><%= t('advice_pages.index.priorities.table.columns.cost_saving') %></th>
      <th><%= t('advice_pages.index.priorities.table.columns.co2_reduction') %></th>
    </tr>
  </thead>
  <tbody id="priority">
    <% management_priorities.each do |priority| %>
      <tr>
        <td data-order="<%= priority.alert.alert_type.fuel_type %>">
          <span class="<%= fuel_type_class(priority.alert.alert_type.fuel_type) %>">
            <%= fa_icon alert_icon(priority.alert, 'fa-2x') %>
          </span>
        </td>
        <td>
          <h4>
            <% if priority.alert.advice_page.present? %>
              <%= link_to priority.management_priorities_title,
                          advice_page_path(school,
                                           priority.alert.advice_page,
                                           priority.alert.alert_type.advice_page_tab_for_link_to,
                                           anchor: priority.alert.alert_type.link_to_section) %>
            <% else %>
              <%= priority.management_priorities_title %>
            <% end %>
          </h4>
        </td>
        <td data-order="<%= formatted_unit_to_num(priority.template_variables[:one_year_saving_kwh]) %>">
          <h4>
            <%= format_unit(formatted_unit_to_num(priority.template_variables[:one_year_saving_kwh]), :kwh) %>
          </h4>
        </td>
        <td>
          <h4>
            <%= priority.template_variables[:average_one_year_saving_gbp] %>
          </h4>
        </td>
        <td data-order="<%= formatted_unit_to_num(priority.template_variables[:one_year_saving_co2]) %>">
          <h4>
            <%= format_unit(formatted_unit_to_num(priority.template_variables[:one_year_saving_co2]), :co2) %>
          </h4>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>