From 751e76678a611240aa5d4110ae556fb6e059ed0f Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Mon, 11 Sep 2023 16:48:32 +0100 Subject: [PATCH 1/5] Remove legacy code to render travel alerts Remove code from the view that would have rendered travel alerts as part of govspeak. To our knowledge this code has never been used as it wasn't possible to set alert_status in the editor until recently. Also remove formatting from the presenter which was customised for rendering the alerts in govspeak by flattening the array of alert statuses and wrapping each in a paragraph tag. This is in readiness for rendering the alerts with warning text in the next commit. --- app/presenters/travel_advice_presenter.rb | 7 ++----- app/views/shared/_travel_advice_first_part.html.erb | 10 ---------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/app/presenters/travel_advice_presenter.rb b/app/presenters/travel_advice_presenter.rb index f398b0851..982a67102 100644 --- a/app/presenters/travel_advice_presenter.rb +++ b/app/presenters/travel_advice_presenter.rb @@ -82,14 +82,11 @@ def alert_status avoid_all_travel_to_whole_country ] alert_statuses = content_item["details"]["alert_status"] || [] - alert_statuses = alert_statuses.map do |alert| + alert_statuses.map do |alert| if allowed_statuses.include?(alert) - copy = I18n.t("travel_advice.alert_status.#{alert}_html").html_safe - view_context.tag.p(copy) + I18n.t("travel_advice.alert_status.#{alert}_html").html_safe end end - - alert_statuses.join("").html_safe end def atom_change_description diff --git a/app/views/shared/_travel_advice_first_part.html.erb b/app/views/shared/_travel_advice_first_part.html.erb index e1a8d15d4..3eae095e7 100644 --- a/app/views/shared/_travel_advice_first_part.html.erb +++ b/app/views/shared/_travel_advice_first_part.html.erb @@ -1,13 +1,3 @@ -<% if content_item.alert_status.present? %> - <%= render 'govuk_publishing_components/components/govspeak', { - direction: page_text_direction, - } do %> -
- <%= raw(content_item.alert_status) %> -
- <% end %> -<% end %> - <%= render 'govuk_publishing_components/components/metadata', content_item.metadata %> <% if content_item.map %>
From 58599176ee84afea86463c392c00e40ae861e77e Mon Sep 17 00:00:00 2001 From: Hanna Laakso Date: Mon, 25 Sep 2023 15:19:02 +0100 Subject: [PATCH 2/5] Render alert statuses with warning text component --- app/presenters/travel_advice_presenter.rb | 2 +- app/views/content_items/travel_advice.html.erb | 6 ++++++ config/locales/en.yml | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/presenters/travel_advice_presenter.rb b/app/presenters/travel_advice_presenter.rb index 982a67102..d680a5c50 100644 --- a/app/presenters/travel_advice_presenter.rb +++ b/app/presenters/travel_advice_presenter.rb @@ -84,7 +84,7 @@ def alert_status alert_statuses = content_item["details"]["alert_status"] || [] alert_statuses.map do |alert| if allowed_statuses.include?(alert) - I18n.t("travel_advice.alert_status.#{alert}_html").html_safe + I18n.t("travel_advice.alert_status.#{alert}_html", country: country_name).html_safe end end end diff --git a/app/views/content_items/travel_advice.html.erb b/app/views/content_items/travel_advice.html.erb index e2f211a62..3dcc103c9 100644 --- a/app/views/content_items/travel_advice.html.erb +++ b/app/views/content_items/travel_advice.html.erb @@ -16,6 +16,12 @@
<%= render 'govuk_publishing_components/components/title', @content_item.title_and_context %> + <% @content_item.alert_status.each do |text| %> + <%= render "govuk_publishing_components/components/warning_text", + text: text + %> + <% end %> +