govuk_publishing_components 6.5.0 → 6.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 07a0593663e9c5f0382e38e40b4cdd4e83e5c87b1010f040add2f9272763bc47
4
- data.tar.gz: 81dab152fcdf00ab3f9ac78aaa97119c08eaf167c2324710043fda7e5c511524
3
+ metadata.gz: ba58789467891b5f446dd9487b0984dd34d98ba61582e432a68036b994adcb8b
4
+ data.tar.gz: b51a14f8281b3a1e06238b7aa7987a0ef6bea4b4669efdda94b381f20c42a973
5
5
  SHA512:
6
- metadata.gz: 475babd9cbe5265f77983b1ee83b56f782751ed02799c85cf9928210ed32db56e8f9244323fedb3bfc55fe1d781397c3cd11e468f6f9e7e09263edcb5597fb2c
7
- data.tar.gz: 159320d6deaabaa6e72df96b941fae40ba97e5e4fa6c31336e16c0ca39ee9ddaf830e0bdf0c27365e76315050f48cb5939ed989f3240a440c7834e72c2460f42
6
+ metadata.gz: 22a327348059ef856523174f4ea4bfdc4cb67af5b57cd5b9a0599daefcd319d8d202a11892273dd1e08c70624219cf17f94db26d5776aee0e8bb2336e069c825
7
+ data.tar.gz: 2eccea1e451c11974f6bd94bdce97f070eb3ea97cce2a24bfaf3b51b7a63279707b96695fb093b480905f72e744bd9eb38ec51203bcbf37b81c4d65a1aec285d
@@ -3,12 +3,13 @@
3
3
  }
4
4
 
5
5
  .gem-c-related-navigation__main-heading {
6
+ @include bold-19;
6
7
  margin-top: $gutter-half;
7
8
  margin-bottom: $gutter-one-third;
8
- @include bold-19;
9
9
  }
10
10
 
11
11
  .gem-c-related-navigation__sub-heading {
12
+ @include core-16;
12
13
  border-top: 1px solid $border-colour;
13
14
  padding-top: $gutter-half;
14
15
  }
@@ -28,16 +29,19 @@
28
29
 
29
30
  .gem-c-related-navigation__link {
30
31
  list-style-type: none;
31
- margin-bottom: $gutter-one-third;
32
+ margin-top: $gutter-half;
33
+
34
+ @include media(tablet) {
35
+ margin-top: 5px;
36
+ }
32
37
  }
33
38
 
34
39
  .gem-c-related-navigation__section-link {
35
- text-decoration: none;
36
- @include bold-19;
40
+ @include bold-16;
37
41
  }
38
42
 
39
43
  .gem-c-related-navigation__section-link--other {
40
- text-decoration: none;
44
+ @include core-16;
41
45
  }
42
46
 
43
47
  // reset the default browser styles
@@ -1,10 +1,16 @@
1
1
  .gem-c-step-nav-related {
2
- margin-bottom: $gutter-half;
2
+ border-top: 2px solid $govuk-blue;
3
+ margin-bottom: $gutter * 1.5;
3
4
  }
4
5
 
5
- .gem-c-step-nav-related__heading,
6
- .gem-c-step-nav-related__links {
6
+ .gem-c-step-nav-related__heading {
7
+ margin-top: $gutter-half;
8
+ margin-bottom: $gutter-one-third;
7
9
  @include bold-19;
10
+ }
11
+
12
+ .gem-c-step-nav-related__links {
13
+ @include bold-16;
8
14
  margin: 0;
9
15
  padding: 0;
10
16
  }
@@ -1,20 +1,23 @@
1
1
  <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request.path) %>
2
2
 
3
- <% if navigation.step_nav_helper.show_header? %>
4
- <!-- Rendering step by step nav -->
5
- <%= render 'govuk_publishing_components/components/step_by_step_nav_header', navigation.step_nav_helper.header %>
3
+ <% if navigation.content_tagged_to_single_step_by_step? %>
4
+ <!-- Rendering step by step nav breadcrumbs because there's 1 step by step -->
5
+ <%= render 'govuk_publishing_components/components/step_by_step_nav_header',
6
+ navigation.step_nav_helper.header %>
7
+ <% elsif navigation.content_tagged_to_mainstream_browse_pages? %>
8
+ <!-- Rendering parent-based breadcrumbs because the page is tagged to mainstream browse -->
9
+ <%= render 'govuk_component/breadcrumbs', breadcrumbs: navigation.breadcrumbs %>
10
+ <% elsif navigation.content_has_curated_related_items? %>
11
+ <!-- Rendering parent-based breadcrumbs because the page has curated related links -->
12
+ <%= render 'govuk_component/breadcrumbs', breadcrumbs: navigation.breadcrumbs %>
13
+ <% elsif navigation.content_is_tagged_to_a_live_taxon? %>
14
+ <!-- Rendering taxonomy breadcrumbs because the page is tagged to live taxons -->
15
+ <%= render 'govuk_component/breadcrumbs',
16
+ breadcrumbs: navigation.taxon_breadcrumbs[:breadcrumbs],
17
+ collapse_on_mobile: true %>
18
+ <% elsif navigation.breadcrumbs.any? %>
19
+ <!-- Rendering parent-based breadcrumbs because no browse, no related links, no live taxons -->
20
+ <%= render 'govuk_component/breadcrumbs', breadcrumbs: navigation.breadcrumbs %>
6
21
  <% else %>
7
- <% if navigation.should_present_taxonomy_navigation? %>
8
- <!-- Rendering taxonomy breadcrumbs -->
9
- <% if navigation.taxon_breadcrumbs.any? %>
10
- <%= render 'govuk_component/breadcrumbs',
11
- breadcrumbs: navigation.taxon_breadcrumbs[:breadcrumbs],
12
- collapse_on_mobile: true %>
13
- <% end %>
14
- <% else %>
15
- <!-- Rendering normal breadcrumbs -->
16
- <% if navigation.breadcrumbs.any? %>
17
- <%= render 'govuk_component/breadcrumbs', breadcrumbs: navigation.breadcrumbs %>
18
- <% end %>
19
- <% end %>
22
+ <!-- Not rendering any breadcrumbs because there aren't any -->
20
23
  <% end %>
@@ -1,19 +1,23 @@
1
1
  <% navigation = GovukPublishingComponents::Presenters::ContextualNavigation.new(content_item, request.path) %>
2
2
 
3
- <% if navigation.step_nav_helper.show_related_links? %>
4
- <!-- rendering step by step related items -->
3
+ <% if navigation.content_tagged_to_a_reasonable_number_of_step_by_steps? %>
4
+ <!-- Rendering step by step related items because there are a few but not too many of them -->
5
5
  <%= render 'govuk_publishing_components/components/step_by_step_nav_related', links: navigation.step_nav_helper.related_links %>
6
+ <% end %>
6
7
 
7
- <% if navigation.step_nav_helper.show_sidebar? %>
8
- <!-- rendering step by step sidebar -->
9
- <%= render 'govuk_publishing_components/components/step_by_step_nav', navigation.step_nav_helper.sidebar %>
10
- <% end %>
8
+ <% if navigation.content_tagged_to_single_step_by_step? %>
9
+ <!-- Rendering step by step sidebar because there's 1 step by step list -->
10
+ <%= render 'govuk_publishing_components/components/step_by_step_nav', navigation.step_nav_helper.sidebar %>
11
+ <% elsif navigation.content_tagged_to_mainstream_browse_pages? %>
12
+ <!-- Rendering related navigation sidebar because the page is tagged to mainstream browse -->
13
+ <%= render 'govuk_publishing_components/components/related_navigation', content_item %>
14
+ <% elsif navigation.content_has_curated_related_items? %>
15
+ <!-- Rendering related navigation sidebar because the page has curated related links -->
16
+ <%= render 'govuk_publishing_components/components/related_navigation', content_item %>
17
+ <% elsif navigation.content_is_tagged_to_a_live_taxon? %>
18
+ <!-- Rendering taxonomy sidebar because the page is tagged to live taxons -->
19
+ <%= render 'govuk_publishing_components/components/taxonomy_navigation', navigation.taxonomy_sidebar %>
11
20
  <% else %>
12
- <% if navigation.should_present_taxonomy_navigation? %>
13
- <!-- rendering taxonomy sidebar -->
14
- <%= render 'govuk_publishing_components/components/taxonomy_navigation', navigation.taxonomy_sidebar %>
15
- <% else %>
16
- <!-- rendering related navigation sidebar -->
17
- <%= render 'govuk_publishing_components/components/related_navigation', content_item %>
18
- <% end %>
21
+ <!-- Rendering related navigation sidebar because no browse, no related links, no live taxons -->
22
+ <%= render 'govuk_publishing_components/components/related_navigation', content_item %>
19
23
  <% end %>
@@ -1,77 +1,27 @@
1
1
  <% related_nav_helper = GovukPublishingComponents::Presenters::RelatedNavigationHelper.new(local_assigns) %>
2
- <% related_content = related_nav_helper.related_navigation %>
3
- <% if related_content.map(&:values).flatten.any? || related_nav_helper.other.flatten.any? %>
4
- <% random = SecureRandom.hex(4) %>
2
+
3
+ <% if related_nav_helper.anything_to_show? %>
4
+ <% random = SecureRandom.hex(4) %>
5
5
  <div class="gem-c-related-navigation">
6
6
  <h2 id="related-nav-related_items-<%= random %>"
7
7
  class="gem-c-related-navigation__main-heading"
8
8
  data-track-count="sidebarRelatedItemSection" >
9
9
  <%= t('components.related_navigation.related_content') %>
10
10
  </h2>
11
+
11
12
  <% section_index = 0 %>
12
- <% related_content.each do |section| %>
13
- <% section.each do |section_title, links| %>
14
- <% if links.any? %>
15
- <% section_index += 1 %>
16
- <nav role="navigation"
17
- class="gem-c-related-navigation__nav-section"
18
- aria-labelledby="related-nav-<%= section_title %>-<%= random %>"
19
- data-module="toggle">
20
- <% unless section_title === "related_items" %>
21
- <h3 id="related-nav-<%= section_title %>-<%= random %>"
22
- data-track-count="sidebarRelatedItemSection"
23
- class="<%= related_nav_helper.section_css_class("gem-c-related-navigation__sub-heading", section_title) %>">
24
- <%= related_nav_helper.construct_section_heading(section_title) %>
25
- </h3>
26
- <% end %>
27
- <ul class="gem-c-related-navigation_link-list" data-module="track-click">
28
- <% constructed_link_array = [] %>
29
- <% section_link_limit = related_nav_helper.calculate_section_link_limit(links) %>
30
- <% links.each.with_index(1) do |link, index| %>
31
- <%
32
- link_element = link_to(
33
- link[:text],
34
- link[:path],
35
- class: related_nav_helper.section_css_class("gem-c-related-navigation__section-link", section_title, link),
36
- rel: link[:rel],
37
- data: {
38
- track_category: 'relatedLinkClicked',
39
- track_action: "#{section_index}.#{index} #{related_nav_helper.construct_section_heading(section_title) || t('components.related_navigation.related_content')}",
40
- track_label: link[:path],
41
- track_options: {
42
- dimension28: links.length.to_s,
43
- dimension29: link[:text]
44
- }
45
- }
46
- )
47
- %>
48
- <% if index <= section_link_limit %>
49
- <li class="gem-c-related-navigation__link"><%= link_element %></li>
50
- <% else %>
51
- <% constructed_link_array.push(link_element) %>
52
- <% end %>
53
- <% end %>
54
- <% if links.length > section_link_limit %>
55
- <li class="gem-c-related-navigation__link toggle-wrap">
56
- <a href="#"
57
- data-controls="toggle_<%= section_title %>"
58
- data-expanded="false"
59
- data-toggled-text="<%= t("govuk_component.metadata.toggle_less", default: "Show fewer") %>">
60
- <%= t("govuk_component.metadata.toggle_more",
61
- number: related_nav_helper.remaining_link_count(links),
62
- default: "+ #{related_nav_helper.remaining_link_count(links)} more") %>
63
- </a>
64
- </li>
65
- <li class="gem-c-related-navigation__link">
66
- <span id="toggle_<%= section_title %>" class="js-hidden">
67
- <%= constructed_link_array.to_sentence.html_safe %>
68
- </span>
69
- </li>
70
- <% end %>
71
- </ul>
72
- </nav>
73
- <% end %>
74
- <% end %>
13
+
14
+ <% related_nav_helper.related_navigation.each do |section_title, links| %>
15
+ <% next unless links.any? %>
16
+
17
+ <% section_index += 1 %>
18
+
19
+ <%= render 'govuk_publishing_components/components/related_navigation/section',
20
+ related_nav_helper: related_nav_helper,
21
+ section_title: section_title,
22
+ links: links,
23
+ section_index: section_index,
24
+ random: random %>
75
25
  <% end %>
76
26
  </div>
77
27
  <% end %>
@@ -1,8 +1,8 @@
1
1
  <%
2
- links ||= false
2
+ links ||= []
3
3
  pretitle ||= t("govuk_component.step_by_step_nav_related.part_of", default: "Part of")
4
4
  %>
5
- <% if links %>
5
+ <% if links.any? %>
6
6
  <div class="gem-c-step-nav-related" data-module="track-click">
7
7
  <h2 class="gem-c-step-nav-related__heading">
8
8
  <span class="gem-c-step-nav-related__pretitle"><%= pretitle %></span>
@@ -29,3 +29,16 @@ examples:
29
29
  ordered_related_items:
30
30
  - title: "Find an apprenticeship"
31
31
  base_path: "/apply-apprenticeship"
32
+ with_step_by_step:
33
+ data:
34
+ content_item:
35
+ title: "A content item"
36
+ links:
37
+ part_of_step_navs:
38
+ - title: "Choosing a micropig or micropug: step by step"
39
+ base_path: "/micropigs-vs-micropugs"
40
+ - title: "Walk your micropig: step by step"
41
+ base_path: "/porgs-step-by-step"
42
+ ordered_related_items:
43
+ - title: "Find an apprenticeship"
44
+ base_path: "/apply-apprenticeship"
@@ -0,0 +1,63 @@
1
+ <nav role="navigation"
2
+ class="gem-c-related-navigation__nav-section"
3
+ aria-labelledby="related-nav-<%= section_title %>-<%= random %>"
4
+ data-module="toggle">
5
+
6
+ <% unless section_title === "related_items" %>
7
+ <h3 id="related-nav-<%= section_title %>-<%= random %>"
8
+ data-track-count="sidebarRelatedItemSection"
9
+ class="<%= related_nav_helper.section_css_class("gem-c-related-navigation__sub-heading", section_title) %>">
10
+ <%= related_nav_helper.construct_section_heading(section_title) %>
11
+ </h3>
12
+ <% end %>
13
+
14
+ <ul class="gem-c-related-navigation_link-list" data-module="track-click">
15
+ <% constructed_link_array = [] %>
16
+
17
+ <% section_link_limit = related_nav_helper.calculate_section_link_limit(links) %>
18
+
19
+ <% links.each.with_index(1) do |link, index| %>
20
+ <%
21
+ link_element = link_to(
22
+ link[:text],
23
+ link[:path],
24
+ class: related_nav_helper.section_css_class("gem-c-related-navigation__section-link", section_title, link),
25
+ rel: link[:rel],
26
+ data: {
27
+ track_category: 'relatedLinkClicked',
28
+ track_action: "#{section_index}.#{index} #{related_nav_helper.construct_section_heading(section_title) || t('components.related_navigation.related_content')}",
29
+ track_label: link[:path],
30
+ track_options: {
31
+ dimension28: links.length.to_s,
32
+ dimension29: link[:text]
33
+ }
34
+ }
35
+ )
36
+ %>
37
+ <% if index <= section_link_limit %>
38
+ <li class="gem-c-related-navigation__link"><%= link_element %></li>
39
+ <% else %>
40
+ <% constructed_link_array.push(link_element) %>
41
+ <% end %>
42
+ <% end %>
43
+
44
+ <% if links.length > section_link_limit %>
45
+ <li class="gem-c-related-navigation__link toggle-wrap">
46
+ <a href="#"
47
+ data-controls="toggle_<%= section_title %>"
48
+ data-expanded="false"
49
+ data-toggled-text="<%= t("govuk_component.metadata.toggle_less", default: "Show fewer") %>">
50
+ <%= t("govuk_component.metadata.toggle_more",
51
+ number: related_nav_helper.remaining_link_count(links),
52
+ default: "+ #{related_nav_helper.remaining_link_count(links)} more") %>
53
+ </a>
54
+ </li>
55
+
56
+ <li class="gem-c-related-navigation__link">
57
+ <span id="toggle_<%= section_title %>" class="js-hidden">
58
+ <%= constructed_link_array.to_sentence.html_safe %>
59
+ </span>
60
+ </li>
61
+ <% end %>
62
+ </ul>
63
+ </nav>
@@ -31,7 +31,9 @@ en:
31
31
  policies: "Policy"
32
32
  publishers: "Published by"
33
33
  related_content: "Related content"
34
+ related_external_links: "Elsewhere on the web"
34
35
  related_guides: "Detailed guidance"
36
+ related_contacts: "Other contacts"
35
37
  statistical_data_sets: "Statistical data set"
36
38
  topics: "Explore the topic"
37
39
  topical_events: "Topical event"
@@ -1,7 +1,6 @@
1
1
  require "govuk_publishing_components/config"
2
2
  require "govuk_publishing_components/engine"
3
3
  require "govuk_publishing_components/presenters/contextual_navigation"
4
- require "govuk_publishing_components/presenters/navigation_type"
5
4
  require "govuk_publishing_components/presenters/related_navigation_helper"
6
5
  require "govuk_publishing_components/presenters/step_by_step_nav_helper"
7
6
  require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
@@ -39,9 +39,25 @@ module GovukPublishingComponents
39
39
  end
40
40
  end
41
41
 
42
- def should_present_taxonomy_navigation?
43
- navigation = NavigationType.new(content_item)
44
- navigation.should_present_taxonomy_navigation?
42
+ def content_tagged_to_mainstream_browse_pages?
43
+ content_item.dig("links", "mainstream_browse_pages").present?
44
+ end
45
+
46
+ def content_has_curated_related_items?
47
+ content_item.dig("links", "ordered_related_items").present?
48
+ end
49
+
50
+ def content_is_tagged_to_a_live_taxon?
51
+ content_item.dig("links", "taxons").to_a.any? { |taxon| taxon["phase"] == "live" }
52
+ end
53
+
54
+ def content_tagged_to_single_step_by_step?
55
+ # TODO: remove indirection here
56
+ step_nav_helper.show_header?
57
+ end
58
+
59
+ def content_tagged_to_a_reasonable_number_of_step_by_steps?
60
+ step_nav_helper.show_related_links?
45
61
  end
46
62
 
47
63
  def step_nav_helper
@@ -19,31 +19,18 @@ module GovukPublishingComponents
19
19
  end
20
20
 
21
21
  def related_navigation
22
- @related_content ||= [
23
- { "related_items" => related_items },
24
- { "related_guides" => related_guides },
25
- { "collections" => related_collections },
26
- { "topics" => related_topics },
27
- { "policies" => related_policies },
28
- { "topical_events" => related_topical_events },
29
- { "world_locations" => related_world_locations },
30
- { "statistical_data_sets" => related_statistical_data_sets },
31
- ]
32
-
33
- other = [related_external_links, related_contacts] || []
34
- other.each do |sections|
35
- sections.each do |section|
36
- @related_content.push(
37
- section["title"].tr(' ', '_') => section["links"]
38
- )
39
- end
40
- end
41
-
42
- @related_content
43
- end
44
-
45
- def other
46
- @other ||= []
22
+ {
23
+ "related_items" => related_items,
24
+ "related_guides" => related_guides,
25
+ "collections" => related_collections,
26
+ "topics" => related_topics,
27
+ "policies" => related_policies,
28
+ "topical_events" => related_topical_events,
29
+ "world_locations" => related_world_locations,
30
+ "statistical_data_sets" => related_statistical_data_sets,
31
+ "related_external_links" => related_external_links,
32
+ "related_contacts" => related_contacts,
33
+ }
47
34
  end
48
35
 
49
36
  def construct_section_heading(section_title)
@@ -67,6 +54,10 @@ module GovukPublishingComponents
67
54
  links.length - MAX_SECTION_LENGTH
68
55
  end
69
56
 
57
+ def anything_to_show?
58
+ related_navigation.flat_map(&:last).any?
59
+ end
60
+
70
61
  private
71
62
 
72
63
  def build_links_for_sidebar(collection, path_key = "base_path", additional_attr = {})
@@ -126,10 +117,14 @@ module GovukPublishingComponents
126
117
  end
127
118
 
128
119
  def related_topics
129
- topics = filter_link_type("topics", "topic")
130
- links = build_links_for_sidebar(topics)
131
- links << related_mainstream_topic << related_mainstream_parent_topic
132
- deduplicate_topics_by_title(links.compact)
120
+ mainstream_browse_pages = filter_link_type("mainstream_browse_pages", "mainstream_browse_page")
121
+
122
+ topics_that_dont_duplicate_browse = filter_link_type("topics", "topic").select do |topic|
123
+ mainstream_browse_pages.none? { |browse_page| browse_page["title"] == topic["title"] }
124
+ end
125
+
126
+ links = build_links_for_sidebar(mainstream_browse_pages + topics_that_dont_duplicate_browse)
127
+ links.compact
133
128
  end
134
129
 
135
130
  def related_topical_events
@@ -139,54 +134,12 @@ module GovukPublishingComponents
139
134
 
140
135
  def related_contacts
141
136
  contacts = filter_link_type("related", "contact")
142
- return [] unless contacts.any?
143
- [
144
- "title" => "Other contacts",
145
- "links" => build_links_for_sidebar(contacts)
146
- ]
137
+ build_links_for_sidebar(contacts)
147
138
  end
148
139
 
149
140
  def related_external_links
150
141
  external_links = @content_item.dig("details", "external_related_links").to_a
151
- return [] unless external_links.any?
152
- [
153
- "title" => "Elsewhere on the web",
154
- "links" => build_links_for_sidebar(external_links, "url", rel: 'external')
155
- ]
156
- end
157
-
158
- def related_mainstream_topic
159
- return unless tagged_to_same_mainstream_browse_page.any?
160
- { text: parent["title"], path: parent["base_path"] }
161
- end
162
-
163
- def related_mainstream_parent_topic
164
- return unless parents_tagged_to_same_mainstream_browse_page.any?
165
- { text: grandparent["title"], path: grandparent["base_path"] }
166
- end
167
-
168
- def parent
169
- link_group("parent").first
170
- end
171
-
172
- def grandparent
173
- parent.dig("links", "parent", 0)
174
- end
175
-
176
- # This method post-processes the topics collated by the helper.
177
- # We add mainstream browse page links if they are present, however
178
- # if these have the same title as an existing topic we should prefer
179
- # the mainstream version and remove the existing topic.
180
- # @see spec/related_navigation_helper_spec.rb for test coverage.
181
- def deduplicate_topics_by_title(topics)
182
- is_dupe = lambda { |a, b| a && a != b && a[:text] == b[:text] }
183
-
184
- topics.delete_if do |t|
185
- is_dupe.call(related_mainstream_topic, t) ||
186
- is_dupe.call(related_mainstream_parent_topic, t)
187
- end
188
-
189
- topics
142
+ build_links_for_sidebar(external_links, "url", rel: "external")
190
143
  end
191
144
 
192
145
  def parameterise(str, sep = "-")
@@ -201,28 +154,6 @@ module GovukPublishingComponents
201
154
  parameterised_str.downcase
202
155
  end
203
156
 
204
- def tagged_to_same_mainstream_browse_page
205
- return [] unless parent
206
- @tagged_to_same_mainstream_browse_page ||= related_links.select do |related_item|
207
- links = related_item.dig("links", "mainstream_browse_pages") || []
208
- content_ids = links.any? ? links.map { |page| page["content_id"] } : []
209
- content_ids.include?(parent["content_id"])
210
- end
211
- end
212
-
213
- def parents_tagged_to_same_mainstream_browse_page
214
- return [] unless parent && grandparent
215
- common_parent_content_ids = tagged_to_same_mainstream_browse_page.map { |item| item["content_id"] }
216
-
217
- @parents_tagged_to_same_mainstream_browse_page ||= related_links.select do |related_item|
218
- next if common_parent_content_ids.include?(related_item["content_id"])
219
- mainstream_browse_pages = related_item.dig("links", "mainstream_browse_pages") || []
220
- parents = mainstream_browse_pages.map { |page| page["links"]["parent"][0] }
221
- content_ids = parents.map { |parent| parent["content_id"] }
222
- content_ids.include?(grandparent["content_id"])
223
- end
224
- end
225
-
226
157
  def related_links
227
158
  link_group("ordered_related_items")
228
159
  end
@@ -24,9 +24,8 @@ module GovukPublishingComponents
24
24
 
25
25
  def related_navigation_links
26
26
  {}.tap do |hash|
27
- @related_navigation.related_navigation.each do |section|
28
- key = section.keys.first
29
- hash[key.to_sym] = section[key] if RELATED_SECTIONS.include?(key)
27
+ @related_navigation.related_navigation.each do |key, items|
28
+ hash[key.to_sym] = items if RELATED_SECTIONS.include?(key)
30
29
  end
31
30
  end
32
31
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '6.5.0'.freeze
2
+ VERSION = '6.6.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.5.0
4
+ version: 6.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-12 00:00:00.000000000 Z
11
+ date: 2018-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -395,6 +395,7 @@ files:
395
395
  - app/views/govuk_publishing_components/components/docs/step_by_step_nav_related.yml
396
396
  - app/views/govuk_publishing_components/components/docs/success_alert.yml
397
397
  - app/views/govuk_publishing_components/components/docs/taxonomy_navigation.yml
398
+ - app/views/govuk_publishing_components/components/related_navigation/_section.html.erb
398
399
  - app/views/layouts/govuk_publishing_components/application.html.erb
399
400
  - config/initializers/assets.rb
400
401
  - config/locales/cy.yml
@@ -415,7 +416,6 @@ files:
415
416
  - lib/govuk_publishing_components/presenters/content_item.rb
416
417
  - lib/govuk_publishing_components/presenters/contextual_navigation.rb
417
418
  - lib/govuk_publishing_components/presenters/curated_taxonomy_sidebar_links.rb
418
- - lib/govuk_publishing_components/presenters/navigation_type.rb
419
419
  - lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb
420
420
  - lib/govuk_publishing_components/presenters/related_navigation_helper.rb
421
421
  - lib/govuk_publishing_components/presenters/rummager_taxonomy_sidebar_links.rb
@@ -444,7 +444,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
444
444
  version: '0'
445
445
  requirements: []
446
446
  rubyforge_project:
447
- rubygems_version: 2.7.3
447
+ rubygems_version: 2.7.6
448
448
  signing_key:
449
449
  specification_version: 4
450
450
  summary: A gem to document components in GOV.UK frontend applications
@@ -1,30 +0,0 @@
1
- module GovukPublishingComponents
2
- module Presenters
3
- # @private
4
- class NavigationType
5
- def initialize(content_item)
6
- @content_item = content_item
7
- end
8
-
9
- def should_present_taxonomy_navigation?
10
- @content_item.dig("document_type") != "travel_advice" &&
11
- !content_is_tagged_to_browse_pages? &&
12
- content_is_tagged_to_a_live_taxon?
13
- end
14
-
15
- private
16
-
17
- def content_is_tagged_to_a_live_taxon?
18
- @content_item.dig("links", "taxons").to_a.any? { |taxon| taxon["phase"] == "live" }
19
- end
20
-
21
- def content_is_tagged_to_browse_pages?
22
- @content_item.dig("links", "mainstream_browse_pages").present?
23
- end
24
-
25
- def content_schema_is_guidance?
26
- GUIDANCE_SCHEMAS.include? @content_item["schema_name"]
27
- end
28
- end
29
- end
30
- end