Skip to content

Commit

Permalink
Standardise dates in the admin area
Browse files Browse the repository at this point in the history
Requirement is to standardise on %d/%m/%Y when displaying dates in the
admin area. We've added a new locale format `admin_date` which we now
use throughout the admin area when displaying a date or datetime.
  • Loading branch information
rjlynch committed Jan 6, 2025
1 parent 31a5748 commit 4f17d3c
Show file tree
Hide file tree
Showing 24 changed files with 47 additions and 49 deletions.
10 changes: 5 additions & 5 deletions app/helpers/admin/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def admin_personal_details(claim)
[
[translate("admin.teacher_reference_number"), claim.eligibility.teacher_reference_number.presence || "Not provided"],
[translate("#{claim.policy.locale_key}.govuk_verify_fields.full_name", default: :"govuk_verify_fields.full_name").capitalize, claim.personal_data_removed? ? personal_data_removed_text : claim.full_name],
[translate("govuk_verify_fields.date_of_birth").capitalize, claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year)],
[translate("govuk_verify_fields.date_of_birth").capitalize, claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :admin_date)],
[translate("admin.national_insurance_number"), claim.personal_data_removed? ? personal_data_removed_text : claim.national_insurance_number],
[translate("govuk_verify_fields.address").capitalize, claim.personal_data_removed? ? personal_data_removed_text : sanitize(claim.address("<br>").html_safe, tags: %w[br])],
[translate("#{claim.policy.locale_key}.admin.email_address", default: :"admin.email_address"), claim.email_address]
Expand Down Expand Up @@ -66,9 +66,9 @@ def admin_student_loan_details(claim)

def admin_submission_details(claim)
[
[translate("admin.started_at"), l(claim.started_at)],
[translate("admin.submitted_at"), l(claim.submitted_at)],
[translate("admin.decision_deadline"), l(claim.decision_deadline_date)],
[translate("admin.started_at"), l(claim.started_at, format: :admin_date)],
[translate("admin.submitted_at"), l(claim.submitted_at, format: :admin_date)],
[translate("admin.decision_deadline"), l(claim.decision_deadline_date, format: :admin_date)],
[translate("admin.decision_overdue"), decision_deadline_warning(claim)]
]
end
Expand All @@ -79,7 +79,7 @@ def admin_submission_details_for_early_years_payments(claim)

def admin_decision_details(decision)
[].tap do |a|
a << [translate("admin.decision.created_at"), l(decision.created_at)]
a << [translate("admin.decision.created_at"), l(decision.created_at, format: :admin_date)]
a << [translate("admin.decision.result"), decision.result.capitalize]
a << [translate("admin.decision.reasons"), rejected_reasons_list(decision)] if decision.rejected?
a << [translate("admin.decision.notes"), simple_format(decision.notes, class: "govuk-body")] if decision.notes.present?
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/admin/timeline_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def admin_amendment_attribute_name(attribute)
def admin_amendment_format_attribute(attribute, value)
override = case attribute.to_s
when "payroll_gender" then "don’t know" if value.to_s == "dont_know"
when "date_of_birth" then l(value, format: :day_month_year)
when "date_of_birth" then l(value, format: :admin_date)
when "student_loan_repayment_amount" then number_to_currency(value)
when "student_loan_plan" then (value.to_s == "not_applicable") ? "not applicable" : value&.humanize
when "award_amount" then number_to_currency(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def initialize(claim)
def personal_details
[
[translate("#{claim.policy.locale_key}.govuk_verify_fields.full_name").capitalize, personal_data(claim.full_name)],
[translate("govuk_verify_fields.date_of_birth").capitalize, personal_data(formatted_date(claim.date_of_birth, format: :day_month_year))],
[translate("govuk_verify_fields.date_of_birth").capitalize, personal_data(formatted_date(claim.date_of_birth))],
[translate("admin.national_insurance_number"), personal_data(claim.national_insurance_number)],
[translate("govuk_verify_fields.address").capitalize, personal_data(sanitize(claim.address("<br>").html_safe, tags: %w[br]))],
[translate("#{claim.policy.locale_key}.admin.email_address"), claim.email_address],
Expand Down Expand Up @@ -65,14 +65,10 @@ def personal_data(data)
data
end

def formatted_date(date, format: nil)
def formatted_date(date)
return unless date

if format
l(date, format: format)
else
l(date)
end
l(date, format: :admin_date)
end

def decision_overdue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(claim)
def employment
[
["Current employment", claim.eligibility.eligible_ey_provider.nursery_name],
["Start date", l(claim.eligibility.start_date)]
["Start date", l(claim.eligibility.start_date, format: :admin_date)]
]
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/amendments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<% end %>
</section>

<p class="hmcts-timeline__description"> by <%= user_details(amendment.created_by, include_line_break: false) %> on <%= l(amendment.created_at) %></p>
<p class="hmcts-timeline__description"> by <%= user_details(amendment.created_by, include_line_break: false) %> on <%= l(amendment.created_at, format: :admin_date) %></p>
</div>
<% end %>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/claims/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<% if claims_with_warning.nonzero? %>
<td class="govuk-table__cell"><%= decision_deadline_warning(claim) %></td>
<% end %>
<td class="govuk-table__cell"><%= l(claim.decision_deadline_date) if claim.decision_deadline_date %></td>
<td class="govuk-table__cell"><%= l(claim.decision_deadline_date, format: :admin_date) if claim.decision_deadline_date %></td>
<td class="govuk-table__cell"><%= claim.assigned_to.present? ? claim.assigned_to.full_name.titleize : nil %></td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/claims/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<% if @claim.personal_data_removed? %>
<div class="govuk-body-l govuk-flash__notice">
This claim had personal data removed on <%= l(@claim.personal_data_removed_at.to_date) %>.
This claim had personal data removed on <%= l(@claim.personal_data_removed_at.to_date, format: :admin_date) %>.
</div>
<% end %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/journey_configurations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="govuk-panel govuk-panel--informational govuk-panel--small">
<% if lupp_awards_last_updated_at %>
<p class="govuk-panel__body">
The <%= I18n.t("levelling_up_premium_payments.policy_short_name") %> school award amounts for academic year <%= journey_configuration.current_academic_year %> were updated on <%= l(lupp_awards_last_updated_at) %>.
The <%= I18n.t("levelling_up_premium_payments.policy_short_name") %> school award amounts for academic year <%= journey_configuration.current_academic_year %> were updated on <%= l(lupp_awards_last_updated_at, format: :admin_date) %>.
</p>
<% else %>
<p class="govuk-panel__body">
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/notes/_note.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<% else %>
by an automated check
<% end %>
on <%= l(note.created_at) %>
on <%= l(note.created_at, format: :admin_date) %>
</p>
<% end %>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Upload Payment Confirmation Report
</h1>

<p class="govuk-body">You are uploading a Payment Confirmation Report for the payroll run dated <%= l(@payroll_run.created_at.to_date) %>.</p>
<p class="govuk-body">You are uploading a Payment Confirmation Report for the payroll run dated <%= l(@payroll_run.created_at.to_date, format: :admin_date) %>.</p>

<p class="govuk-body govuk-!-font-weight-bold">
NOTE: <%= @payroll_run.payment_confirmations.count%> <%= "report".pluralize(@payroll_run.payment_confirmations.count) %> uploaded, for a total of
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/payments/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<td class="govuk-table__cell"><%= number_to_currency(topup.award_amount) %></td>
<td class="govuk-table__cell"><%= topup.payment_id? ? topup.payment_id : "Awaiting payroll" %></td>
<td class="govuk-table__cell"><%= user_details(topup.created_by) %></td>
<td class="govuk-table__cell"><%= l(topup.created_at) %></td>
<td class="govuk-table__cell"><%= l(topup.created_at, format: :admin_date) %></td>
<td class="govuk-table__cell">
<% unless topup.payrolled? %>
<%= link_to remove_admin_claim_topup_path(claim_id: @claim.id, id: topup.id), class: "govuk-link" do %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/payroll_run_downloads/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<% if @payroll_run.download_triggered? %>
<p class="govuk-body govuk-!-font-weight-bold">
NOTE: This month's payroll file was last downloaded on
<%= l(@payroll_run.downloaded_at) %> by
<%= l(@payroll_run.downloaded_at, format: :admin_date) %> by
<%= user_details(@payroll_run.downloaded_by, include_line_break: false) %>.
</p>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/payroll_runs/_complete.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</dt>

<dd class="govuk-summary-list__value">
<%= @payroll_run.download_triggered? ? l(@payroll_run.downloaded_at) : "No" %>
<%= @payroll_run.download_triggered? ? l(@payroll_run.downloaded_at, format: :admin_date) : "No" %>
</dd>
</div>
<% if @payroll_run.download_triggered? %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/admin/payroll_runs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</h1>

<div class="govuk-inset-text">
The next payroll run must be with DfE Payroll on or before <%= l(next_payroll_file_due_date) %>
The next payroll run must be with DfE Payroll on or before <%= l(next_payroll_file_due_date, format: :admin_date) %>
</div>

<%= link_to(
Expand All @@ -33,7 +33,7 @@
<tbody class="govuk-table__body">
<% @payroll_runs.each do |payroll_run| %>
<tr class="govuk-table__row">
<th scope="row" class="govuk-table__header"><%= l(payroll_run.created_at.to_date) %></th>
<th scope="row" class="govuk-table__header"><%= l(payroll_run.created_at.to_date, format: :admin_date) %></th>
<td class="govuk-table__cell"><%= payroll_run.number_of_claims_for_policy(:all, filter: :claims) %></td>
<td class="govuk-table__cell"><%= payroll_run.number_of_claims_for_policy(Policies::LevellingUpPremiumPayments, filter: :topups) %></td>
<td class="govuk-table__cell">
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/tasks/_claim_summary.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</dt>

<dd class="govuk-summary-list__value">
<%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) %>
<%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :admin_date) %>
</dd>
</div>
<div class="govuk-summary-list__row">
Expand Down Expand Up @@ -94,7 +94,7 @@
</dt>

<dd class="govuk-summary-list__value">
<%= l(claim.submitted_at) %>
<%= l(claim.submitted_at, format: :admin_date) %>
</dd>
</div>
<div class="govuk-summary-list__row">
Expand All @@ -103,7 +103,7 @@
</dt>

<dd class="govuk-summary-list__value">
<%= l(claim.decision_deadline_date) %>
<%= l(claim.decision_deadline_date, format: :admin_date) %>
<%= decision_deadline_warning(claim, {na_text: ""}) %>
</dd>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
Start date
</dt>
<dd class="govuk-summary-list__value">
<%= l(claim.eligibility.start_date) %>
<%= l(claim.eligibility.start_date, format: :admin_date) %>
</dd>
</div>

Expand All @@ -72,7 +72,7 @@
</dt>
<dd class="govuk-summary-list__value">
<% if claim.date_of_birth.present? %>
<%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) %>
<%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :admin_date) %>
<% end %>
</dd>
</div>
Expand Down Expand Up @@ -104,7 +104,7 @@
Submitted
</dt>
<dd class="govuk-summary-list__value">
<%= l(claim.submitted_at) if claim.submitted_at %>
<%= l(claim.submitted_at, format: :admin_date) if claim.submitted_at %>
</dd>
</div>

Expand All @@ -114,7 +114,7 @@
</dt>
<dd class="govuk-summary-list__value">
<% if claim.submitted_at %>
<%= l(claim.decision_deadline_date) %>
<%= l(claim.decision_deadline_date, format: :admin_date) %>
<%= decision_deadline_warning(claim, {na_text: ""}) %>
<% end %>
</dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</dt>

<dd class="govuk-summary-list__value">
<%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) %>
<%= claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :admin_date) %>
</dd>
</div>
<div class="govuk-summary-list__row">
Expand Down Expand Up @@ -93,7 +93,7 @@
</dt>

<dd class="govuk-summary-list__value">
<%= l(claim.submitted_at) %>
<%= l(claim.submitted_at, format: :admin_date) %>
</dd>
</div>
<div class="govuk-summary-list__row">
Expand All @@ -102,7 +102,7 @@
</dt>

<dd class="govuk-summary-list__value">
<%= l(claim.decision_deadline_date) %>
<%= l(claim.decision_deadline_date, format: :admin_date) %>
<%= decision_deadline_warning(claim, {na_text: ""}) %>
</dd>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

<% summary_list.with_row do |row| %>
<% row.with_key { "Date of birth" } %>
<% row.with_value { claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :day_month_year) } %>
<% row.with_value { claim.personal_data_removed? ? personal_data_removed_text : l(claim.date_of_birth, format: :admin_date) } %>
<% end %>

<% summary_list.with_row do |row| %>
Expand All @@ -63,12 +63,12 @@

<% summary_list.with_row do |row| %>
<% row.with_key { "Submitted" } %>
<% row.with_value { l(claim.submitted_at) } %>
<% row.with_value { l(claim.submitted_at, format: :admin_date) } %>
<% end %>

<% summary_list.with_row do |row| %>
<% row.with_key { "Decision due" } %>
<% row.with_value { (l(claim.decision_deadline_date) + decision_deadline_warning(claim, {na_text: ""})).html_safe } %>
<% row.with_value { (l(claim.decision_deadline_date, format: :admin_date) + decision_deadline_warning(claim, {na_text: ""})).html_safe } %>
<% end %>

<% summary_list.with_row do |row| %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/admin/tasks/_one_login_idv.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if @claim.onelogin_idv_at.present? %>
<div class="govuk-grid-column-two-thirds">
<p class="govuk-body">
This task was performed by GOV.UK One Login on <%= l(@claim.onelogin_idv_at) %>
This task was performed by GOV.UK One Login on <%= l(@claim.onelogin_idv_at, format: :admin_date) %>
</p>

<%= govuk_table do |table| %>
Expand All @@ -17,13 +17,13 @@
<% body.with_row do |row| %>
<% row.with_cell(header: true, text: "One Login identity verification (IDV)") %>
<% row.with_cell(text: @claim.onelogin_idv_full_name) %>
<% row.with_cell(text: l(@claim.onelogin_idv_date_of_birth)) %>
<% row.with_cell(text: l(@claim.onelogin_idv_date_of_birth, format: :admin_date)) %>
<% end %>

<% body.with_row do |row| %>
<% row.with_cell(header: true, text: "Details provided by claimant") %>
<% row.with_cell(text: @claim.full_name) %>
<% row.with_cell(text: l(@claim.date_of_birth)) %>
<% row.with_cell(text: l(@claim.date_of_birth, format: :admin_date)) %>
<% end %>
<% end %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<% else %>
an automated process
<% end %>
on <%= l(verification_email.created_at) %>
on <%= l(verification_email.created_at, format: :admin_date) %>
</p>
<% end %>
</div>
Expand Down
8 changes: 4 additions & 4 deletions app/views/admin/tasks/_task_outcome.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

<p class="govuk-body">
<% if task.manual %>
This task was performed by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.updated_at) %>
This task was performed by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.updated_at, format: :admin_date) %>
<% elsif task.created_by %>
This task was performed by an automated check uploaded by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.created_at) %>
This task was performed by an automated check uploaded by <%= user_details(task.created_by, include_line_break: false) %> on <%= l(task.created_at, format: :admin_date) %>
<% elsif task.identity_confirmation? && task.claim.identity_confirmed_with_onelogin? %>
This task was performed by GOV.UK One Login on <%= l(task.claim.onelogin_idv_at) %>
This task was performed by GOV.UK One Login on <%= l(task.claim.onelogin_idv_at, format: :admin_date) %>
<% else %>
This task was performed by an automated check on <%= l(task.created_at) %>
This task was performed by an automated check on <%= l(task.created_at, format: :admin_date) %>
<% end %>
</p>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<%= @tasks_presenter.one_login_claimant_name %>
</td>
<td class="govuk-table__cell">
<%= @tasks_presenter.one_login_claimant_dob %>
<%= l(@tasks_presenter.one_login_claimant_dob, format: :admin_date) %>
</td>
</tr>
<tr class="govuk-table__row">
Expand All @@ -49,7 +49,7 @@
<%= @tasks_presenter.provider_entered_claimant_name %>
</td>
<td class="govuk-table__cell">
<%= @tasks_presenter.practitioner_entered_dob %>
<%= l(@tasks_presenter.practitioner_entered_dob, format: :admin_date) %>
</td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/tasks/employment.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<%= govuk_inset_text(
text: I18n.t(
"#{@claim.policy.to_s.underscore}.admin.task_questions.#{@task.name}.unavailable",
employment_task_available_at: l(@claim.eligibility.employment_task_available_at)
employment_task_available_at: l(@claim.eligibility.employment_task_available_at, format: :admin_date)
)
) %>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ en:
default: "%-d %B %Y"
day_month_year: "%d/%m/%Y"
month_year: "%B %Y"
admin_date: "%d/%m/%Y"
time:
formats:
default: "%-d %B %Y %-l:%M%P"
admin_date: "%d/%m/%Y %-l:%M%P"
number:
currency:
format:
Expand Down

0 comments on commit 4f17d3c

Please sign in to comment.