Extract methods to show a phase start/end

This commit is contained in:
Javi Martín
2021-02-18 22:09:48 +01:00
parent cbe3d515b9
commit f9ecc583ef
2 changed files with 13 additions and 3 deletions

View File

@@ -19,9 +19,7 @@
</td>
<td>
<% if phase.starts_at.present? || phase.ends_at.present? %>
<%= l(phase.starts_at.to_date) if phase.starts_at.present? %>
-
<%= l(phase.ends_at.to_date) if phase.ends_at.present? %>
<%= start_date(phase) %> - <%= end_date(phase) %>
<% else %>
<em><%= t("admin.budgets.edit.blank_dates") %></em>
<% end %>

View File

@@ -10,4 +10,16 @@ class Admin::BudgetPhases::PhasesComponent < ApplicationComponent
def phases
budget.phases.order(:id)
end
def start_date(phase)
formatted_date(phase.starts_at)
end
def end_date(phase)
formatted_date(phase.ends_at)
end
def formatted_date(time)
l(time.to_date) if time.present?
end
end