govuk_publishing_components 28.7.1 → 28.8.0
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/analytics/page-content.js +3 -3
- data/app/views/govuk_publishing_components/components/_attachment.html.erb +3 -1
- data/app/views/govuk_publishing_components/components/docs/attachment.yml +11 -0
- data/lib/govuk_publishing_components/presenters/attachment.rb +23 -0
- data/lib/govuk_publishing_components/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dbe5219da6d54a38c3909d40c427560378214263daa7701f83c7972c24509d4
|
4
|
+
data.tar.gz: 850ad5d021962d86f7d192ebe353d850c3041e21f200dfbbeceb12d5a3c83304
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de64be05c1cb2168c55c4ab9a7eea97c0e4861b9625edeb0cbec24b419f1f3b15c9d1908c5aa50a382946237052c5eb4312137df75ba87d21314b8e02bec661e
|
7
|
+
data.tar.gz: 71eecbbd72eba66a68b972e3f8020cd87b96bf076094f2bf1330271b012f95c735fb907d66e8d25ad5562ce72157a5e15921e51fe882eb593f6c84e3d7460cf3
|
@@ -14,7 +14,7 @@
|
|
14
14
|
case isDocumentCollectionPage():
|
15
15
|
return document.querySelectorAll('.document-collection .group-title').length
|
16
16
|
case isMainstreamBrowsePage():
|
17
|
-
return countVisible(document.querySelectorAll('#subsection ul')) || document.querySelectorAll('#section ul').length
|
17
|
+
return countVisible(document.querySelectorAll('#subsection ul')) || document.querySelectorAll('#section ul').length || document.querySelectorAll('#root ul').length
|
18
18
|
case isTopicPage():
|
19
19
|
return document.querySelectorAll('.topics-page nav.index-list').length
|
20
20
|
case isPolicyAreaPage():
|
@@ -45,7 +45,7 @@
|
|
45
45
|
case isDocumentCollectionPage():
|
46
46
|
return document.querySelectorAll('.document-collection .group-document-list li a').length
|
47
47
|
case isMainstreamBrowsePage():
|
48
|
-
return countVisible(document.querySelectorAll('#subsection ul a')) || document.querySelectorAll('#section ul a').length
|
48
|
+
return countVisible(document.querySelectorAll('#subsection ul a')) || document.querySelectorAll('#section ul a').length || document.querySelectorAll('#root ul a').length
|
49
49
|
case isTopicPage():
|
50
50
|
return document.querySelectorAll('.topics-page .index-list ul a').length ||
|
51
51
|
document.querySelectorAll('.topics-page .topics ul a').length
|
@@ -71,7 +71,7 @@
|
|
71
71
|
function getMetaAttribute (selector) {
|
72
72
|
var element = document.querySelector(selector)
|
73
73
|
if (element) {
|
74
|
-
return element.getAttribute('content')
|
74
|
+
return element.getAttribute('content').toLowerCase()
|
75
75
|
}
|
76
76
|
}
|
77
77
|
|
@@ -83,7 +83,9 @@
|
|
83
83
|
<% end %>
|
84
84
|
<% end %>
|
85
85
|
|
86
|
-
<% if attachment.
|
86
|
+
<% if attachment.display_accessible_format_request_form_link? %>
|
87
|
+
<%= link_to "Request an accessible format of this document", "/contact/govuk/request-accessible-format?content_id=#{attachment.owning_document_content_id}&attachment_id=#{attachment.attachment_id}", class: "govuk-link" %>
|
88
|
+
<% elsif attachment.alternative_format_contact_email %>
|
87
89
|
<%= tag.p t("components.attachment.request_format_text"), class: "gem-c-attachment__metadata" %>
|
88
90
|
<%= render "govuk_publishing_components/components/details", {
|
89
91
|
title: t("components.attachment.request_format_cta")
|
@@ -76,6 +76,17 @@ examples:
|
|
76
76
|
content_type: application/pdf
|
77
77
|
file_size: 20000
|
78
78
|
alternative_format_contact_email: defra.helpline@defra.gsi.gov.uk
|
79
|
+
with_link_to_request_accessible_format_form:
|
80
|
+
data:
|
81
|
+
attachment:
|
82
|
+
title: "Department for Transport information asset register"
|
83
|
+
url: https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/747661/department-for-transport-information-asset-register.csv
|
84
|
+
filename: department-for-transport-information-asset-register.csv
|
85
|
+
content_type: application/pdf
|
86
|
+
file_size: 20000
|
87
|
+
owning_document_content_id: 456_abc
|
88
|
+
attachment_id: 123
|
89
|
+
alternative_format_contact_email: alternative.formats@education.gov.uk
|
79
90
|
with_data_attributes:
|
80
91
|
data:
|
81
92
|
attachment:
|
@@ -1,6 +1,16 @@
|
|
1
1
|
module GovukPublishingComponents
|
2
2
|
module Presenters
|
3
3
|
class Attachment
|
4
|
+
# DfE, DWP, DHSC, HMRC, DVSA and PHE are taking part in a pilot to use a form
|
5
|
+
# rather than direct email for users to request accessible formats. When the pilot
|
6
|
+
# scheme is rolled out further this can be removed.
|
7
|
+
EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT = %w[alternative.formats@education.gov.uk
|
8
|
+
accessible.formats@dwp.gov.uk
|
9
|
+
publications@dhsc.gov.uk
|
10
|
+
different.format@hmrc.gov.uk
|
11
|
+
gov.uk.publishing@dvsa.gov.uk
|
12
|
+
publications@phe.gov.uk].freeze
|
13
|
+
|
4
14
|
delegate :opendocument?, :document?, :spreadsheet?, to: :content_type
|
5
15
|
|
6
16
|
attr_reader :attachment_data
|
@@ -8,6 +18,7 @@ module GovukPublishingComponents
|
|
8
18
|
# Expects a hash of attachment data
|
9
19
|
# * title and url are required
|
10
20
|
# * content_type, filename, file_size, number of pages, alternative_format_contact_email can be provided
|
21
|
+
# * attachment_id and owning_document_content_id are required to use the accessible format request form
|
11
22
|
def initialize(attachment_data)
|
12
23
|
@attachment_data = attachment_data.with_indifferent_access
|
13
24
|
end
|
@@ -47,6 +58,14 @@ module GovukPublishingComponents
|
|
47
58
|
attachment_data[:alternative_format_contact_email]
|
48
59
|
end
|
49
60
|
|
61
|
+
def attachment_id
|
62
|
+
attachment_data[:attachment_id]
|
63
|
+
end
|
64
|
+
|
65
|
+
def owning_document_content_id
|
66
|
+
attachment_data[:owning_document_content_id]
|
67
|
+
end
|
68
|
+
|
50
69
|
def reference
|
51
70
|
reference = []
|
52
71
|
reference << "ISBN #{attachment_data[:isbn]}" if attachment_data[:isbn].present?
|
@@ -71,6 +90,10 @@ module GovukPublishingComponents
|
|
71
90
|
attachment_data[:command_paper_number].present? || attachment_data[:hoc_paper_number].present? || attachment_data[:unnumbered_command_paper].eql?(true) || attachment_data[:unnumbered_hoc_paper].eql?(true)
|
72
91
|
end
|
73
92
|
|
93
|
+
def display_accessible_format_request_form_link?
|
94
|
+
EMAILS_IN_ACCESSIBLE_FORMAT_REQUEST_PILOT.include?(alternative_format_contact_email) && owning_document_content_id.present? && attachment_id.present?
|
95
|
+
end
|
96
|
+
|
74
97
|
class SupportedContentType
|
75
98
|
attr_reader :content_type_data
|
76
99
|
|