govuk_publishing_components 34.11.0 → 34.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/analytics-ga4/ga4-form-tracker.js +8 -2
- data/app/models/govuk_publishing_components/audit_components.rb +55 -1
- data/app/views/govuk_publishing_components/audit/_components.html.erb +46 -1
- data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +3 -0
- data/app/views/govuk_publishing_components/components/docs/related_navigation.yml +20 -0
- data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +15 -9
- data/config/locales/en.yml +1 -1
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd36433fa99aed8ea4144f791e7e78f72ae786e1148b7826758d65e271f98e5e
|
4
|
+
data.tar.gz: ce9e9975edbf99d74771088e9dadcd610ffacc345358afc25e85640a110d4035
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb41c9f45ecf8ae1e4f12d80f871392b08e97bf8c7074e22a2a1d265cb67d317bc1350cb1eb855270e1a48945c1e0a0b156e8e0c50eed2ed17998cb921ad640
|
7
|
+
data.tar.gz: bce8a83d09679a2e20a5bc5e05f112a207e455ed8eae2b726ad670c19c84348868a918ec82abd30119196332b6dc5a3f5443697622008eadee028f9d2ca2f974
|
@@ -7,6 +7,7 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
7
7
|
function Ga4FormTracker (module) {
|
8
8
|
this.module = module
|
9
9
|
this.trackingTrigger = 'data-ga4-form' // elements with this attribute get tracked
|
10
|
+
this.includeTextInputValues = this.module.hasAttribute('data-ga4-form-include-text')
|
10
11
|
}
|
11
12
|
|
12
13
|
Ga4FormTracker.prototype.init = function () {
|
@@ -82,8 +83,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {};
|
|
82
83
|
input.answer = labelText
|
83
84
|
} else if (inputNodename === 'SELECT' && elem.options[elem.selectedIndex].value) {
|
84
85
|
input.answer = elem.options[elem.selectedIndex].text
|
85
|
-
} else if (inputType === 'text' && elem.value) {
|
86
|
-
|
86
|
+
} else if ((inputType === 'text' || inputType === 'search') && elem.value) {
|
87
|
+
if (this.includeTextInputValues) {
|
88
|
+
var PIIRemover = new window.GOVUK.analyticsGa4.PIIRemover()
|
89
|
+
input.answer = PIIRemover.stripPIIWithOverride(elem.value, true, true)
|
90
|
+
} else {
|
91
|
+
input.answer = '[REDACTED]'
|
92
|
+
}
|
87
93
|
} else if (inputType === 'radio' && elem.checked) {
|
88
94
|
input.answer = labelText
|
89
95
|
} else {
|
@@ -34,12 +34,19 @@ module GovukPublishingComponents
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def compile_data(path)
|
37
|
+
component_file_details = get_component_file_details(path)
|
38
|
+
helper_usage = get_helper_usage(component_file_details)
|
39
|
+
|
40
|
+
# remove the template file reference as not needed
|
41
|
+
component_file_details.map { |detail| detail.delete(:template_file) }
|
42
|
+
|
37
43
|
{
|
38
44
|
gem_found: true,
|
39
45
|
component_code: clean_files(@all_templates, @templates_full_path).sort,
|
40
46
|
components_containing_components: find_all_partials_in(@all_templates),
|
41
|
-
component_file_details:
|
47
|
+
component_file_details: component_file_details,
|
42
48
|
component_numbers: @component_numbers,
|
49
|
+
helper_usage: helper_usage,
|
43
50
|
}
|
44
51
|
end
|
45
52
|
|
@@ -96,6 +103,8 @@ module GovukPublishingComponents
|
|
96
103
|
type = detail[:type]
|
97
104
|
file = detail[:file]
|
98
105
|
details["#{type}_exists".to_sym] = false
|
106
|
+
# save the location of the template to later grep for helper use
|
107
|
+
details["#{type}_file".to_sym] = file if type == "template"
|
99
108
|
if File.file?(file)
|
100
109
|
# we don't have separate print stylesheets anymore
|
101
110
|
# so check the main stylesheet for print styles
|
@@ -215,5 +224,50 @@ module GovukPublishingComponents
|
|
215
224
|
|
216
225
|
link
|
217
226
|
end
|
227
|
+
|
228
|
+
def get_helper_usage(components)
|
229
|
+
helpers = [
|
230
|
+
{
|
231
|
+
name: "Brand helper",
|
232
|
+
link: "lib/govuk_publishing_components/app_helpers/brand_helper.rb",
|
233
|
+
match: /(GovukPublishingComponents::AppHelpers::BrandHelper.new)/,
|
234
|
+
used_by: [],
|
235
|
+
},
|
236
|
+
{
|
237
|
+
name: "Component wrapper helper",
|
238
|
+
link: "lib/govuk_publishing_components/presenters/component_wrapper_helper.rb",
|
239
|
+
match: /(GovukPublishingComponents::Presenters::ComponentWrapperHelper.new)/,
|
240
|
+
used_by: [],
|
241
|
+
},
|
242
|
+
{
|
243
|
+
name: "Heading helper",
|
244
|
+
link: "lib/govuk_publishing_components/presenters/heading_helper.rb",
|
245
|
+
match: /(GovukPublishingComponents::Presenters::HeadingHelper.new)/,
|
246
|
+
used_by: [],
|
247
|
+
},
|
248
|
+
{
|
249
|
+
name: "Shared helper",
|
250
|
+
link: "lib/govuk_publishing_components/presenters/shared_helper.rb",
|
251
|
+
match: /(GovukPublishingComponents::Presenters::SharedHelper.new)/,
|
252
|
+
used_by: [],
|
253
|
+
},
|
254
|
+
]
|
255
|
+
|
256
|
+
components.each do |component|
|
257
|
+
file = component[:template_file]
|
258
|
+
next unless File.file?(file)
|
259
|
+
|
260
|
+
helpers.each do |helper|
|
261
|
+
next unless File.foreach(file).grep(helper[:match]).present?
|
262
|
+
|
263
|
+
helper[:used_by] << {
|
264
|
+
name: component[:name],
|
265
|
+
link: component[:template_file].split("/components/")[1],
|
266
|
+
}
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
270
|
+
helpers
|
271
|
+
end
|
218
272
|
end
|
219
273
|
end
|
@@ -63,9 +63,54 @@
|
|
63
63
|
items: component_items
|
64
64
|
%>
|
65
65
|
|
66
|
+
<% helpers_by_component = capture do %>
|
67
|
+
<dl class="govuk-summary-list">
|
68
|
+
<% @components[:helper_usage].each do |helper| %>
|
69
|
+
<div class="govuk-summary-list__row">
|
70
|
+
<dt class="govuk-summary-list__key">
|
71
|
+
<a href="https://github.com/alphagov/govuk_publishing_components/blob/main/<%= helper[:link] %>" class="govuk-link"><%= helper[:name] %></a>
|
72
|
+
</dt>
|
73
|
+
<dd class="govuk-summary-list__value">
|
74
|
+
<details class="govuk-details" data-module="govuk-details">
|
75
|
+
<summary class="govuk-details__summary">
|
76
|
+
<span class="govuk-details__summary-text">
|
77
|
+
Used by <%= helper[:used_by].length %> components
|
78
|
+
</span>
|
79
|
+
</summary>
|
80
|
+
<div class="govuk-details__text">
|
81
|
+
<ul class="govuk-list govuk-list--bullet">
|
82
|
+
<% helper[:used_by].each do |component| %>
|
83
|
+
<% github_link = 'https://github.com/alphagov/govuk_publishing_components/tree/main/app/views/govuk_publishing_components/components/' %>
|
84
|
+
<li>
|
85
|
+
<a href="<%= github_link %><%= component[:link] %>" class="govuk-link"><%= component[:name] %></a>
|
86
|
+
</li>
|
87
|
+
<% end %>
|
88
|
+
</ul>
|
89
|
+
</div>
|
90
|
+
</details>
|
91
|
+
</dd>
|
92
|
+
</div>
|
93
|
+
<% end %>
|
94
|
+
</dl>
|
95
|
+
<% end %>
|
96
|
+
|
97
|
+
<%
|
98
|
+
component_items << {
|
99
|
+
heading: {
|
100
|
+
text: "Helpers by component",
|
101
|
+
},
|
102
|
+
summary: {
|
103
|
+
text: "Shows which components use common helpers",
|
104
|
+
},
|
105
|
+
content: {
|
106
|
+
html: helpers_by_component
|
107
|
+
},
|
108
|
+
}
|
109
|
+
%>
|
110
|
+
|
66
111
|
<%= render 'items_in_applications',
|
67
112
|
heading: 'Helpers by application',
|
68
|
-
summary: 'Shows any applications that use
|
113
|
+
summary: 'Shows any applications that use helpers from the components gem',
|
69
114
|
content: @components[:helpers_used_by_applications],
|
70
115
|
items: component_items
|
71
116
|
%>
|
data/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb
CHANGED
@@ -262,6 +262,9 @@
|
|
262
262
|
<form
|
263
263
|
class="gem-c-layout-super-navigation-header__search-form"
|
264
264
|
id="search"
|
265
|
+
data-module="ga4-form-tracker"
|
266
|
+
data-ga4-form='{ "event_name": "search", "type": "header menu bar", "section": "Search GOV.UK", "action": "Search", "url": "/search/all" }'
|
267
|
+
data-ga4-form-include-text
|
265
268
|
action="/search"
|
266
269
|
method="get"
|
267
270
|
role="search"
|
@@ -333,3 +333,23 @@ examples:
|
|
333
333
|
- title: UK-China High-Level People to People Dialogue 2017
|
334
334
|
base_path: /government/topical-events/uk-china-high-level-people-to-people-dialogue-2017
|
335
335
|
document_type: topical_event
|
336
|
+
world_locations:
|
337
|
+
- title: Algeria
|
338
|
+
base_path: /world/algeria/news
|
339
|
+
- title: Austria
|
340
|
+
base_path: /world/austria/news
|
341
|
+
- title: Belarus
|
342
|
+
base_path: /world/belarus/news
|
343
|
+
- title: Belgium
|
344
|
+
base_path: /world/belgium/news
|
345
|
+
- title: Bolivia
|
346
|
+
base_path: /world/bolivia/news
|
347
|
+
- title: Brazil
|
348
|
+
base_path: /world/brazil/news
|
349
|
+
- title: Canada
|
350
|
+
base_path: /world/canada/news
|
351
|
+
- title: Chile
|
352
|
+
base_path: /world/chile/news
|
353
|
+
- title: China
|
354
|
+
base_path: /world/China/news
|
355
|
+
|
@@ -63,17 +63,23 @@
|
|
63
63
|
<% end %>
|
64
64
|
|
65
65
|
<% if links.length > section_link_limit %>
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
66
|
+
<%
|
67
|
+
classes = "gem-c-related-navigation__link toggle-wrap"
|
68
|
+
data_attributes_li = { module: "ga4-event-tracker" } if ga4_tracking
|
69
|
+
data_attributes_link = {
|
70
|
+
controls: "toggle_#{section_title}",
|
71
|
+
expanded: "false",
|
72
|
+
toggled_text: t("common.toggle_less")
|
73
|
+
}
|
74
|
+
data_attributes_link[:ga4_event] = { "event_name": "select_content", "type": "related content" } if ga4_tracking
|
75
|
+
%>
|
76
|
+
<%= tag.li(class: classes, data: data_attributes_li) do %>
|
77
|
+
<%= link_to("#", class: "gem-c-related-navigation__toggle", data: data_attributes_link) do %>
|
72
78
|
<%= t("common.toggle_more",
|
73
79
|
show: t('common.show'),
|
74
|
-
number: related_nav_helper.remaining_link_count(links)) %>
|
75
|
-
|
76
|
-
|
80
|
+
number: related_nav_helper.remaining_link_count(links)) %>
|
81
|
+
<% end %>
|
82
|
+
<% end %>
|
77
83
|
|
78
84
|
<li class="gem-c-related-navigation__link gem-c-related-navigation__link--truncated-links">
|
79
85
|
<span id="toggle_<%= section_title %>" class="gem-c-related-navigation__toggle-more js-hidden">
|
data/config/locales/en.yml
CHANGED
@@ -293,7 +293,7 @@ en:
|
|
293
293
|
- label: 'Homes for Ukraine: record your interest'
|
294
294
|
href: https://www.gov.uk/register-interest-homes-ukraine
|
295
295
|
- label: Find out about the UK’s response
|
296
|
-
href: https://
|
296
|
+
href: https://www.gov.uk/government/topical-events/russian-invasion-of-ukraine-uk-government-response
|
297
297
|
title: Invasion of Ukraine
|
298
298
|
world_locations: World locations
|
299
299
|
search_box:
|
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: 34.
|
4
|
+
version: 34.12.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: 2023-02-
|
11
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_app_config
|