Skip to content

Commit

Permalink
Only show taxonomy sidebar when tagged to a live taxon
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tijmenb committed Mar 14, 2018
1 parent 3bbc383 commit 486795c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/models/navigation_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 486795c

Please sign in to comment.