Files
nairobi/app/components/budgets/investments/my_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

26 lines
590 B
Ruby

class Budgets::Investments::MyBallotComponent < ApplicationComponent
attr_reader :ballot, :heading, :investment_ids, :assigned_heading
use_helpers :can?, :heading_link
def initialize(ballot:, heading:, investment_ids:, assigned_heading: nil)
@ballot = ballot
@heading = heading
@investment_ids = investment_ids
@assigned_heading = assigned_heading
end
def render?
heading && can?(:show, ballot)
end
private
def budget
ballot.budget
end
def investments
ballot.investments.by_heading(heading.id).sort_by_ballot_lines
end
end