Files
nairobi/app/components/budgets/phases_component.rb
Javi Martín b37eaf19c6 Use a time HTML tag to display phases dates
Currently this change is barely beneficial (if at all), but it doesn't
harm and might be useful in some cases. For instance, the `datetime`
attributes generates a date containing time zone information, which the
text shown on the screen does not, and styling dates with CSS is now
easier.
2021-03-11 19:37:58 +01:00

35 lines
760 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)
phases.index(phase) + 1
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