From 3bbc383ca170f645ab46f6e7d8f59f8c5d387431 Mon Sep 17 00:00:00 2001 From: Tijmen Brommet Date: Wed, 14 Mar 2018 15:30:31 +0000 Subject: [PATCH 1/2] Add HTML comments about the sidebar decision One of the hard things in debugging the problems with the sidebar was that we couldn't determine what the page was supposed to show. This would have been very helpful. --- app/views/shared/_sidebar_navigation.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/shared/_sidebar_navigation.html.erb b/app/views/shared/_sidebar_navigation.html.erb index d0bcbd526..d30ddc31e 100644 --- a/app/views/shared/_sidebar_navigation.html.erb +++ b/app/views/shared/_sidebar_navigation.html.erb @@ -1,10 +1,13 @@ <% if step_nav_helper.show_related_links? %> + <%= render 'shared/sidebar_step_nav', no_margin: true %> <% else %>
<% if @navigation.should_present_taxonomy_navigation? %> + <%= render partial: 'govuk_component/taxonomy_sidebar', locals: @content_item.taxonomy_sidebar %> <% else %> + <%= render 'govuk_publishing_components/components/related_navigation', @content_item.content_item.parsed_content %> <% end %>
From 486795c6fdb2b799742ab51fd7c3928c0eb99a8e Mon Sep 17 00:00:00 2001 From: Tijmen Brommet Date: Wed, 14 Mar 2018 15:33:34 +0000 Subject: [PATCH 2/2] Only show taxonomy sidebar when tagged to a live taxon The recent changes to the taxonomy exposed that we have duplicated logic between this application and the components. At the moment this app thinks that there are taxons, so it tries to show the sidebar. However, the `govuk_component/taxonomy_sidebar` component *doesn't* think there are taxons, because it only looks at the live ones. This is a temporary fix, we will re-architect this so that the logic is simple and in only one place. --- app/models/navigation_type.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/navigation_type.rb b/app/models/navigation_type.rb index 57b46bc52..15ef1706c 100644 --- a/app/models/navigation_type.rb +++ b/app/models/navigation_type.rb @@ -8,14 +8,14 @@ def initialize(content_item) def should_present_taxonomy_navigation? !content_is_tagged_to_browse_pages? && - content_is_tagged_to_a_taxon? && + content_is_tagged_to_a_live_taxon? && content_schema_is_guidance? end private - def content_is_tagged_to_a_taxon? - @content_item.dig("links", "taxons").present? + def content_is_tagged_to_a_live_taxon? + @content_item.dig("links", "taxons").to_a.any? { |taxon| taxon["phase"] == "live" } end def content_is_tagged_to_browse_pages?