Extract methods to show a phase start/end
This commit is contained in:
@@ -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 %>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user