content_block_tools 0.10.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 076d610c0146672c70d0b2d7971b6917c87fc395599ff546e0f50a0fe6817bf5
4
- data.tar.gz: 3027bd4756b5246363b8ad1f220d9ec6da2e3c30dd79d3b1716ac568146be0fa
3
+ metadata.gz: 7bd3435567461a7899094649b4c46efc6ae674c943e94b7f7d8dc28615c90c54
4
+ data.tar.gz: 9cb772f8e04c00854c6824628f3defa875faa997a85f3c7be458fe1e22c758ee
5
5
  SHA512:
6
- metadata.gz: 31ebe02a43ba3a92b7f5c18717dc7e9b889aba02fd453d68f7bd71a494d82af835c182eebd8ff54abeed544dc0983016ef1abf659b356faca233d1ca8da3e8dc
7
- data.tar.gz: 1dd7eeeaa7aaba5f6ff1c7ca485eb4ed131dd604845dce282c700318f1314b281989d9993074e55f0dd12ba17e0324372a36acd9f508cfb506c53a6862c3a74a
6
+ metadata.gz: 57b390d576c0b7b4d2ac7e16d852d60c97ea3990f69861d633d8cf0041751391c0c8c4b06bd6ae037f057f8b909944a7a48819b75d22e147e497e8b3a0b2f1cc
7
+ data.tar.gz: a1d49cbc4e5ad8b87c16e4705d1c68ae7cc3143b960a5c02a9426a1b799a25934cfbdd0670b4605cc43333461b1b203bc4c29a0b8754a5c2126c6423bb6e1dc4
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@
7
7
  useful summary for people upgrading their application, not a replication
8
8
  of the commit log.
9
9
 
10
+ ## 0.12.0
11
+
12
+ - Add missing fields for contact object ([62](https://github.com/alphagov/govuk_content_block_tools/pull/62))
13
+
14
+ ## 0.11.0
15
+
16
+ - Update address and contact presenter to match model changes([61](https://github.com/alphagov/govuk_content_block_tools/pull/61))
17
+
10
18
  ## 0.10.0
11
19
 
12
20
  - Add content block titles to individual contact blocks ([60](https://github.com/alphagov/govuk_content_block_tools/pull/60))
@@ -9,25 +9,37 @@ module ContentBlockTools
9
9
 
10
10
  def render
11
11
  wrapper do
12
- content_tag(:p, class: "adr") do
13
- %i[street_address locality region postal_code country].map { |field|
12
+ output = []
13
+
14
+ output << content_tag(:p, class: "adr") do
15
+ %i[title street_address town_or_city state_or_county postal_code country].map { |field|
14
16
  next if item[field].blank?
15
17
 
16
18
  content_tag(:span, item[field], { class: class_for_field_name(field) })
17
19
  }.compact_blank.join(",<br/>").html_safe
18
20
  end
21
+
22
+ output << render_govspeak(item[:description]) if item[:description].present?
23
+
24
+ output.join.html_safe
19
25
  end
20
26
  end
21
27
 
22
28
  def class_for_field_name(field_name)
23
29
  {
24
30
  street_address: "street-address",
25
- locality: "locality",
26
- region: "region",
31
+ town_or_city: "locality",
32
+ state_or_county: "region",
27
33
  postal_code: "postal-code",
28
34
  country: "country-name",
29
35
  }[field_name]
30
36
  end
37
+
38
+ private
39
+
40
+ def show_title_in_field_names_context?
41
+ false
42
+ end
31
43
  end
32
44
  end
33
45
  end
@@ -14,7 +14,7 @@ module ContentBlockTools
14
14
  def wrapper(&block)
15
15
  if @rendering_context == :field_names
16
16
  content_tag(:div, class: "contact") do
17
- concat title
17
+ concat title if show_title_in_field_names_context?
18
18
  concat yield block
19
19
  end
20
20
  else
@@ -27,6 +27,12 @@ module ContentBlockTools
27
27
  @content_block.title,
28
28
  class: "govuk-!-margin-bottom-3")
29
29
  end
30
+
31
+ private
32
+
33
+ def show_title_in_field_names_context?
34
+ true
35
+ end
30
36
  end
31
37
  end
32
38
  end
@@ -10,16 +10,30 @@ module ContentBlockTools
10
10
  def render
11
11
  wrapper do
12
12
  content_tag(:div, class: "email-url-number") do
13
- content_tag(:p) do
14
- concat content_tag(:span, item[:title])
15
- concat content_tag(:a,
16
- item[:email_address],
17
- class: "email",
18
- href: "mailto:#{item[:email_address]}")
19
- end
13
+ concat email
14
+ concat render_govspeak(item[:description]) if item[:description].present?
20
15
  end
21
16
  end
22
17
  end
18
+
19
+ def email
20
+ content_tag(:p) do
21
+ concat content_tag(:span, item[:title])
22
+ concat content_tag(:a,
23
+ item[:email_address],
24
+ class: "email",
25
+ href: "mailto:#{item[:email_address]}#{query_params}")
26
+ end
27
+ end
28
+
29
+ def query_params
30
+ params = {
31
+ subject: item[:subject],
32
+ body: item[:body],
33
+ }.compact.map { |k, v| "#{k}=#{v}" }.join("&")
34
+
35
+ "?#{params}" if params.present?
36
+ end
23
37
  end
24
38
  end
25
39
  end
@@ -12,6 +12,8 @@ module ContentBlockTools
12
12
  content_tag(:div, class: "email-url-number") do
13
13
  concat title_and_description
14
14
  concat number_list
15
+ concat video_relay_service
16
+ concat bsl_details
15
17
  concat opening_hours_list if item[:opening_hours].present?
16
18
  concat call_charges_link
17
19
  end
@@ -54,6 +56,21 @@ module ContentBlockTools
54
56
  end
55
57
  end
56
58
 
59
+ def video_relay_service
60
+ video_relay_service = item[:video_relay_service] || {}
61
+
62
+ if video_relay_service[:show]
63
+ content = "#{video_relay_service[:prefix]} #{video_relay_service[:telephone_number]}"
64
+ render_govspeak(content, root_class: "govuk-!-margin-bottom-0")
65
+ end
66
+ end
67
+
68
+ def bsl_details
69
+ bsl_guidance = item[:bsl_guidance] || {}
70
+
71
+ render_govspeak(bsl_guidance[:value], root_class: "govuk-!-margin-bottom-0") if bsl_guidance[:show]
72
+ end
73
+
57
74
  def opening_hours_list
58
75
  content_tag(:ul) do
59
76
  item[:opening_hours].each do |item|
@@ -67,12 +84,14 @@ module ContentBlockTools
67
84
  end
68
85
 
69
86
  def call_charges_link
70
- if item[:show_uk_call_charges] == "true"
87
+ call_charges = item[:call_charges] || {}
88
+
89
+ if call_charges[:show_call_charges_info_url]
71
90
  content_tag(:p) do
72
91
  concat content_tag(:a,
73
- "Find out about call charges",
92
+ call_charges[:label],
74
93
  class: "govuk-link",
75
- href: "https://www.gov.uk/call-charges")
94
+ href: call_charges[:call_charges_info_url])
76
95
  end
77
96
  end
78
97
  end
@@ -2,6 +2,7 @@ module ContentBlockTools
2
2
  module Presenters
3
3
  class ContactPresenter < BasePresenter
4
4
  include ActionView::Helpers::TextHelper
5
+ include ContentBlockTools::Govspeak
5
6
 
6
7
  BASE_TAG_TYPE = :div
7
8
 
@@ -25,6 +26,7 @@ module ContentBlockTools
25
26
  content_tag(:div, class: "content") do
26
27
  content_tag(:div, class: "vcard contact-inner") do
27
28
  concat content_tag(:p, content_block.title, class: "fn org")
29
+ concat render_govspeak(content_block.details[:description]) if content_block.details[:description]
28
30
  embedded_objects.each do |object|
29
31
  items = send(object)
30
32
  concat(items.map { |item| presenter_for_object_type(object).new(item, content_block:).render }.join.html_safe)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentBlockTools
4
- VERSION = "0.10.0"
4
+ VERSION = "0.12.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_block_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev