Skip to content

Commit

Permalink
Refactor allocation show page layout and improve funding source display
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Aug 27, 2024
1 parent 7b84180 commit 909f6ef
Showing 1 changed file with 29 additions and 40 deletions.
69 changes: 29 additions & 40 deletions app/views/allocations/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,37 @@

<p>
Total: <%= number_to_currency(@allocation.total_cents/100) %><br/>
Projects: <%= @project_allocations.count %>
Projects: <%= @allocation.funded_projects_count %>
</p>

<table class="table w-auto">
<thead>
<tr>
<th>Platform</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<% @allocation.group_projects_by_funding_platform.each do |platform, total_cents| %>
<tr>
<td><%= platform %></td>
<td><%= number_to_currency(total_cents/100.0) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class='row'>
<% @allocation.group_projects_by_funding_source_and_platform.group_by{|i,j| i[0] }.each do |platform, sources| %>
<div class='col-3'>
<table class="table w-auto">
<thead>
<tr>
<th><%= platform %></th>
<th>Total</th>
</tr>
</thead>
<tbody>
<% sources.each do |source, total_cents|%>
<tr>
<td><%= link_to source[1].split('/').last, source[1] %></td>
<td><%= number_to_currency(total_cents/100.0) %></td>
</tr>
<% end %>
</tbody>
<tfoot>
<tr>
<td>Total</td>
<td><%= number_to_currency(sources.sum{|source, total_cents| total_cents}/100.0) %></td>
</tr>
</tfoot>
</table>
</div>
<% end %>
</div>

<table class="table">
<thead>
Expand Down Expand Up @@ -52,27 +64,4 @@
<% end %>
</tbody>
</table>

<div class='row'>
<% @allocation.group_projects_by_funding_source_and_platform.group_by{|i,j| i[0] }.each do |platform, sources| %>
<div class='col-3'>
<table class="table w-auto">
<thead>
<tr>
<th><%= platform %> Funding Source</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<% sources.each do |source, total_cents|%>
<tr>
<td><%= link_to source[1].split('/').last, source[1] %></td>
<td><%= number_to_currency(total_cents/100.0) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
</div>

0 comments on commit 909f6ef

Please sign in to comment.