govuk_publishing_components 21.48.0 → 21.49.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/govuk_publishing_components/components/_contextual_breadcrumbs.html.erb +9 -1
- data/lib/govuk_publishing_components.rb +1 -0
- data/lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb +43 -0
- data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +4 -0
- data/lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb +7 -7
- data/lib/govuk_publishing_components/presenters/page_with_step_by_step_navigation.rb +5 -5
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7256d35290379a3b50da4ec0a841472d56209f7780442eef0f15b8c4ca91a4f4
|
4
|
+
data.tar.gz: a25616924f8557b5530a9db3aa0db62ca6856165b9e74bd323841080dd6bf433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5317e25d449fcdd3c7453ed45bebe434991a4c7f8e1058c5b344830580b8e9146b41dc2ac9d342e458fdd189930bcf3b2ed4848330a308ec6d318cdff0c34d57
|
7
|
+
data.tar.gz: b80b58ec4481c8dd2db13b939461bcfbcaa844f81d4a8f01d3255e991791d81a0dacf554bcbea9226cd6bddd2189af8fb7479407cd4709a9091cc964f4e3b008
|
@@ -4,7 +4,15 @@
|
|
4
4
|
<% collapse_on_mobile ||= true unless local_assigns[:collapse_on_mobile].eql?(false) %>
|
5
5
|
|
6
6
|
<div class='gem-c-contextual-breadcrumbs'>
|
7
|
-
|
7
|
+
|
8
|
+
<% if navigation.priority_taxon %>
|
9
|
+
<%= render 'govuk_publishing_components/components/step_by_step_nav_header',
|
10
|
+
{
|
11
|
+
title: navigation.priority_taxon['title'],
|
12
|
+
path: navigation.priority_taxon['base_path']
|
13
|
+
}
|
14
|
+
%>
|
15
|
+
<% elsif navigation.content_tagged_to_current_step_by_step? %>
|
8
16
|
<%# Rendering step by step nav breadcrumbs because there's 1 step by step %>
|
9
17
|
<%= render 'govuk_publishing_components/components/step_by_step_nav_header',
|
10
18
|
navigation.step_nav_helper.header %>
|
@@ -12,6 +12,7 @@ require "govuk_publishing_components/presenters/related_navigation_helper"
|
|
12
12
|
require "govuk_publishing_components/presenters/step_by_step_nav_helper"
|
13
13
|
require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
|
14
14
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent"
|
15
|
+
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority"
|
15
16
|
require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
|
16
17
|
require "govuk_publishing_components/presenters/checkboxes_helper"
|
17
18
|
require "govuk_publishing_components/presenters/select"
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module GovukPublishingComponents
|
2
|
+
module Presenters
|
3
|
+
class ContentBreadcrumbsBasedOnPriority
|
4
|
+
# keys are labels, values are the content_ids for the matching taxons
|
5
|
+
# Where multiple matching taxons are present, the top most one is the highest priority
|
6
|
+
# and the bottom one the lowest priority
|
7
|
+
PRIORITY_TAXONS = {
|
8
|
+
education_coronavirus: "272308f4-05c8-4d0d-abc7-b7c2e3ccd249",
|
9
|
+
business_coronavirus: "65666cdf-b177-4d79-9687-b9c32805e450",
|
10
|
+
}.freeze
|
11
|
+
|
12
|
+
# Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
|
13
|
+
def self.call(content_item)
|
14
|
+
new(content_item).taxon
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :content_item
|
18
|
+
|
19
|
+
def initialize(content_item)
|
20
|
+
@content_item = content_item
|
21
|
+
end
|
22
|
+
|
23
|
+
def taxon
|
24
|
+
@taxon ||= priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def priority_taxons
|
30
|
+
taxons = content_item.dig("links", "taxons")&.map do |taxon|
|
31
|
+
taxon.dig("links", "parent_taxons")&.select do |parent_taxon|
|
32
|
+
PRIORITY_TAXONS.values.include?(parent_taxon["content_id"])
|
33
|
+
end
|
34
|
+
end
|
35
|
+
return [] unless taxons
|
36
|
+
|
37
|
+
taxons.flatten!
|
38
|
+
taxons.compact!
|
39
|
+
taxons
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -20,6 +20,10 @@ module GovukPublishingComponents
|
|
20
20
|
@taxon_breadcrumbs ||= ContentBreadcrumbsBasedOnTaxons.new(content_item).breadcrumbs
|
21
21
|
end
|
22
22
|
|
23
|
+
def priority_taxon
|
24
|
+
@priority_taxon ||= ContentBreadcrumbsBasedOnPriority.call(content_item)
|
25
|
+
end
|
26
|
+
|
23
27
|
def breadcrumbs
|
24
28
|
if content_tagged_to_a_finder?
|
25
29
|
parent_finder = content_item.dig("links", "finder", 0)
|
data/lib/govuk_publishing_components/presenters/machine_readable/government_service_schema.rb
CHANGED
@@ -29,13 +29,13 @@ module GovukPublishingComponents
|
|
29
29
|
|
30
30
|
{
|
31
31
|
"isRelatedTo" => related_links.each_with_object([]) do |link, items|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
next unless link["schema_name"] == "transaction"
|
33
|
+
|
34
|
+
items << {
|
35
|
+
"@type" => "GovernmentService",
|
36
|
+
"name" => link["title"],
|
37
|
+
"url" => link["web_url"],
|
38
|
+
}
|
39
39
|
end,
|
40
40
|
}
|
41
41
|
end
|
@@ -169,11 +169,11 @@ module GovukPublishingComponents
|
|
169
169
|
next unless content[:contents]
|
170
170
|
|
171
171
|
content[:contents].each do |link|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
172
|
+
next unless link[:href] == current_path
|
173
|
+
|
174
|
+
link[:active] = true
|
175
|
+
step_nav_content[:show_step] = step_index + 1
|
176
|
+
step_nav_content[:highlight_step] = step_index + 1
|
177
177
|
end
|
178
178
|
end
|
179
179
|
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: 21.
|
4
|
+
version: 21.49.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -748,6 +748,7 @@ files:
|
|
748
748
|
- lib/govuk_publishing_components/presenters/button_helper.rb
|
749
749
|
- lib/govuk_publishing_components/presenters/checkboxes_helper.rb
|
750
750
|
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_parent.rb
|
751
|
+
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb
|
751
752
|
- lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb
|
752
753
|
- lib/govuk_publishing_components/presenters/content_item.rb
|
753
754
|
- lib/govuk_publishing_components/presenters/contents_list_helper.rb
|