content_block_tools 0.6.4 → 0.7.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/CHANGELOG.md +9 -0
- data/lib/content_block_tools/presenters/block_presenters/base_presenter.rb +0 -4
- data/lib/content_block_tools/presenters/block_presenters/contact/address_presenter.rb +16 -8
- data/lib/content_block_tools/presenters/block_presenters/contact/contact_form_presenter.rb +8 -6
- data/lib/content_block_tools/presenters/block_presenters/contact/email_address_presenter.rb +8 -6
- data/lib/content_block_tools/presenters/block_presenters/contact/telephone_presenter.rb +20 -4
- data/lib/content_block_tools/presenters/contact_presenter.rb +8 -4
- data/lib/content_block_tools/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: 55ffab3c548b42f43db5e9ea658b4fc6cdd13e0d51eaef12c1c7b60a72f00bb7
|
4
|
+
data.tar.gz: e6ca9db8eddd145974c49edb2a57b4f6b1b327b1f94a855a9ae2e61dc2765261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ce195b0111b12dcf83b791f3702e75e2d4edeb2abb1bb8caa827257780eb1f858b8a1f78bbdd4c7ae439968eed27d360d59026ad0a46bfb170930bbe67fd6bd
|
7
|
+
data.tar.gz: a33e0a2898e36fd0c73245e115f9eac3732bf183c59c4836621b20ac89138a69d87ee234714b201c92421f49d035a8ee8c9dc35ad14601fdfb782d417c1a2612
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,15 @@
|
|
7
7
|
useful summary for people upgrading their application, not a replication
|
8
8
|
of the commit log.
|
9
9
|
|
10
|
+
## 0.7.0
|
11
|
+
|
12
|
+
- Alter markup of contact ([55](https://github.com/alphagov/govuk_content_block_tools/pull/55))
|
13
|
+
- Handle when opening hours are missing ([55](https://github.com/alphagov/govuk_content_block_tools/pull/55))
|
14
|
+
|
15
|
+
## 0.6.5
|
16
|
+
|
17
|
+
- Add opening hours to a contact block ([52](https://github.com/alphagov/govuk_content_block_tools/pull/52))
|
18
|
+
|
10
19
|
## 0.6.4
|
11
20
|
|
12
21
|
- Fix rendering of block when UK call charges are not shown ([54](https://github.com/alphagov/govuk_content_block_tools/pull/54))
|
@@ -4,16 +4,24 @@ module ContentBlockTools
|
|
4
4
|
module Contact
|
5
5
|
class AddressPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
|
6
6
|
def render
|
7
|
-
content_tag(:p, class: "
|
8
|
-
[
|
9
|
-
item[
|
10
|
-
|
11
|
-
item[
|
12
|
-
|
13
|
-
item[:country],
|
14
|
-
].compact_blank.join(",<br/>").html_safe
|
7
|
+
content_tag(:p, class: "adr") do
|
8
|
+
%i[street_address locality region postal_code country].map { |field|
|
9
|
+
next if item[field].blank?
|
10
|
+
|
11
|
+
content_tag(:span, item[field], { class: class_for_field_name(field) })
|
12
|
+
}.compact_blank.join(",<br/>").html_safe
|
15
13
|
end
|
16
14
|
end
|
15
|
+
|
16
|
+
def class_for_field_name(field_name)
|
17
|
+
{
|
18
|
+
street_address: "street-address",
|
19
|
+
locality: "locality",
|
20
|
+
region: "region",
|
21
|
+
postal_code: "postal-code",
|
22
|
+
country: "country-name",
|
23
|
+
}[field_name]
|
24
|
+
end
|
17
25
|
end
|
18
26
|
end
|
19
27
|
end
|
@@ -4,12 +4,14 @@ module ContentBlockTools
|
|
4
4
|
module Contact
|
5
5
|
class ContactFormPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
|
6
6
|
def render
|
7
|
-
content_tag(:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
content_tag(:div, class: "email-url-number") do
|
8
|
+
content_tag(:p) do
|
9
|
+
concat content_tag(:span, item[:title])
|
10
|
+
concat content_tag(:a,
|
11
|
+
item[:url],
|
12
|
+
class: "url",
|
13
|
+
href: item[:url])
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -4,12 +4,14 @@ module ContentBlockTools
|
|
4
4
|
module Contact
|
5
5
|
class EmailAddressPresenter < ContentBlockTools::Presenters::BlockPresenters::BasePresenter
|
6
6
|
def render
|
7
|
-
content_tag(:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
content_tag(:div, class: "email-url-number") do
|
8
|
+
content_tag(:p) do
|
9
|
+
concat content_tag(:span, item[:title])
|
10
|
+
concat content_tag(:a,
|
11
|
+
item[:email_address],
|
12
|
+
class: "email",
|
13
|
+
href: "mailto:#{item[:email_address]}")
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
@@ -6,14 +6,15 @@ module ContentBlockTools
|
|
6
6
|
BASE_TAG_TYPE = :div
|
7
7
|
|
8
8
|
def render
|
9
|
-
content_tag(:div, class: "
|
9
|
+
content_tag(:div, class: "email-url-number") do
|
10
10
|
concat number_list
|
11
|
+
concat opening_hours_list if item[:opening_hours].present?
|
11
12
|
concat call_charges_link
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
def number_list
|
16
|
-
content_tag(:ul
|
17
|
+
content_tag(:ul) do
|
17
18
|
item[:telephone_numbers].each do |number|
|
18
19
|
concat number_list_item(number)
|
19
20
|
end
|
@@ -21,12 +22,27 @@ module ContentBlockTools
|
|
21
22
|
end
|
22
23
|
|
23
24
|
def number_list_item(number)
|
24
|
-
content_tag(:li
|
25
|
+
content_tag(:li) do
|
26
|
+
concat content_tag(:span, number[:label])
|
27
|
+
concat content_tag(:span, number[:telephone_number], { class: "tel" })
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def opening_hours_list
|
32
|
+
content_tag(:ul) do
|
33
|
+
item[:opening_hours].each do |item|
|
34
|
+
concat opening_hours_list_item(item)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def opening_hours_list_item(item)
|
40
|
+
content_tag(:li, "#{item[:day_from]} to #{item[:day_to]}, #{item[:time_from]} to #{item[:time_to]}")
|
25
41
|
end
|
26
42
|
|
27
43
|
def call_charges_link
|
28
44
|
if item[:show_uk_call_charges] == "true"
|
29
|
-
content_tag(:p
|
45
|
+
content_tag(:p) do
|
30
46
|
concat content_tag(:a,
|
31
47
|
"Find out about call charges",
|
32
48
|
class: "govuk-link",
|
@@ -20,10 +20,14 @@ module ContentBlockTools
|
|
20
20
|
|
21
21
|
def default_content
|
22
22
|
content_tag(:div, class: "contact") do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
content_tag(:div, class: "content") do
|
24
|
+
content_tag(:div, class: "vcard contact-inner") do
|
25
|
+
concat content_tag(:p, content_block.title, class: "fn org")
|
26
|
+
embedded_objects.each do |object|
|
27
|
+
items = send(object)
|
28
|
+
concat(items.map { |item| presenter_for_object_type(object).new(item).render }.join.html_safe)
|
29
|
+
end
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|