content_block_tools 1.1.1 → 1.2.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/stylesheets/content_block_tools.scss +14 -13
- data/app/components/content_block_tools/base_component.rb +1 -0
- data/app/components/content_block_tools/contact_component.html.erb +19 -14
- data/app/components/content_block_tools/contact_component.rb +2 -4
- data/app/components/content_block_tools/contacts/address_component.html.erb +1 -1
- data/app/components/content_block_tools/contacts/address_component.rb +0 -2
- data/app/components/content_block_tools/contacts/contact_link_component.html.erb +1 -1
- data/app/components/content_block_tools/contacts/contact_link_component.rb +0 -2
- data/app/components/content_block_tools/contacts/email_address_component.html.erb +1 -1
- data/app/components/content_block_tools/contacts/email_address_component.rb +0 -2
- data/app/components/content_block_tools/contacts/telephone_component.html.erb +5 -5
- data/app/components/content_block_tools/contacts/telephone_component.rb +0 -2
- data/lib/content_block_tools/content_block.rb +4 -1
- data/lib/content_block_tools/version.rb +1 -1
- metadata +15 -2
- data/app/assets/stylesheets/blocks/_contact.scss +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31aa623f594711bad29bb3e3dcd8540565f469a3432d9fd4a2d6d01e00cbef99
|
4
|
+
data.tar.gz: dbe0f54e0ed010a2cb110259ca56d81cadd782373119aa632d7b447c03fd10c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f105b4fda9c8680ebf69f1bc48f79278e861050035a5febeac7d0cc932f1dc96dfcc793f1cb4c12161b57e24d17bc55da55b13ce125efe7d0118bd0648bc58
|
7
|
+
data.tar.gz: 868af6b530f82d1bc74877aa6baca6f20ebd86c07cd62b1ce233ddae724865676bca53d249ecce791a75377411761f073b094aa14265b6899baf7c36f1ebab3b
|
@@ -1,25 +1,26 @@
|
|
1
|
-
@import "govuk/core/links";
|
2
1
|
@import "govuk/core/lists";
|
3
2
|
@import "govuk/core/typography";
|
4
3
|
|
5
|
-
@import "blocks/contact";
|
6
|
-
|
7
4
|
.content-block {
|
8
|
-
&
|
9
|
-
|
5
|
+
&__contact-key, &__contact-value, &__contact-list {
|
6
|
+
margin: 0;
|
7
|
+
padding: 0;
|
10
8
|
}
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
10
|
+
&__contact-list {
|
11
|
+
.content-block__contact-key {
|
12
|
+
@extend %govuk-heading-m;
|
13
|
+
}
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
&--nested {
|
16
|
+
.content-block__contact-key {
|
17
|
+
@extend %govuk-heading-s;
|
18
|
+
}
|
19
19
|
}
|
20
20
|
}
|
21
21
|
|
22
|
-
|
23
|
-
@extend %govuk-
|
22
|
+
ul.content-block__list {
|
23
|
+
@extend %govuk-list;
|
24
|
+
margin-left: 0;
|
24
25
|
}
|
25
26
|
}
|
@@ -1,18 +1,23 @@
|
|
1
|
-
<
|
2
|
-
<
|
3
|
-
|
4
|
-
<% if block_type.present? && content_block.details[:description] %>
|
5
|
-
<%= render_govspeak(content_block.details[:description]) %>
|
6
|
-
<% end %>
|
1
|
+
<dl class="vcard content-block__contact-list">
|
2
|
+
<dt class="content-block__contact-key fn org"><%= content_block.title %></dt>
|
7
3
|
|
8
4
|
<% if block_type.nil? %>
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
<dd class="content-block__contact-value">
|
6
|
+
<%= render_govspeak(content_block.details[:description]) if content_block.details[:description] %>
|
7
|
+
<dl class="content-block__contact-list--nested">
|
8
|
+
<% BLOCK_TYPES.each do |block_type| %>
|
9
|
+
<% content_for_block_type(block_type).each do |item| %>
|
10
|
+
<dt class="content-block__contact-key"><%= item[:title] %></dt>
|
11
|
+
<dd class="content-block__contact-value">
|
12
|
+
<%= component_for_block_type(block_type).new(item:).render.html_safe %>
|
13
|
+
</dd>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
</dl>
|
17
|
+
</dd>
|
15
18
|
<% else %>
|
16
|
-
|
19
|
+
<dd class="content-block__contact-value">
|
20
|
+
<%= component_for_block_type(block_type).new(item: item_to_render).render.html_safe %>
|
21
|
+
</dd>
|
17
22
|
<% end %>
|
18
|
-
</
|
23
|
+
</dl>
|
@@ -16,10 +16,8 @@ module ContentBlockTools
|
|
16
16
|
"ContentBlockTools::Contacts::#{block_type.to_s.singularize.camelize}Component".constantize
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
[key, content_block.details[key]&.values]
|
22
|
-
}.to_h
|
19
|
+
def content_for_block_type(block_type)
|
20
|
+
content_block.details.fetch(block_type, {}).values
|
23
21
|
end
|
24
22
|
|
25
23
|
def item_to_render
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<% if item[:description] %>
|
2
|
-
<%= render_govspeak(item[:description]
|
2
|
+
<%= render_govspeak(item[:description]) %>
|
3
3
|
<% end %>
|
4
4
|
|
5
5
|
<ul class="content-block__list">
|
@@ -16,16 +16,16 @@
|
|
16
16
|
<% end %>
|
17
17
|
|
18
18
|
<% if show_bsl_guidance? %>
|
19
|
-
<%= render_govspeak(bsl_guidance[:value]
|
19
|
+
<%= render_govspeak(bsl_guidance[:value]) %>
|
20
20
|
<% end %>
|
21
21
|
|
22
22
|
<% if show_opening_hours? %>
|
23
|
-
<%= render_govspeak(opening_hours[:opening_hours]
|
23
|
+
<%= render_govspeak(opening_hours[:opening_hours]) %>
|
24
24
|
<% end %>
|
25
25
|
|
26
26
|
<% if show_call_charges? %>
|
27
|
-
<p
|
28
|
-
<a href="<%= call_charges[:call_charges_info_url] %>"
|
27
|
+
<p>
|
28
|
+
<a href="<%= call_charges[:call_charges_info_url] %>">
|
29
29
|
<%= call_charges[:label] %>
|
30
30
|
</a>
|
31
31
|
</p>
|
@@ -40,6 +40,7 @@ module ContentBlockTools
|
|
40
40
|
# @return [String]
|
41
41
|
class ContentBlock
|
42
42
|
include ActionView::Helpers::TagHelper
|
43
|
+
class UnknownComponentError < StandardError; end
|
43
44
|
|
44
45
|
CONTENT_BLOCK_PREFIX = "content_block_".freeze
|
45
46
|
|
@@ -87,7 +88,7 @@ module ContentBlockTools
|
|
87
88
|
|
88
89
|
def content
|
89
90
|
field_names.present? ? field_or_block_content : component.new(content_block: self).render
|
90
|
-
rescue
|
91
|
+
rescue UnknownComponentError
|
91
92
|
title
|
92
93
|
end
|
93
94
|
|
@@ -110,6 +111,8 @@ module ContentBlockTools
|
|
110
111
|
|
111
112
|
def component
|
112
113
|
"ContentBlockTools::#{document_type.camelize}Component".constantize
|
114
|
+
rescue NameError
|
115
|
+
raise UnknownComponentError
|
113
116
|
end
|
114
117
|
|
115
118
|
def field_presenter(field)
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GOV.UK Dev
|
@@ -65,6 +65,20 @@ dependencies:
|
|
65
65
|
- - '='
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: 5.1.18
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: simplecov
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
type: :development
|
76
|
+
prerelease: false
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
68
82
|
- !ruby/object:Gem::Dependency
|
69
83
|
name: actionview
|
70
84
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +142,6 @@ extensions: []
|
|
128
142
|
extra_rdoc_files: []
|
129
143
|
files:
|
130
144
|
- README.md
|
131
|
-
- app/assets/stylesheets/blocks/_contact.scss
|
132
145
|
- app/assets/stylesheets/content_block_tools.scss
|
133
146
|
- app/components/content_block_tools/base_component.rb
|
134
147
|
- app/components/content_block_tools/contact_component.html.erb
|