Extract methods to get investments in a ballot

This commit is contained in:
Javi Martín
2024-03-30 00:24:28 +01:00
parent f9d9fe8f23
commit 05a6021938
4 changed files with 11 additions and 5 deletions

View File

@@ -36,9 +36,7 @@
<% end %>
<ul class="ballot-list">
<%= render Budgets::Ballot::InvestmentComponent.with_collection(
ballot.investments.by_group(group.id)
) %>
<%= render Budgets::Ballot::InvestmentComponent.with_collection(group_investments(group)) %>
</ul>
</div>
</div>

View File

@@ -26,4 +26,8 @@ class Budgets::Ballot::BallotComponent < ApplicationComponent
budget_investments_path(budget, heading_id: group.headings.first)
end
end
def group_investments(group)
ballot.investments.by_group(group.id)
end
end

View File

@@ -3,7 +3,7 @@
<%= t("budgets.investments.index.sidebar.my_ballot") %>
</h2>
<% if ballot.investments.by_heading(heading.id).count > 0 %>
<% if investments.count > 0 %>
<p>
<em><%= sanitize(ballot.voted_info(heading)) %></em>
</p>
@@ -32,7 +32,7 @@
<ul class="ballot-list">
<% if heading %>
<%= render Budgets::Ballot::InvestmentForSidebarComponent.with_collection(
ballot.investments.by_heading(heading.id),
investments,
investment_ids: investment_ids
) %>
<% end %>

View File

@@ -18,4 +18,8 @@ class Budgets::Investments::MyBallotComponent < ApplicationComponent
def budget
ballot.budget
end
def investments
ballot.investments.by_heading(heading.id)
end
end