From a1ec3195fbf3677338332580ac814141c2b9b560 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 5 Jul 2023 15:09:14 +0100 Subject: [PATCH 1/5] Remove metadata component --- .../stylesheets/components/_metadata.scss | 7 ------- app/views/components/_metadata.html.erb | 6 ------ app/views/components/docs/metadata.yml | 7 ------- config/initializers/dartsass.rb | 1 - test/components/metadata_test.rb | 20 ------------------- 5 files changed, 41 deletions(-) delete mode 100644 app/assets/stylesheets/components/_metadata.scss delete mode 100644 app/views/components/_metadata.html.erb delete mode 100644 app/views/components/docs/metadata.yml delete mode 100644 test/components/metadata_test.rb diff --git a/app/assets/stylesheets/components/_metadata.scss b/app/assets/stylesheets/components/_metadata.scss deleted file mode 100644 index b284c2f238..0000000000 --- a/app/assets/stylesheets/components/_metadata.scss +++ /dev/null @@ -1,7 +0,0 @@ -@import "govuk_publishing_components/individual_component_support"; - -.app-c-metadata { - @include govuk-font($size: 16); - - color: $govuk-secondary-text-colour; -} diff --git a/app/views/components/_metadata.html.erb b/app/views/components/_metadata.html.erb deleted file mode 100644 index 053bea9ea1..0000000000 --- a/app/views/components/_metadata.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -<% - add_app_component_stylesheet("metadata") -%> -

- <%= t 'common.last_updated' %>: <%= (l last_updated, :format => '%e %B %Y').squish %> -

diff --git a/app/views/components/docs/metadata.yml b/app/views/components/docs/metadata.yml deleted file mode 100644 index 0096b136d4..0000000000 --- a/app/views/components/docs/metadata.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: Metadata -description: Calendar page metadata (i.e. last updated date). Should be called with a date object e.g. Date.parse("2-5-2008") -accessibility_criteria: Elements must have sufficient color contrast -examples: - default: - data: - last_updated: 2019-01-07 diff --git a/config/initializers/dartsass.rb b/config/initializers/dartsass.rb index 5959a8ab2c..6cb3fab60c 100644 --- a/config/initializers/dartsass.rb +++ b/config/initializers/dartsass.rb @@ -1,7 +1,6 @@ APP_STYLESHEETS = { "application.scss" => "application.css", "components/_calendar.scss" => "components/_calendar.css", - "components/_metadata.scss" => "components/_metadata.css", "components/_subscribe.scss" => "components/_subscribe.css", "views/_calendars.scss" => "views/_calendars.css", "views/_cookie-settings.scss" => "views/_cookie-settings.css", diff --git a/test/components/metadata_test.rb b/test/components/metadata_test.rb deleted file mode 100644 index 7e8cf4887d..0000000000 --- a/test/components/metadata_test.rb +++ /dev/null @@ -1,20 +0,0 @@ -require "component_test_helper" - -class MetadataComponentTest < ComponentTestCase - def component_name - "metadata" - end - - test "fails to render when no parameters given" do - assert_raise do - render_component({}) - end - end - - test "renders the component when a date object is given" do - render_component({ - last_updated: Date.parse("2-5-2008"), - }) - assert_select ".app-c-metadata", text: "Last updated: 2 May 2008" - end -end From 6d14ad72b45a6893f3c22dd236923f4428b92842 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 5 Jul 2023 15:11:06 +0100 Subject: [PATCH 2/5] Add new helper method `format_date` This helper method is used to localize the time format - https://edgeguides.rubyonrails.org/i18n.html#adding-date-time-formats --- app/helpers/calendar_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/helpers/calendar_helper.rb b/app/helpers/calendar_helper.rb index cda7cffb16..61194674ba 100644 --- a/app/helpers/calendar_helper.rb +++ b/app/helpers/calendar_helper.rb @@ -8,4 +8,8 @@ def last_updated_date def time_tag_safe(date) tag.time(datetime: date) { l(date, format: "%e %B") }.html_safe end + + def format_date(date) + l date, format: "%e %B %Y" + end end From 977c21f1cb8d4cb950d99894a7c4291649e515df Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 5 Jul 2023 15:12:44 +0100 Subject: [PATCH 3/5] Replace app `metadata` component with gem version Update the view templates for the `bank-holiday` and `when-do-the-clocks-change` to use the `metadata` component from the publishing components gem. --- app/views/calendar/bank_holidays.html.erb | 4 ++-- app/views/calendar/when_do_the_clocks_change.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/calendar/bank_holidays.html.erb b/app/views/calendar/bank_holidays.html.erb index 2133bd6f2d..ee828c06d3 100644 --- a/app/views/calendar/bank_holidays.html.erb +++ b/app/views/calendar/bank_holidays.html.erb @@ -119,8 +119,8 @@ } %> - <%= render "components/metadata", { - last_updated: last_updated_date + <%= render "govuk_publishing_components/components/metadata", { + last_updated: format_date(last_updated_date) } %> diff --git a/app/views/calendar/when_do_the_clocks_change.html.erb b/app/views/calendar/when_do_the_clocks_change.html.erb index 739d1b59e9..ccd6d7faba 100644 --- a/app/views/calendar/when_do_the_clocks_change.html.erb +++ b/app/views/calendar/when_do_the_clocks_change.html.erb @@ -52,8 +52,8 @@

<%= t('bank_holidays.gmt_explanation') %>

- <%= render "components/metadata", { - last_updated: last_updated_date + <%= render "govuk_publishing_components/components/metadata", { + last_updated: format_date(last_updated_date) } %> <%= render :partial => "calendar_footer" %> From 04d87502985957e9ef0b876eaab5bc40234e71be Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 5 Jul 2023 15:14:25 +0100 Subject: [PATCH 4/5] Remove unused translations `last_updated` was only being used in the `metadata` app component which has been removed in favour of the `metadata` component from the publishing components gem. --- config/locales/cy.yml | 1 - config/locales/en.yml | 1 - 2 files changed, 2 deletions(-) diff --git a/config/locales/cy.yml b/config/locales/cy.yml index 4cedbc9a2c..58b6b63ec2 100644 --- a/config/locales/cy.yml +++ b/config/locales/cy.yml @@ -81,7 +81,6 @@ cy: download_ics: Llwythwch y dyddiadau hyn i lawr er mwyn eu hychwanegu at raglen calendr fel iCal neu Outlook extra_bank_holiday: Gŵyl banc ychwanegol holiday_entitlement_html: Nid oes yn rhaid i'ch cyflogwr roi gwyliau â thâl i chi ar wyliau banc neu gyhoeddus. - last_updated: Diweddarwyd ddiwethaf nations: england-and-wales: Cymru a Lloegr england-and-wales_for: ar gyfer Cymru a Lloegr diff --git a/config/locales/en.yml b/config/locales/en.yml index b85450a3cd..a87e517115 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -81,7 +81,6 @@ en: download_ics: Download these dates so you can add them to a calendar application such as iCal or Outlook extra_bank_holiday: Extra bank holiday holiday_entitlement_html: Your employer does not have to give you paid leave on bank or public holidays. - last_updated: Last updated nations: england-and-wales: England and Wales england-and-wales_for: for England and Wales From c95774d147f16bce47f8a61c66d99043d563de96 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 5 Jul 2023 15:28:37 +0100 Subject: [PATCH 5/5] Update bank-holiday page tests --- test/integration/bank_holidays_test.rb | 4 ++-- test/integration/gwyliau_banc_test.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/integration/bank_holidays_test.rb b/test/integration/bank_holidays_test.rb index 33386181d5..fe70eefa84 100644 --- a/test/integration/bank_holidays_test.rb +++ b/test/integration/bank_holidays_test.rb @@ -257,8 +257,8 @@ class BankHolidaysTest < ActionDispatch::IntegrationTest should "be formatted correctly" do Timecop.travel(Date.parse("5th Dec 2012")) do visit "/bank-holidays" - within ".app-c-metadata" do - assert page.has_content?("Last updated: 5 December 2012") + within ".gem-c-metadata" do + assert page.has_content?("Last updated 5 December 2012") end end end diff --git a/test/integration/gwyliau_banc_test.rb b/test/integration/gwyliau_banc_test.rb index 96107e0735..6e373b10ef 100644 --- a/test/integration/gwyliau_banc_test.rb +++ b/test/integration/gwyliau_banc_test.rb @@ -212,8 +212,8 @@ class GwyliauBancTest < ActionDispatch::IntegrationTest should "be translated and localised" do Timecop.travel(Date.parse("25th Dec 2012")) do visit "/gwyliau-banc" - within ".app-c-metadata" do - assert page.has_content?("Diweddarwyd ddiwethaf: 25 Rhagfyr 2012") + within ".gem-c-metadata" do + assert page.has_content?("Diweddarwyd ddiwethaf 25 Rhagfyr 2012") end end end