govuk_publishing_components 29.0.1 → 29.1.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: 3b2249b313207eb5d21c77d4b5daf9ff81a39459ca3ae488aa27385ac3d107ac
4
- data.tar.gz: d484a78ee501972e49e477c386d84e4616b0668f9d865620875ddf687c0c5713
3
+ metadata.gz: b8ea9dce00e2fc90b3a88d941fa237f4d276295be027676233cf31cbf904bec0
4
+ data.tar.gz: c3ff5045ff3c0f0be4df536e1ea165c896d01e1b680c4f98f838bc213f4d3931
5
5
  SHA512:
6
- metadata.gz: d745f36953d411596341155eaf6797db40950023c1bbacf5938b0571e480b3083f6e80453fbf13ed5adf0d8f0c5d13838f33fada99f6287d705efbf9cae17a60
7
- data.tar.gz: b155b56e49062bdae108c6932d7e3c6baccb579a510a4018d5b89f789c9e1218d3e54f594738950bca50824c581c77aa573e59455b5aa2da63c4076eb5f4dced
6
+ metadata.gz: 1fe533fa65e9d6d6e97e94d388e1176031f4bdf9eb896867b7f81ba56deb790fc630383060aab98f3e7f09f5f6b8547db2c27d19519631a97fbdd135f6314759
7
+ data.tar.gz: 3c7659b2fd425a674de931fee53307329f12586aced6775dde5ae21b982661205a1eaab6aacbdf714bbd81e31e7f095184582bf25ca00b323d57410c45d790b4
@@ -12,9 +12,4 @@
12
12
  inverse: inverse,
13
13
  collapse_on_mobile: collapse_on_mobile %>
14
14
  <% end %>
15
- <% if breadcrumb_selector.priority_breadcrumbs %>
16
- <%= render 'govuk_publishing_components/components/step_by_step_nav_header', breadcrumb_selector.priority_breadcrumbs %>
17
- <% meta_tag = GovukPublishingComponents::Presenters::MetaTags.new(content_item, local_assigns, request).brexit_priority_breadcrumb_tag %>
18
- <meta name="<%= meta_tag.keys.first %>" content="<%= meta_tag.values.first %>">
19
- <% end %>
20
15
  </div>
@@ -17,19 +17,8 @@ module GovukPublishingComponents
17
17
  best_match_option[:step_by_step]
18
18
  end
19
19
 
20
- def priority_breadcrumbs
21
- return if hide_priority_breadcrumb?
22
- return parent_item_navigation.priority_breadcrumbs if content_item_navigation.html_publication_with_parent?
23
-
24
- content_item_navigation.priority_breadcrumbs
25
- end
26
-
27
20
  private
28
21
 
29
- def hide_priority_breadcrumb?
30
- content_item_navigation.content_tagged_to_current_step_by_step? && content_item_navigation.tagged_to_brexit?
31
- end
32
-
33
22
  def best_match_option
34
23
  return content_item_options unless content_item_navigation.html_publication_with_parent?
35
24
 
@@ -33,10 +33,6 @@ module GovukPublishingComponents
33
33
  @taxon_breadcrumbs ||= ContentBreadcrumbsBasedOnTaxons.call(content_item)
34
34
  end
35
35
 
36
- def priority_breadcrumbs
37
- @priority_breadcrumbs ||= ContentBreadcrumbsBasedOnPriority.call(content_item, query_parameters)
38
- end
39
-
40
36
  def topic_breadcrumbs
41
37
  @topic_breadcrumbs ||= ContentBreadcrumbsBasedOnTopic.call(content_item)
42
38
  end
@@ -92,22 +88,6 @@ module GovukPublishingComponents
92
88
  content_item.dig("links", "topics").present?
93
89
  end
94
90
 
95
- def tagged_to_brexit?
96
- taxons = content_item.dig("links", "taxons").to_a
97
- brexit_taxon = "d6c2de5d-ef90-45d1-82d4-5f2438369eea"
98
- world_brexit_taxon = "d4c4d91d-fbe7-4eff-bd57-189138c626c9"
99
-
100
- taxons.each do |taxon|
101
- if taxon["content_id"].eql?(brexit_taxon) ||
102
- taxon["content_id"].eql?(world_brexit_taxon) ||
103
- taxon.dig("links", "parent_taxons").to_a.any? { |taxon_item| taxon_item["content_id"].eql?(brexit_taxon) }
104
- return true
105
- end
106
- end
107
-
108
- false
109
- end
110
-
111
91
  def content_tagged_to_current_step_by_step?
112
92
  # TODO: remove indirection here
113
93
  step_nav_helper.show_header?
@@ -20,12 +20,7 @@ module GovukPublishingComponents
20
20
  meta_tags = add_organisation_tags(meta_tags)
21
21
  meta_tags = add_political_tags(meta_tags)
22
22
  meta_tags = add_taxonomy_tags(meta_tags)
23
- meta_tags = add_step_by_step_tags(meta_tags)
24
- add_brexit_tags("govuk:brexit-audience", meta_tags)
25
- end
26
-
27
- def brexit_priority_breadcrumb_tag
28
- add_brexit_tags("govuk:brexit-superbreadcrumb")
23
+ add_step_by_step_tags(meta_tags)
29
24
  end
30
25
 
31
26
  private
@@ -116,37 +111,6 @@ module GovukPublishingComponents
116
111
  meta_tags
117
112
  end
118
113
 
119
- def add_brexit_tags(tag_key, meta_tags = {})
120
- links = content_item[:links]
121
- taxons = links[:taxons] unless links.nil?
122
-
123
- return meta_tags if taxons.blank?
124
- return meta_tags unless tagged_to_priority_taxon?
125
-
126
- taxon =
127
- tag_key == "govuk:brexit-audience" ? priority_brexit_taxon : priority_taxon
128
-
129
- brexit_audience = priority_taxon_helper.brexit_audience(taxon)
130
- meta_tags[tag_key] = brexit_audience if brexit_audience.present?
131
- meta_tags
132
- end
133
-
134
- def tagged_to_priority_taxon?
135
- priority_taxon_helper.priority_taxon.present?
136
- end
137
-
138
- def priority_taxon_helper
139
- @priority_taxon_helper ||= ContentBreadcrumbsBasedOnPriority.new(content_item.deep_stringify_keys, request.query_parameters)
140
- end
141
-
142
- def priority_taxon
143
- priority_taxon_helper.priority_taxon
144
- end
145
-
146
- def priority_brexit_taxon
147
- priority_taxon_helper.priority_brexit_taxon
148
- end
149
-
150
114
  def has_content_history?
151
115
  (content_item[:public_updated_at] && details[:first_public_at] && content_item[:public_updated_at] != details[:first_public_at]) ||
152
116
  (details[:change_history] && details[:change_history].size > 1)
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "29.0.1".freeze
2
+ VERSION = "29.1.0".freeze
3
3
  end
@@ -17,7 +17,6 @@ require "govuk_publishing_components/presenters/step_by_step_nav_helper"
17
17
  require "govuk_publishing_components/presenters/page_with_step_by_step_navigation"
18
18
  require "govuk_publishing_components/presenters/public_layout_helper"
19
19
  require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors"
20
- require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority"
21
20
  require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons"
22
21
  require "govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic"
23
22
  require "govuk_publishing_components/presenters/checkboxes_helper"
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: 29.0.1
4
+ version: 29.1.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: 2022-03-25 00:00:00.000000000 Z
11
+ date: 2022-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config
@@ -907,7 +907,6 @@ files:
907
907
  - lib/govuk_publishing_components/presenters/button_helper.rb
908
908
  - lib/govuk_publishing_components/presenters/checkboxes_helper.rb
909
909
  - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_ancestors.rb
910
- - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_priority.rb
911
910
  - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_taxons.rb
912
911
  - lib/govuk_publishing_components/presenters/content_breadcrumbs_based_on_topic.rb
913
912
  - lib/govuk_publishing_components/presenters/content_item.rb
@@ -1,118 +0,0 @@
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
- brexit_business: "634fd193-8039-4a70-a059-919c34ff4bfc",
9
- brexit_individuals: "614b2e65-56ac-4f8d-bb9c-d1a14167ba25",
10
- brexit_taxon: "d6c2de5d-ef90-45d1-82d4-5f2438369eea",
11
- }.freeze
12
-
13
- # Returns the highest priority taxon that has a content_id matching those in PRIORITY_TAXONS
14
- def self.call(content_item, query_parameters = nil)
15
- new(content_item, query_parameters).breadcrumbs
16
- end
17
-
18
- attr_reader :content_item, :query_parameters
19
-
20
- def initialize(content_item, query_parameters = nil)
21
- @content_item = content_item
22
- @query_parameters = query_parameters
23
- end
24
-
25
- def priority_taxon
26
- @priority_taxon ||= begin
27
- default_taxon = priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
28
- preferred_taxon || default_taxon
29
- end
30
- end
31
-
32
- def priority_brexit_taxon
33
- if tagged_to_both_brexit_child_taxons?
34
- priority_taxons.find { |t| t["content_id"] == PRIORITY_TAXONS[:brexit_taxon] }
35
- else
36
- priority_taxons.min_by { |t| PRIORITY_TAXONS.values.index(t["content_id"]) }
37
- end
38
- end
39
-
40
- def breadcrumbs
41
- priority_taxon && {
42
- title: priority_taxon["title"],
43
- path: breadcrumb_path,
44
- tracking_category: "breadcrumbClicked",
45
- tracking_action: tracking_action,
46
- tracking_label: content_item["base_path"],
47
- tracking_dimension_enabled: false,
48
- }
49
- end
50
-
51
- def brexit_audience(taxon)
52
- return nil unless taxon
53
-
54
- {
55
- PRIORITY_TAXONS[:brexit_business] => "Brexitbusiness",
56
- PRIORITY_TAXONS[:brexit_individuals] => "Brexitcitizen",
57
- PRIORITY_TAXONS[:brexit_taxon] => "Brexitbusinessandcitizen",
58
- }[taxon["content_id"]]
59
- end
60
-
61
- private
62
-
63
- def preferred_taxon
64
- if preferred_priority_taxon
65
- priority_taxons.find { |t| t["content_id"] == preferred_priority_taxon }
66
- elsif tagged_to_both_brexit_child_taxons?
67
- priority_taxons.find { |t| t["content_id"] == PRIORITY_TAXONS[:brexit_taxon] }
68
- end
69
- end
70
-
71
- def priority_taxons
72
- return [] unless content_item["links"].is_a?(Hash)
73
-
74
- taxons = content_item.dig("links", "taxons")
75
- taxon_tree(taxons).select do |taxon|
76
- priority_taxon?(taxon)
77
- end
78
- end
79
-
80
- def taxon_tree(taxons)
81
- return [] if taxons.blank?
82
-
83
- taxons + taxons.flat_map { |taxon| taxon_tree(taxon.dig("links", "parent_taxons")) }
84
- end
85
-
86
- def priority_taxon?(taxon)
87
- PRIORITY_TAXONS.values.include?(taxon["content_id"])
88
- end
89
-
90
- def brexit_child_taxon?(taxon)
91
- brexit_child_taxons.include?(taxon["content_id"])
92
- end
93
-
94
- def brexit_child_taxons
95
- [PRIORITY_TAXONS[:brexit_business], PRIORITY_TAXONS[:brexit_individuals]]
96
- end
97
-
98
- def preferred_priority_taxon
99
- query_parameters["priority-taxon"] if query_parameters
100
- end
101
-
102
- def tracking_action
103
- action = %w[superBreadcrumb]
104
- action << brexit_audience(priority_taxon)
105
- action.compact.join(" ")
106
- end
107
-
108
- def tagged_to_both_brexit_child_taxons?
109
- t = priority_taxons.select { |taxon| brexit_child_taxon?(taxon) }
110
- t.uniq.count > 1
111
- end
112
-
113
- def breadcrumb_path
114
- priority_taxon.dig("details", "url_override").present? ? priority_taxon.dig("details", "url_override") : priority_taxon["base_path"]
115
- end
116
- end
117
- end
118
- end