BathHacked/energy-sparks

View on GitHub
app/views/schools/school_targets/_target_table.html.erb

Summary

Maintainability
Test Coverage
<div class="row">
  <div class="col">
    <div class="table-responsive-sm mt-4">
      <table class="table management-overview" id="target-table">
        <thead class="thead-dark">
          <th class="icon"></th>
          <th></th>
          <th class="text-right"><%= t('schools.school_targets.target_table.target_reduction') %></th>
          <th class="text-right">
            <% if school_target.current? %>
              <%= t('schools.school_targets.target_table.current_progress') %>
            <% else %>
              <%= t('schools.school_targets.target_table.final_result') %>
            <% end %>
          </th>
          <th class="text-right"></th>
        </thead>
        <tbody>
          <% if school_target.electricity.present? %>
            <%= render "target_table_row", fuel_type: :electricity, school_target: school_target, fuel_progress: progress_summary.electricity_progress, overview_data: overview_data,
            report_link: electricity_school_school_target_progress_index_path(school_target.school, school_target) %>
          <% end %>
          <% if school_target.gas.present? %>
            <%= render "target_table_row", fuel_type: :gas, school_target: school_target, fuel_progress: progress_summary.gas_progress, overview_data: overview_data,
            report_link: gas_school_school_target_progress_index_path(school_target.school, school_target) %>
          <% end %>
          <% if school_target.storage_heaters.present? %>
            <%= render "target_table_row", fuel_type: :storage_heaters, school_target: school_target, fuel_progress: progress_summary.storage_heater_progress, overview_data: overview_data,
            report_link: storage_heater_school_school_target_progress_index_path(school_target.school, school_target) %>
          <% end %>
        </tbody>
      </table>
    </div>
    <div class="text-right management-overview-caption">
        <%= t('schools.school_targets.target_table.reporting_change_in_energy_usage_between') %>
        <% if school_target.current? %>
          <%= t('schools.school_targets.target_table.start_date_and_end_date', start_date: I18n.l(school_target.start_date, format: '%B %Y'), end_date: I18n.l(school_target.report_last_generated, format: '%B %Y')) %>
        <% else %>
          <%= t('schools.school_targets.target_table.start_date_and_end_date', start_date: I18n.l(school_target.start_date, format: '%B %Y'), end_date: I18n.l(school_target.target_date, format: '%B %Y')) %>
        <% end %>. <%= link_to_help_for_feature :school_targets, title: "#{t('schools.show.more_information')} #{fa_icon('info-circle')}".html_safe %>
    </div>
  </div>
</div>