Files
nairobi/app/components/budgets/phases_component.rb
Javi Martín cf4e6d2c64 Improve budget phase HTML ID
Some browsers might not recognize an ID as valid when it starts with a
number.
2021-04-07 14:32:49 +02:00

35 lines
798 B
Ruby

class Budgets::PhasesComponent < ApplicationComponent
delegate :wysiwyg, :auto_link_already_sanitized_html, to: :helpers
attr_reader :budget
def initialize(budget)
@budget = budget
end
private
def phases
budget.published_phases
end
def start_date(phase)
time_tag(phase.starts_at.to_date, format: :long) if phase.starts_at.present?
end
def end_date(phase)
time_tag(phase.ends_at.to_date - 1.day, format: :long) if phase.ends_at.present?
end
def phase_dom_id(phase)
"phase-#{phases.index(phase) + 1}-#{phase.name.parameterize}"
end
def prev_phase_dom_id(phase)
phase_dom_id(phases[phases.index(phase) - 1])
end
def next_phase_dom_id(phase)
phase_dom_id(phases[phases.index(phase) + 1])
end
end