Extract methods to get investments in a ballot
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
@@ -18,4 +18,8 @@ class Budgets::Investments::MyBallotComponent < ApplicationComponent
|
||||
def budget
|
||||
ballot.budget
|
||||
end
|
||||
|
||||
def investments
|
||||
ballot.investments.by_heading(heading.id)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user