BathHacked/energy-sparks

View on GitHub
app/components/comparison_table_component/comparison_table_component.html.erb

Summary

Maintainability
Test Coverage
<div class='text-right mt-2'>
  <%= download_link(report, table_name, index_params) %>
</div>

<table id="<%= comparison_table_id(report, table_name) %>" class="table advice-table table-sorted table-hover">
  <thead class="sticky-heading">
    <% if colgroups.any? %>
      <tr>
        <% colgroups.each do |colgroup| %>
          <th class="text-center" colspan="<%= colgroup[:colspan] || 1 %>"><%= colgroup[:label] %></th>
        <% end %>
      </tr>
    <% end %>
    <tr>
      <% headers.each_with_index do |header, idx| %>
        <th class="<%= idx.zero? ? 'text-left' : 'text-center' %>"><%= header %></th>
      <% end %>
    </tr>
  </thead>
  <tbody>
    <% rows.each do |row| %>
      <%= row %>
    <% end %>
  </tbody>

  <% if footnotes.any? || notes.any? %>
    <tfoot>
      <tr>
        <td colspan="<%= headers.count %>">
          <p>
            <strong><%= t('analytics.benchmarking.content.footnotes.notes') %></strong>
          </p>
          <% footnotes.sort_by(&:to_s).each do |footnote| %>
            <div>
              <%= footnote %>
              <% if footnote.reference.footnote %>
                <%= helpers.admin_button edit_admin_comparisons_footnote_path(footnote.reference.footnote) %>
              <% end %>
            </div>
          <% end %>
          <% if footnotes.any? && notes.any? %>
            <hr>
          <% end %>
          <% notes.each do |note| %>
            <%= note %>
          <% end %>
      </tr>
    </tfoot>
  <% end %>
</table>