From 19f9ac292348ed8c6256e27bcc976d45a3de14a5 Mon Sep 17 00:00:00 2001 From: hannako Date: Wed, 31 Aug 2022 16:45:55 +0100 Subject: [PATCH 1/2] Add single page notification button to document collections --- app/presenters/document_collection_presenter.rb | 1 + app/views/content_items/document_collection.html.erb | 1 + test/integration/document_collection_test.rb | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/presenters/document_collection_presenter.rb b/app/presenters/document_collection_presenter.rb index 8440dd624..ac977202c 100644 --- a/app/presenters/document_collection_presenter.rb +++ b/app/presenters/document_collection_presenter.rb @@ -4,6 +4,7 @@ class DocumentCollectionPresenter < ContentItemPresenter include ContentItem::Political include ContentItem::TitleAndContext include ContentItem::ContentsList + include ContentItem::SinglePageNotificationButton def contents_items groups.map do |group| diff --git a/app/views/content_items/document_collection.html.erb b/app/views/content_items/document_collection.html.erb index 0a95dcebd..584ddd473 100644 --- a/app/views/content_items/document_collection.html.erb +++ b/app/views/content_items/document_collection.html.erb @@ -22,6 +22,7 @@ <%= render 'shared/publisher_metadata_with_logo' %> +<%= render 'shared/single_page_notification_button', content_item: @content_item %>
diff --git a/test/integration/document_collection_test.rb b/test/integration/document_collection_test.rb index 0494022a5..43aa07752 100644 --- a/test/integration/document_collection_test.rb +++ b/test/integration/document_collection_test.rb @@ -154,8 +154,8 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest end end - test "does not render with the single page notification button" do + test "renders with the single page notification button" do setup_and_visit_content_item("document_collection") - assert_not page.has_css?(".gem-c-single-page-notification-button") + assert page.has_css?(".gem-c-single-page-notification-button") end end From f766dc117baa42b7e5f1e02ff96777d84a527cb8 Mon Sep 17 00:00:00 2001 From: Jessica Jones Date: Fri, 3 Feb 2023 14:45:08 +0000 Subject: [PATCH 2/2] Update button to skip the govuk-account The single page notification button component, by default, enforces creating/signing in to a gov.uk account. It has a default form action of "/email/subscriptions/single-page/new". Passing in the optional paramater `skip_account` sets a form action of "/email-signup" which does not enforce the gov.uk account See govuk_publishing_components/presenters/single_page_notification_button_helper.rb#L63-L69 --- app/views/content_items/document_collection.html.erb | 2 +- .../shared/_published_dates_with_notification_button.html.erb | 4 +++- app/views/shared/_single_page_notification_button.html.erb | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/content_items/document_collection.html.erb b/app/views/content_items/document_collection.html.erb index 584ddd473..7f3e398e2 100644 --- a/app/views/content_items/document_collection.html.erb +++ b/app/views/content_items/document_collection.html.erb @@ -22,7 +22,7 @@
<%= render 'shared/publisher_metadata_with_logo' %> -<%= render 'shared/single_page_notification_button', content_item: @content_item %> +<%= render 'shared/single_page_notification_button', content_item: @content_item, skip_account: "true" %>
diff --git a/app/views/shared/_published_dates_with_notification_button.html.erb b/app/views/shared/_published_dates_with_notification_button.html.erb index 515276104..94e7e8852 100644 --- a/app/views/shared/_published_dates_with_notification_button.html.erb +++ b/app/views/shared/_published_dates_with_notification_button.html.erb @@ -1,4 +1,5 @@ <% add_view_stylesheet("published-dates-button-group") %> +<% skip_account = skip_account || "false" %> <%= render 'components/published_dates', { published: @content_item.published, @@ -13,6 +14,7 @@ js_enhancement: @has_govuk_account, button_location: "bottom", margin_bottom: 3, + skip_account: skip_account, ga4_data_attributes: { module: "ga4-link-tracker", ga4_link: { @@ -24,7 +26,7 @@ index_total: 2, section: "Footer" } - } + } } if @content_item.has_single_page_notifications? %> <%= render "govuk_publishing_components/components/print_link", { margin_top: 0, diff --git a/app/views/shared/_single_page_notification_button.html.erb b/app/views/shared/_single_page_notification_button.html.erb index 4781454e4..add2a1ea5 100644 --- a/app/views/shared/_single_page_notification_button.html.erb +++ b/app/views/shared/_single_page_notification_button.html.erb @@ -14,6 +14,7 @@ %> <% ga4_data_attributes = ga4_data_attributes || default_ga4_data_attributes %> +<% skip_account = skip_account || "false" %> <%= render 'govuk_publishing_components/components/single_page_notification_button', { base_path: @content_item.base_path, @@ -21,4 +22,5 @@ ga4_data_attributes: ga4_data_attributes, margin_bottom: 6, button_location: "top", + skip_account: skip_account, } if @content_item.has_single_page_notifications? %>