Files
grecia/app/components/admin/budget_phases/phases_component.rb
Javi Martín 7227815a16 Split duration component in two
We were displaying dates in two different formats in the same component,
leading to strange hacks like manually calling the `call` method or not
being able to use `render_inline` in the tests.

Since we're going to reuse one of these formats outside the budgets
section, we're splitting the component. We're also removing the
mentioned hacks.
2022-09-14 15:14:23 +02:00

28 lines
607 B
Ruby

class Admin::BudgetPhases::PhasesComponent < ApplicationComponent
attr_reader :budget
def initialize(budget)
@budget = budget
end
private
def phases
budget.phases.order(:id)
end
def dates(phase)
render Admin::DurationComponent.new(phase)
end
def enabled_cell(phase)
render Admin::BudgetPhases::ToggleEnabledComponent.new(phase)
end
def edit_path(phase)
if helpers.respond_to?(:single_heading?) && helpers.single_heading?
edit_admin_budgets_wizard_budget_budget_phase_path(budget, phase, helpers.url_params)
end
end
end