Remove code duplication

We were calling the same method three times.
This commit is contained in:
Javi Martín
2020-07-12 23:44:31 +02:00
parent a38cdb4df3
commit c22e800329

View File

@@ -19,21 +19,22 @@
<div class="row ballot"> <div class="row ballot">
<% ballot_groups = @ballot.groups.sort_by_name %> <% ballot_groups = @ballot.groups.sort_by_name %>
<% ballot_groups.each do |group| %> <% ballot_groups.each do |group| %>
<% heading = @ballot.heading_for_group(group) %>
<div id="<%= dom_id(group) %>" class="small-12 medium-6 column end"> <div id="<%= dom_id(group) %>" class="small-12 medium-6 column end">
<div class="margin-top ballot-content"> <div class="margin-top ballot-content">
<div class="subtitle"> <div class="subtitle">
<h3> <h3>
<%= group.name %> - <%= @ballot.heading_for_group(group).name %> <%= group.name %> - <%= heading.name %>
</h3> </h3>
<%= link_to sanitize(t("budgets.ballots.show.remaining", <%= link_to sanitize(t("budgets.ballots.show.remaining",
amount: @ballot.formatted_amount_available(@ballot.heading_for_group(group)))), amount: @ballot.formatted_amount_available(heading))),
budget_group_path(@budget, group) %> budget_group_path(@budget, group) %>
</div> </div>
<% if @ballot.has_lines_in_group?(group) %> <% if @ballot.has_lines_in_group?(group) %>
<h4 class="amount-spent text-right"> <h4 class="amount-spent text-right">
<%= t("budgets.ballots.show.amount_spent") %> <%= t("budgets.ballots.show.amount_spent") %>
<span> <span>
<%= @ballot.formatted_amount_spent(@ballot.heading_for_group(group)) %> <%= @ballot.formatted_amount_spent(heading) %>
</span> </span>
</h4> </h4>
<% else %> <% else %>