content_block_tools 1.9.1 → 1.10.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: e50657a9e305421a79ca23cd7720452747b391c2e9fddb3161f2f54f4edf1bc2
4
- data.tar.gz: c0b154b766abdc488a3ce96bcffaadb7fd7a2218e0b8f5017965ae563f9068f6
3
+ metadata.gz: 995ae1c7fb38df54eff5b1df0af68aeb8558cee5e587e9334e8e8d4d903703b0
4
+ data.tar.gz: 0fda3eaef6bf5a4009d7e11dc0fb13cf2ddfdf462db070d6865af65123ba7335
5
5
  SHA512:
6
- metadata.gz: cf33728eec2476f0187debb97ea2b3e752bcc6c822d4489527459bc8c51d84ae3ab1cd800c6bc31bbab565b04dcbd1c44f2dce61483a60a27efb81de99156c8c
7
- data.tar.gz: a8406089740ab6c854fd9d7b73f00d9293ff12e09aea269de8fa249d2c0d94e3f4405fe06a67f0810f770b51a98cee287a81ab4c6266801895a7f7fc4c11e432
6
+ metadata.gz: 9b40e81a30e9e2b9c9c1b22f816911b4886148d7e61347b2ecd8becde453f7a0304f6db89eae4de60ad2d9af65cb607e0d76758028d17373330dc13e56a84f1a
7
+ data.tar.gz: '0783a6f182c878b206847103f7872e4ccfe9263f104f2077f4d8377d48c94b1045292a3523727878f8055541b8715b711d7b1dbe3ce11d0128f80d7640b22bb2'
@@ -1,14 +1,20 @@
1
1
  <div class="vcard">
2
2
  <% if block_type.nil? %>
3
- <%= render_govspeak(content_block.details[:description]) if content_block.details[:description] %>
3
+ <% if content_block.details[:description] %>
4
+ <div data-diff-key="description">
5
+ <%= render_govspeak(content_block.details[:description]) %>
6
+ </div>
7
+ <% end %>
4
8
  <dl class="<%= margin_classes(0) %> <%= padding_classes(0) %>">
5
- <% items.each do |block_type, _, item| %>
6
- <dt class="<%= margin_classes(0, 0, 4, 0) %> <%= padding_classes(0) %> <%= font_classes(19, "bold") %>">
7
- <%= item[:title] %>
8
- </dt>
9
- <dd class="<%= margin_classes(0, 0, 6, 0) %>">
10
- <%= component_for_block_type(block_type).new(item:).render.html_safe %>
11
- </dd>
9
+ <% items.each do |block_type, key, item| %>
10
+ <div data-diff-key="<%= block_type %>-<%= key %>">
11
+ <dt class="<%= margin_classes(0, 0, 4, 0) %> <%= padding_classes(0) %> <%= font_classes(19, "bold") %>">
12
+ <%= item[:title] %>
13
+ </dt>
14
+ <dd class="<%= margin_classes(0, 0, 6, 0) %>">
15
+ <%= component_for_block_type(block_type).new(item:).render.html_safe %>
16
+ </dd>
17
+ </div>
12
18
  <% end %>
13
19
  </dl>
14
20
  <% else %>
@@ -0,0 +1,5 @@
1
+ <p class="govuk-body">
2
+ <%= start_date %>
3
+ to
4
+ <%= end_date %>
5
+ </p>
@@ -0,0 +1,29 @@
1
+ module ContentBlockTools
2
+ class TimePeriodComponent < ContentBlockTools::BaseComponent
3
+ def initialize(content_block:, _block_type: nil, _block_name: nil)
4
+ @content_block = content_block
5
+ end
6
+
7
+ def start_date
8
+ presented_date(
9
+ content_block.details.dig(:date_range, :start, :date),
10
+ )
11
+ end
12
+
13
+ def end_date
14
+ presented_date(
15
+ content_block.details.dig(:date_range, :end, :date),
16
+ )
17
+ end
18
+
19
+ private
20
+
21
+ attr_reader :content_block
22
+
23
+ def presented_date(date)
24
+ Presenters::FieldPresenters::TimePeriod::DatePresenter.new(
25
+ date,
26
+ ).render
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentBlockTools
4
- VERSION = "1.9.1"
4
+ VERSION = "1.10.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: 1.9.1
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
@@ -186,6 +186,8 @@ files:
186
186
  - app/components/content_block_tools/contacts/email_address_component.rb
187
187
  - app/components/content_block_tools/contacts/telephone_component.html.erb
188
188
  - app/components/content_block_tools/contacts/telephone_component.rb
189
+ - app/components/content_block_tools/time_period_component.html.erb
190
+ - app/components/content_block_tools/time_period_component.rb
189
191
  - lib/content_block_tools.rb
190
192
  - lib/content_block_tools/content_block.rb
191
193
  - lib/content_block_tools/content_block_reference.rb