govuk_publishing_components 21.55.1 → 21.56.1
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 +4 -4
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +5 -4
- data/app/assets/stylesheets/govuk_publishing_components/component_support.scss +1 -0
- data/app/assets/stylesheets/govuk_publishing_components/components/_feedback.scss +1 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +18 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/helpers/_link.scss +17 -0
- data/app/controllers/govuk_publishing_components/component_guide_controller.rb +26 -16
- data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +11 -7
- data/app/views/govuk_publishing_components/components/_summary_list.html.erb +34 -14
- data/app/views/govuk_publishing_components/components/docs/summary_list.yml +27 -0
- data/config/locales/en.yml +3 -0
- data/lib/govuk_publishing_components.rb +2 -1
- data/lib/govuk_publishing_components/presenters/breadcrumb_selector.rb +52 -44
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb +41 -0
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +1 -0
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb +4 -0
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb +38 -0
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +15 -4
- data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +3 -1
- data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +18 -17
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/axe-core/CHANGELOG.md +11 -0
- data/node_modules/axe-core/axe.js +36 -9
- data/node_modules/axe-core/axe.min.js +2 -2
- data/node_modules/axe-core/bower.json +1 -1
- data/node_modules/axe-core/lib/checks/color/color-contrast.js +2 -2
- data/node_modules/axe-core/lib/checks/lists/listitem.js +1 -1
- data/node_modules/axe-core/lib/checks/mobile/meta-viewport-scale.js +3 -0
- data/node_modules/axe-core/lib/commons/dom/is-visible.js +37 -19
- data/node_modules/axe-core/lib/core/public/configure.js +26 -0
- data/node_modules/axe-core/lib/rules/aria-input-field-name.json +1 -1
- data/node_modules/axe-core/package.json +12 -12
- data/node_modules/axe-core/sri-history.json +4 -0
- metadata +5 -3
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent.rb +0 -39
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ae35a18ee87f9f8bdbc0b7f05b1874d04f3bcfbebed8eb0fd21dfb178bf1118
|
|
4
|
+
data.tar.gz: e83b74f0187e3db2687dea59f3dc1f482b3400a7fe24f95d1ba5cb9b1377a94e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 485ae5bca952be5d4bd237148436f7c165cf91aadafdc433cf1dec9a899cbcff4f78c9e9ede0509ffc79511902fcdeeff699ed73e918f2cbcbf08182e8d8da42
|
|
7
|
+
data.tar.gz: fde1485cf2b9b1849993aa71fee949f39c3f4d08c996c1d9a61de520f3c44d0c25d3fd047d176032fd0c4e7c4862a0b4fe00b926b43e5898424c3e459355ada3
|
data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js
CHANGED
|
@@ -109,6 +109,8 @@
|
|
|
109
109
|
event.target.f.title = videoTitle + ' (video)'
|
|
110
110
|
},
|
|
111
111
|
onStateChange: function (event) {
|
|
112
|
+
var eventData = event.data
|
|
113
|
+
var eventTarget = event.target
|
|
112
114
|
var states = {
|
|
113
115
|
"-1": "VideoUnstarted",
|
|
114
116
|
"0": "VideoEnded",
|
|
@@ -117,14 +119,13 @@
|
|
|
117
119
|
"3": "VideoBuffering",
|
|
118
120
|
"5": "VideoCued"
|
|
119
121
|
}
|
|
120
|
-
|
|
121
|
-
if (states[event.data] && options.tracking && options.tracking.hasTracking
|
|
122
|
+
if (states[eventData] && options.tracking && options.tracking.hasTracking
|
|
122
123
|
&& window.GOVUK.analytics && window.GOVUK.analytics.trackEvent)
|
|
123
124
|
{
|
|
124
125
|
var tracking = {
|
|
125
126
|
category: options.tracking.category,
|
|
126
|
-
action: states[
|
|
127
|
-
label: { transport: 'beacon', label:
|
|
127
|
+
action: states[eventData],
|
|
128
|
+
label: { transport: 'beacon', label: eventTarget.getVideoData && eventTarget.getVideoData().title }
|
|
128
129
|
}
|
|
129
130
|
|
|
130
131
|
window.GOVUK.analytics.trackEvent(tracking.category, tracking.action, tracking.label)
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
@import "govuk_publishing_components/components/helpers/variables";
|
|
10
10
|
@import "govuk_publishing_components/components/helpers/brand-colours";
|
|
11
|
+
@import "govuk_publishing_components/components/helpers/link";
|
|
11
12
|
@import "govuk_publishing_components/components/mixins/govuk-template-link-focus-override";
|
|
12
13
|
@import "govuk_publishing_components/components/mixins/media-down";
|
|
13
14
|
@import "govuk_publishing_components/components/mixins/margins";
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
.gem-c-feedback {
|
|
2
2
|
background: govuk-colour("white");
|
|
3
|
-
margin: govuk-spacing(6)
|
|
4
|
-
max-width: $govuk-page-width;
|
|
5
|
-
position: relative;
|
|
3
|
+
margin-top: govuk-spacing(6);
|
|
6
4
|
|
|
7
5
|
@include govuk-media-query($from: tablet) {
|
|
8
6
|
margin-top: govuk-spacing(9);
|
|
@@ -182,7 +180,6 @@
|
|
|
182
180
|
}
|
|
183
181
|
|
|
184
182
|
.gem-c-feedback__form {
|
|
185
|
-
margin: govuk-spacing(3) govuk-spacing(2) 0 govuk-spacing(2);
|
|
186
183
|
padding: govuk-spacing(3) 0;
|
|
187
184
|
border-top: govuk-spacing(2) solid govuk-colour("blue");
|
|
188
185
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
@import "govuk/components/summary-list/summary-list";
|
|
2
2
|
|
|
3
3
|
.gem-c-summary-list {
|
|
4
|
-
position: relative;
|
|
5
4
|
border-bottom: 1px solid $govuk-border-colour;
|
|
6
5
|
|
|
7
6
|
@include govuk-font(19);
|
|
@@ -14,12 +13,26 @@
|
|
|
14
13
|
&:nth-last-of-type(1) {
|
|
15
14
|
border-bottom: 0;
|
|
16
15
|
}
|
|
16
|
+
|
|
17
|
+
.govuk-summary-list {
|
|
18
|
+
clear: both;
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
.gem-c-summary-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
.gem-c-summary-list__group-title {
|
|
23
|
+
@include govuk-media-query($from: tablet) {
|
|
24
|
+
display: inline-block;
|
|
25
|
+
margin-right: govuk-spacing(3);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.gem-c-summary-list__group-actions-list {
|
|
30
|
+
margin-bottom: govuk-spacing(3);
|
|
31
|
+
|
|
32
|
+
@include govuk-media-query($from: tablet) {
|
|
33
|
+
float: right;
|
|
34
|
+
width: auto;
|
|
35
|
+
}
|
|
23
36
|
}
|
|
24
37
|
|
|
25
38
|
.gem-c-summary__block {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
.gem-link--destructive {
|
|
2
|
+
@include govuk-font(19);
|
|
3
|
+
|
|
4
|
+
&:link {
|
|
5
|
+
color: $govuk-error-colour;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&:visited,
|
|
9
|
+
&:hover,
|
|
10
|
+
&:active {
|
|
11
|
+
color: darken($govuk-error-colour, 5%);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&:focus {
|
|
15
|
+
color: $govuk-focus-text-colour;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -2,6 +2,8 @@ module GovukPublishingComponents
|
|
|
2
2
|
class ComponentGuideController < GovukPublishingComponents::ApplicationController
|
|
3
3
|
append_view_path File.join(Rails.root, "app", "views", GovukPublishingComponents::Config.component_directory_name)
|
|
4
4
|
|
|
5
|
+
MATCH_COMPONENTS = /(?<=govuk_publishing_components\/components\/)[\/a-zA-Z_-]+(?=['"])/.freeze
|
|
6
|
+
|
|
5
7
|
def index
|
|
6
8
|
@application_path = Rails.root
|
|
7
9
|
@component_gem_path = Gem.loaded_specs["govuk_publishing_components"].full_gem_path
|
|
@@ -86,24 +88,30 @@ module GovukPublishingComponents
|
|
|
86
88
|
|
|
87
89
|
files.each do |file|
|
|
88
90
|
data = File.read(file)
|
|
89
|
-
matches << data.scan(
|
|
91
|
+
matches << data.scan(MATCH_COMPONENTS)
|
|
90
92
|
end
|
|
91
93
|
|
|
92
|
-
matches.flatten.uniq.map(&:to_s).sort
|
|
94
|
+
matches.flatten.uniq.map(&:to_s).sort
|
|
93
95
|
end
|
|
94
96
|
|
|
95
|
-
def find_all_partials_in(
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
def find_all_partials_in(templates)
|
|
98
|
+
components = [templates]
|
|
99
|
+
|
|
100
|
+
templates.each do |template|
|
|
101
|
+
partials_found = true
|
|
102
|
+
components_to_search = [template]
|
|
103
|
+
components_found = []
|
|
98
104
|
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
while partials_found
|
|
106
|
+
extra_components = find_partials_in(components_to_search)
|
|
101
107
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
if extra_components.any?
|
|
109
|
+
components_found << extra_components
|
|
110
|
+
components_to_search = extra_components
|
|
111
|
+
else
|
|
112
|
+
partials_found = false
|
|
113
|
+
components << components_found.uniq.sort if components_found.any?
|
|
114
|
+
end
|
|
107
115
|
end
|
|
108
116
|
end
|
|
109
117
|
|
|
@@ -113,8 +121,7 @@ module GovukPublishingComponents
|
|
|
113
121
|
def find_partials_in(components)
|
|
114
122
|
extra_components = []
|
|
115
123
|
components.each do |component|
|
|
116
|
-
|
|
117
|
-
extra_components << components_in_component
|
|
124
|
+
extra_components << components_within_component(component)
|
|
118
125
|
end
|
|
119
126
|
|
|
120
127
|
extra_components.flatten.uniq.sort
|
|
@@ -132,9 +139,12 @@ module GovukPublishingComponents
|
|
|
132
139
|
def components_within_component(component)
|
|
133
140
|
filename = @component_gem_path + "/app/views/govuk_publishing_components/components/#{component}.html.erb"
|
|
134
141
|
filename = filename.sub(/.*\K\//, "/_") # files begin with _ but the method may have been passed 'filename' or 'dir/partial'
|
|
142
|
+
|
|
143
|
+
return [] unless File.file?(filename)
|
|
144
|
+
|
|
135
145
|
data = File.read(filename)
|
|
136
|
-
match = data.scan(
|
|
137
|
-
match.flatten.uniq.map(&:to_s).sort
|
|
146
|
+
match = data.scan(MATCH_COMPONENTS)
|
|
147
|
+
match.flatten.uniq.map(&:to_s).sort
|
|
138
148
|
end
|
|
139
149
|
|
|
140
150
|
def index_breadcrumb
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
<% prioritise_taxon_breadcrumbs ||= false %>
|
|
2
|
-
<% breadcrumb_selector = GovukPublishingComponents::Presenters::BreadcrumbSelector.
|
|
2
|
+
<% breadcrumb_selector = GovukPublishingComponents::Presenters::BreadcrumbSelector.new(content_item, request, prioritise_taxon_breadcrumbs) %>
|
|
3
3
|
<% inverse ||= false %>
|
|
4
4
|
<% collapse_on_mobile ||= true unless local_assigns[:collapse_on_mobile].eql?(false) %>
|
|
5
5
|
|
|
6
|
-
<div class=
|
|
7
|
-
<% if breadcrumb_selector
|
|
8
|
-
<%= render 'govuk_publishing_components/components/step_by_step_nav_header',
|
|
9
|
-
|
|
10
|
-
<% elsif breadcrumb_selector[:breadcrumbs] %>
|
|
6
|
+
<div class="gem-c-contextual-breadcrumbs">
|
|
7
|
+
<% if breadcrumb_selector.step_by_step %>
|
|
8
|
+
<%= render 'govuk_publishing_components/components/step_by_step_nav_header', breadcrumb_selector.breadcrumbs %>
|
|
9
|
+
<% elsif breadcrumb_selector.breadcrumbs %>
|
|
11
10
|
<%= render 'govuk_publishing_components/components/breadcrumbs',
|
|
12
|
-
breadcrumbs: breadcrumb_selector
|
|
11
|
+
breadcrumbs: breadcrumb_selector.breadcrumbs,
|
|
13
12
|
inverse: inverse,
|
|
14
13
|
collapse_on_mobile: collapse_on_mobile %>
|
|
15
14
|
<% end %>
|
|
15
|
+
|
|
16
|
+
<%= render(
|
|
17
|
+
'govuk_publishing_components/components/step_by_step_nav_header', breadcrumb_selector.priority_breadcrumbs
|
|
18
|
+
) if breadcrumb_selector.priority_breadcrumbs
|
|
19
|
+
%>
|
|
16
20
|
</div>
|
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
<%
|
|
2
|
+
local_assigns[:heading_level] ||= 3
|
|
3
|
+
heading_size = 'm' unless ['s', 'm', 'l', 'xl'].include?(heading_size)
|
|
4
|
+
shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns)
|
|
5
|
+
|
|
2
6
|
id ||= nil
|
|
3
7
|
title ||= nil
|
|
4
8
|
borderless ||= false
|
|
5
9
|
edit ||= {}
|
|
10
|
+
delete ||= {}
|
|
6
11
|
items ||= []
|
|
7
12
|
block ||= yield
|
|
8
13
|
%>
|
|
9
14
|
<% if title || items.any? %>
|
|
10
15
|
<%= tag.div class: "gem-c-summary-list #{"govuk-summary-list--no-border" if borderless}", id: id do %>
|
|
11
16
|
<% if title %>
|
|
12
|
-
<%=
|
|
13
|
-
<% if edit.any? %>
|
|
14
|
-
<%= tag.ul class: "govuk-summary-list__actions-list" do %>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
<%= content_tag(shared_helper.get_heading_level, title, class: "govuk-heading-#{heading_size} gem-c-summary-list__group-title") %>
|
|
18
|
+
<% if edit.any? || delete.any? %>
|
|
19
|
+
<%= tag.ul class: "govuk-summary-list__actions-list gem-c-summary-list__group-actions-list" do %>
|
|
20
|
+
<%- if edit.any? %>
|
|
21
|
+
<% edit_section_link_text = edit[:link_text] || t("components.summary_list.edit") %>
|
|
22
|
+
<%= tag.li class: "govuk-summary-list__actions-list-item" do -%>
|
|
23
|
+
<%= link_to edit.fetch(:href),
|
|
24
|
+
class: "govuk-link",
|
|
25
|
+
title: "#{edit_section_link_text} #{title}",
|
|
26
|
+
data: edit.fetch(:data_attributes, {}) do %>
|
|
27
|
+
<%= edit_section_link_text %><%= tag.span " #{title}", class: "govuk-visually-hidden" -%>
|
|
28
|
+
<% end %>
|
|
29
|
+
<% end %>
|
|
30
|
+
<% end %>
|
|
31
|
+
<% if delete.any? %>
|
|
32
|
+
<% delete_section_link_text = delete[:link_text] || t("components.summary_list.delete") %>
|
|
33
|
+
<%= tag.li class: "govuk-summary-list__actions-list-item" do -%>
|
|
34
|
+
<%= link_to delete.fetch(:href),
|
|
35
|
+
class: "govuk-link gem-link--destructive",
|
|
36
|
+
title: "#{delete_section_link_text} #{title}",
|
|
37
|
+
data: delete.fetch(:data_attributes, {}) do %>
|
|
38
|
+
<%= delete_section_link_text %><%= tag.span " #{title}", class: "govuk-visually-hidden" -%>
|
|
39
|
+
<% end %>
|
|
21
40
|
<% end %>
|
|
22
41
|
<% end %>
|
|
23
42
|
<% end %>
|
|
@@ -37,22 +56,23 @@
|
|
|
37
56
|
<%= tag.ul class: "govuk-summary-list__actions-list" do %>
|
|
38
57
|
<% if item.fetch(:edit, {}).any? %>
|
|
39
58
|
<%= tag.li class: "govuk-summary-list__actions-list-item" do %>
|
|
40
|
-
<% edit_link_text = item[:edit][:link_text] || "
|
|
59
|
+
<% edit_link_text = item[:edit][:link_text] || t("components.summary_list.edit") %>
|
|
41
60
|
<%= link_to item[:edit].fetch(:href),
|
|
42
61
|
class: "govuk-link",
|
|
43
62
|
title: "#{edit_link_text} #{item[:field]}",
|
|
44
63
|
data: item[:edit].fetch(:data_attributes, {}) do %>
|
|
45
|
-
<%= edit_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden"
|
|
64
|
+
<%= edit_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" -%>
|
|
65
|
+
<% end %>
|
|
46
66
|
<% end %>
|
|
47
67
|
<% end %>
|
|
48
68
|
<% if item.fetch(:delete, {}).any? %>
|
|
49
69
|
<%= tag.li class: "govuk-summary-list__actions-list-item" do %>
|
|
50
|
-
<% delete_link_text = item[:delete][:link_text] || "
|
|
70
|
+
<% delete_link_text = item[:delete][:link_text] || t("components.summary_list.delete") %>
|
|
51
71
|
<%= link_to item[:delete].fetch(:href),
|
|
52
|
-
class: "govuk-link",
|
|
72
|
+
class: "govuk-link gem-link--destructive",
|
|
53
73
|
title: "#{delete_link_text} #{item[:field]}",
|
|
54
74
|
data: item[:delete].fetch(:data_attributes, {}) do %>
|
|
55
|
-
<%= delete_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden"
|
|
75
|
+
<%= delete_link_text %><%= tag.span " #{item[:field]}", class: "govuk-visually-hidden" -%>
|
|
56
76
|
<% end %>
|
|
57
77
|
<% end %>
|
|
58
78
|
<% end %>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
name: Summary list
|
|
2
2
|
description: Use the summary list to summarise information, for example, a user’s responses at the end of a form.
|
|
3
|
+
body: This component extends the [Summary list component in the Design System](https://design-system.service.gov.uk/components/summary-list/) allowing the rendering of multiple groups of lists, and actions at the group level.
|
|
3
4
|
accessibility_criteria: |
|
|
4
5
|
Action links in the component must:
|
|
5
6
|
|
|
@@ -41,6 +42,32 @@ examples:
|
|
|
41
42
|
data_attributes:
|
|
42
43
|
gtm: "edit-title-summary-body"
|
|
43
44
|
|
|
45
|
+
with_delete_on_section:
|
|
46
|
+
data:
|
|
47
|
+
<<: *default-example-data
|
|
48
|
+
delete:
|
|
49
|
+
href: "delete-title-summary-body"
|
|
50
|
+
data_attributes:
|
|
51
|
+
gtm: "delete-title-summary-body"
|
|
52
|
+
|
|
53
|
+
with_edit_and_delete_on_section:
|
|
54
|
+
data:
|
|
55
|
+
<<: *default-example-data
|
|
56
|
+
edit:
|
|
57
|
+
href: "edit-title-summary-body"
|
|
58
|
+
data_attributes:
|
|
59
|
+
gtm: "edit-title-summary-body"
|
|
60
|
+
delete:
|
|
61
|
+
href: "delete-title-summary-body"
|
|
62
|
+
data_attributes:
|
|
63
|
+
gtm: "delete-title-summary-body"
|
|
64
|
+
|
|
65
|
+
with_custom_section_heading:
|
|
66
|
+
data:
|
|
67
|
+
<<: *default-example-data
|
|
68
|
+
heading_level: 2
|
|
69
|
+
heading_size: l
|
|
70
|
+
|
|
44
71
|
with_custom_link_on_section:
|
|
45
72
|
description: |
|
|
46
73
|
Take care that the provided `link_text` still makes sense to screen readers when combined with the title.
|
data/config/locales/en.yml
CHANGED
|
@@ -12,9 +12,10 @@ require "govuk_publishing_components/presenters/contextual_navigation"
|
|
|
12
12
|
require "govuk_publishing_components/presenters/related_navigation_helper"
|
|
13
13
|
require "govuk_publishing_components/presenters/step_by_step_nav_helper"
|
|
14
14
|
require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
|
|
15
|
-
require "govuk_publishing_components/presenters/
|
|
15
|
+
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors"
|
|
16
16
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority"
|
|
17
17
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
|
|
18
|
+
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic"
|
|
18
19
|
require "govuk_publishing_components/presenters/checkboxes_helper"
|
|
19
20
|
require "govuk_publishing_components/presenters/select"
|
|
20
21
|
require "govuk_publishing_components/presenters/meta_tags"
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
module GovukPublishingComponents
|
|
2
2
|
module Presenters
|
|
3
3
|
class BreadcrumbSelector
|
|
4
|
-
def self.call(*args)
|
|
5
|
-
new(*args).output
|
|
6
|
-
end
|
|
7
|
-
|
|
8
4
|
attr_reader :content_item, :request, :prioritise_taxon_breadcrumbs
|
|
9
5
|
|
|
10
6
|
def initialize(content_item, request, prioritise_taxon_breadcrumbs)
|
|
@@ -13,66 +9,42 @@ module GovukPublishingComponents
|
|
|
13
9
|
@prioritise_taxon_breadcrumbs = prioritise_taxon_breadcrumbs
|
|
14
10
|
end
|
|
15
11
|
|
|
16
|
-
def
|
|
17
|
-
|
|
12
|
+
def breadcrumbs
|
|
13
|
+
best_match_option[:breadcrumbs]
|
|
18
14
|
end
|
|
19
15
|
|
|
20
|
-
def
|
|
21
|
-
|
|
16
|
+
def step_by_step
|
|
17
|
+
best_match_option[:step_by_step]
|
|
22
18
|
end
|
|
23
19
|
|
|
24
|
-
def
|
|
25
|
-
|
|
26
|
-
rescue GdsApi::ContentStore::ItemNotFound
|
|
27
|
-
# Do nothing
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def parent_item_options
|
|
31
|
-
@parent_item_options ||= options(parent_item_navigation)
|
|
32
|
-
end
|
|
20
|
+
def priority_breadcrumbs
|
|
21
|
+
return parent_item_navigation.priority_breadcrumbs if content_item_navigation.html_publication_with_parent?
|
|
33
22
|
|
|
34
|
-
|
|
35
|
-
@content_item_options ||= options(content_item_navigation)
|
|
23
|
+
content_item_navigation.priority_breadcrumbs
|
|
36
24
|
end
|
|
37
25
|
|
|
38
|
-
|
|
39
|
-
breadcrumbs = [parent_item_options[:breadcrumbs]].flatten # to ensure breadcrumbs always an array
|
|
40
|
-
breadcrumbs.last[:is_page_parent] = false
|
|
41
|
-
breadcrumbs << {
|
|
42
|
-
title: parent_item["title"],
|
|
43
|
-
url: parent_item["base_path"],
|
|
44
|
-
is_page_parent: true,
|
|
45
|
-
}
|
|
46
|
-
end
|
|
26
|
+
private
|
|
47
27
|
|
|
48
|
-
def
|
|
28
|
+
def best_match_option
|
|
49
29
|
return content_item_options unless content_item_navigation.html_publication_with_parent?
|
|
50
|
-
return parent_item_options if parent_item_navigation.priority_breadcrumbs
|
|
51
|
-
|
|
52
|
-
step_by_step_header = parent_item_options[:step_by_step]
|
|
53
30
|
|
|
54
31
|
{
|
|
55
|
-
step_by_step:
|
|
56
|
-
breadcrumbs:
|
|
32
|
+
step_by_step: parent_is_step_by_step?,
|
|
33
|
+
breadcrumbs: parent_is_step_by_step? ? parent_breadcrumbs.first : parent_breadcrumbs,
|
|
57
34
|
}
|
|
58
35
|
end
|
|
59
36
|
|
|
60
37
|
def options(navigation)
|
|
61
|
-
if navigation.
|
|
38
|
+
if navigation.content_tagged_to_a_finder?
|
|
62
39
|
{
|
|
63
|
-
step_by_step:
|
|
64
|
-
breadcrumbs: navigation.
|
|
40
|
+
step_by_step: false,
|
|
41
|
+
breadcrumbs: navigation.finder_breadcrumbs,
|
|
65
42
|
}
|
|
66
43
|
elsif navigation.content_tagged_to_current_step_by_step?
|
|
67
44
|
{
|
|
68
45
|
step_by_step: true,
|
|
69
46
|
breadcrumbs: navigation.step_nav_helper.header,
|
|
70
47
|
}
|
|
71
|
-
elsif navigation.content_tagged_to_a_finder?
|
|
72
|
-
{
|
|
73
|
-
step_by_step: false,
|
|
74
|
-
breadcrumbs: navigation.breadcrumbs,
|
|
75
|
-
}
|
|
76
48
|
elsif navigation.content_is_tagged_to_a_live_taxon? && prioritise_taxon_breadcrumbs
|
|
77
49
|
{
|
|
78
50
|
step_by_step: false,
|
|
@@ -83,10 +55,10 @@ module GovukPublishingComponents
|
|
|
83
55
|
step_by_step: false,
|
|
84
56
|
breadcrumbs: navigation.breadcrumbs,
|
|
85
57
|
}
|
|
86
|
-
elsif navigation.
|
|
58
|
+
elsif navigation.content_has_a_topic?
|
|
87
59
|
{
|
|
88
60
|
step_by_step: false,
|
|
89
|
-
breadcrumbs: navigation.
|
|
61
|
+
breadcrumbs: navigation.topic_breadcrumbs,
|
|
90
62
|
}
|
|
91
63
|
elsif navigation.use_taxon_breadcrumbs?
|
|
92
64
|
{
|
|
@@ -102,6 +74,42 @@ module GovukPublishingComponents
|
|
|
102
74
|
{}
|
|
103
75
|
end
|
|
104
76
|
end
|
|
77
|
+
|
|
78
|
+
def content_item_navigation
|
|
79
|
+
@content_item_navigation ||= ContextualNavigation.new(content_item, request)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def parent_item_navigation
|
|
83
|
+
@parent_item_navigation ||= ContextualNavigation.new(parent_item, request)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def parent_item
|
|
87
|
+
@parent_item ||= Services.content_store.content_item(content_item_navigation.parent_api_path)
|
|
88
|
+
rescue GdsApi::ContentStore::ItemNotFound
|
|
89
|
+
# Do nothing
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def parent_item_options
|
|
93
|
+
@parent_item_options ||= options(parent_item_navigation)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def content_item_options
|
|
97
|
+
@content_item_options ||= options(content_item_navigation)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def parent_breadcrumbs
|
|
101
|
+
breadcrumbs = [parent_item_options[:breadcrumbs]].flatten # to ensure breadcrumbs always an array
|
|
102
|
+
breadcrumbs.last[:is_page_parent] = false
|
|
103
|
+
breadcrumbs << {
|
|
104
|
+
title: parent_item["title"],
|
|
105
|
+
url: parent_item["base_path"],
|
|
106
|
+
is_page_parent: true,
|
|
107
|
+
}
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
def parent_is_step_by_step?
|
|
111
|
+
parent_item_options[:step_by_step]
|
|
112
|
+
end
|
|
105
113
|
end
|
|
106
114
|
end
|
|
107
115
|
end
|