Files
grecia/app/components/budgets/ballot/ballot_component.rb
Javi Martín f669b476f8 Go to investments list from a single heading group
There's no real point in linking to a page offering users to choose a
heading when there's only one heading to choose.

So we're linking to the investments index instead.
2021-10-29 15:23:22 +02:00

30 lines
544 B
Ruby

class Budgets::Ballot::BallotComponent < ApplicationComponent
attr_reader :ballot
def initialize(ballot)
@ballot = ballot
end
def budget
ballot.budget
end
private
def ballot_groups
ballot.groups.sort_by_name
end
def no_balloted_groups
budget.groups.sort_by_name - ballot.groups
end
def group_path(group)
if group.multiple_headings?
budget_group_path(budget, group)
else
budget_investments_path(budget, heading_id: group.headings.first)
end
end
end