govuk_publishing_components 9.27.0 → 9.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e6c7609a6180903a56d25047915cb659b1a9e8c80be76d8deb94d89edeaa1d6
4
- data.tar.gz: 1e41eeb83cfdffb791ef9ea2a88f58dd075be99de33635a726352a70f09196d4
3
+ metadata.gz: dd97893a0b544cc658d03a410175d5f5bef9173a23368563ad0b1bfc3a3f1e98
4
+ data.tar.gz: 380f25942322cee9c5efb96fa977faf46ae5597dddf5012333f99a294946df6a
5
5
  SHA512:
6
- metadata.gz: '0530198829ee0f9d826b83b293fb088e11e9b1e3155642927d2bf3d4bcc3f80e1e2ffa86d5987bae0f63e4568bedfef01bef5f20a0d2bd49d889c4f5da85cac1'
7
- data.tar.gz: 57e3bc14dd4358785679bb33bd8472978203092a6ecb7d558f0d3b8e77437f984e915694cd3cd37477dbd070876ca566b8beb14a7f19eff25611a4932fb5574d
6
+ metadata.gz: 97c7bf5aa73ddb895bd8cf6457d5f0f0d18f3ea7aa06f52a9e4d5a2aa51dd3472f8340fd4ebc263976d2d02aae75579d33968288970a167756f8401d1ba7a50b
7
+ data.tar.gz: 32476ad88ae096153c99d1fd6ecb9036d1c69e9bd24b6c888986aa0ff32183d4944ee9ac348ec8400946cb97ccfbcafb1b3e381386f2ce5a227a273658fdb932
@@ -15,6 +15,12 @@ module GovukPublishingComponents
15
15
  end
16
16
  end
17
17
 
18
+ def related_to_step_navs
19
+ @related_to_step_navs ||= parsed_related_to_step_navs.map do |step_nav|
20
+ StepByStepModel.new(step_nav)
21
+ end
22
+ end
23
+
18
24
  def show_sidebar?
19
25
  show_header? && current_step_nav.steps.present?
20
26
  end
@@ -24,11 +30,12 @@ module GovukPublishingComponents
24
30
  end
25
31
 
26
32
  def show_related_links?
27
- step_navs.any? && (step_navs.count < 5 || active_step_by_step?)
33
+ return true if active_step_by_step?
34
+ step_navs.any? && step_navs.count < 5
28
35
  end
29
36
 
30
37
  def show_also_part_of_step_nav?
31
- active_step_by_step? && also_part_of_step_nav.any?
38
+ active_step_by_step? && also_part_of_step_nav.any? && step_navs_combined_list.count < 5
32
39
  end
33
40
 
34
41
  def related_links
@@ -37,7 +44,8 @@ module GovukPublishingComponents
37
44
  end
38
45
 
39
46
  def also_part_of_step_nav
40
- step_by_step_navs = step_navs.delete_if { |step_nav| step_nav.content_id == active_step_by_step.content_id }
47
+ step_navs_list = step_navs_combined_list
48
+ step_by_step_navs = step_navs_list.delete_if { |step_nav| step_nav.content_id == active_step_by_step.content_id }
41
49
  format_related_links(step_by_step_navs)
42
50
  end
43
51
 
@@ -67,7 +75,8 @@ module GovukPublishingComponents
67
75
  end
68
76
 
69
77
  def active_step_by_step
70
- @active_step_navs ||= step_navs.select { |step_nav| step_nav.content_id == active_step_nav_content_id }
78
+ step_navs_list = step_navs_combined_list
79
+ @active_step_navs ||= step_navs_list.select { |step_nav| step_nav.content_id == active_step_nav_content_id }
71
80
  @active_step_navs.first
72
81
  end
73
82
 
@@ -88,10 +97,21 @@ module GovukPublishingComponents
88
97
  @steps ||= step_nav[:steps]
89
98
  end
90
99
 
100
+ def step_navs_combined_list
101
+ step_nav_list = []
102
+ step_nav_list += step_navs if step_navs.any?
103
+ step_nav_list += related_to_step_navs if related_to_step_navs.any?
104
+ step_nav_list
105
+ end
106
+
91
107
  def parsed_step_navs
92
108
  content_item.dig("links", "part_of_step_navs").to_a
93
109
  end
94
110
 
111
+ def parsed_related_to_step_navs
112
+ content_item.dig("links", "related_to_step_navs").to_a
113
+ end
114
+
95
115
  def configure_for_sidebar(step_nav_content)
96
116
  step_nav_content[:steps].each_with_index do |step, step_index|
97
117
  step[:contents].each do |content|
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = '9.27.0'.freeze
2
+ VERSION = '9.28.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.27.0
4
+ version: 9.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev