From fd7154f166a3d41449b6dc1e3d6d915adac322ba Mon Sep 17 00:00:00 2001 From: Peter Hartshorn Date: Thu, 21 Jul 2022 15:36:43 +0100 Subject: [PATCH 1/3] Remove TODO's We're no longer planning on tagging manual attributes to sections. --- app/presenters/content_item/manual_section.rb | 2 -- app/views/layouts/application.html.erb | 1 - 2 files changed, 3 deletions(-) diff --git a/app/presenters/content_item/manual_section.rb b/app/presenters/content_item/manual_section.rb index d67b2061f..49a721784 100644 --- a/app/presenters/content_item/manual_section.rb +++ b/app/presenters/content_item/manual_section.rb @@ -20,8 +20,6 @@ def breadcrumb end def manual_content_item - # TODO: Add the same tagging to a normal section as a manual for contextual breadcrumbs - # TODO: Add the manual published / public updated at to both manual sections (normal and HMRC) @manual_content_item ||= Services.content_store.content_item(base_path) end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6f206e855..8f459a9bc 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,7 +42,6 @@ <%= render 'govuk_publishing_components/components/breadcrumbs', breadcrumbs: [ { url: "/", title: "Home" } , { url: "/brexit", title: "Brexit" } ] %> <% else %> - <%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.try(:manual_content_item) || @content_item.content_item.parsed_content %> <% end %> From 0666708f5fd051c1035b6b3999ff111d317348b2 Mon Sep 17 00:00:00 2001 From: Peter Hartshorn Date: Thu, 21 Jul 2022 15:38:08 +0100 Subject: [PATCH 2/3] Use manual title from its content item --- app/presenters/hmrc_manual_section_presenter.rb | 8 ++++---- test/presenters/hmrc_manual_section_presenter_test.rb | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/presenters/hmrc_manual_section_presenter.rb b/app/presenters/hmrc_manual_section_presenter.rb index db2e1b16c..47d72df00 100644 --- a/app/presenters/hmrc_manual_section_presenter.rb +++ b/app/presenters/hmrc_manual_section_presenter.rb @@ -7,10 +7,6 @@ def base_path details["manual"]["base_path"] end - def title - details["manual"]["title"] - end - def breadcrumbs crumbs = manual_breadcrumbs.dup @@ -85,6 +81,10 @@ def adjacent_siblings [before.try(:last), after.try(:first)] end + def manual + parent_base_path == base_path ? parent_for_section : manual_content_item + end + def parent_base_path content_item_breadcrumbs.present? ? content_item_breadcrumbs.last["base_path"] : base_path end diff --git a/test/presenters/hmrc_manual_section_presenter_test.rb b/test/presenters/hmrc_manual_section_presenter_test.rb index 44a111460..9227b7541 100644 --- a/test/presenters/hmrc_manual_section_presenter_test.rb +++ b/test/presenters/hmrc_manual_section_presenter_test.rb @@ -34,7 +34,10 @@ class PresentedHmrcManualSectionTest < HmrcManualSectionPresenterTestCase end test "presents manual title" do - manual = schema_item("vatgpb2000")["details"]["manual"] + manual_base_path = schema_item("vatgpb2000")["details"]["manual"]["base_path"] + manual = schema_item("vat-government-public-bodies", "hmrc_manual") + stub_content_store_has_item(manual_base_path, manual.to_json) + assert_equal manual["title"], presented_manual_section.title end From f485c27be69d8fd4bd3afa831f1b11f40ec60252 Mon Sep 17 00:00:00 2001 From: Peter Hartshorn Date: Thu, 21 Jul 2022 15:38:57 +0100 Subject: [PATCH 3/3] Add parsed_content_item method to clean up code --- app/presenters/content_item/manual_section.rb | 4 ++++ app/presenters/content_item_presenter.rb | 4 ++++ app/views/layouts/application.html.erb | 3 +-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/presenters/content_item/manual_section.rb b/app/presenters/content_item/manual_section.rb index 49a721784..938a27eba 100644 --- a/app/presenters/content_item/manual_section.rb +++ b/app/presenters/content_item/manual_section.rb @@ -23,6 +23,10 @@ def manual_content_item @manual_content_item ||= Services.content_store.content_item(base_path) end + def parsed_content_item + manual_content_item.parsed_content + end + def published display_date(manual_content_item["first_published_at"]) end diff --git a/app/presenters/content_item_presenter.rb b/app/presenters/content_item_presenter.rb index fd2a68232..51b96526a 100644 --- a/app/presenters/content_item_presenter.rb +++ b/app/presenters/content_item_presenter.rb @@ -36,6 +36,10 @@ def initialize(content_item, requested_path, view_context) @part_slug = requesting_a_part? ? requested_path.split("/").last : nil end + def parsed_content_item + content_item.parsed_content + end + def requesting_a_part? false end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8f459a9bc..8365fdb16 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -42,8 +42,7 @@ <%= render 'govuk_publishing_components/components/breadcrumbs', breadcrumbs: [ { url: "/", title: "Home" } , { url: "/brexit", title: "Brexit" } ] %> <% else %> - <%= render 'govuk_publishing_components/components/contextual_breadcrumbs', - content_item: @content_item.try(:manual_content_item) || @content_item.content_item.parsed_content %> + <%= render 'govuk_publishing_components/components/contextual_breadcrumbs', content_item: @content_item.parsed_content_item %> <% end %> <% end %>