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>
26 lines
590 B
Ruby
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
|