Files
grecia/app/components/budgets/ballot/ballot_component.rb
CoslaJohn c4d8c92ae2 Change the order in which votes are displayed to be in the order they were selected by the voter
Note that the `budget` parameter was added to the `delete_path` method
so it works in the tests; on production, it worked because this
component is only rendered on pages which already have the `budget`
parameter.

Co-authored-by: Javi Martín <javim@elretirao.net>
2024-04-04 18:47:03 +02:00

34 lines
651 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
def group_investments(group)
ballot.investments.by_group(group.id).sort_by_ballot_lines
end
end