metadata_presenter 0.28.9 → 0.28.10

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: f4d5dbea9a24b8fae69170d03e8ff69dafd77a0b858013baee1c8c1434fdcca1
4
- data.tar.gz: 415da25856e17541de78ece98f8539471e33ae8417285630ef00a55152982999
3
+ metadata.gz: ab52764aea2d132a57111ec99a9d7523362e8163a4d78a6254667c47cbb35f2a
4
+ data.tar.gz: bc5f21431c95fbd7ca139adb76376879eb712b31b360694ed98cf3941dfcb318
5
5
  SHA512:
6
- metadata.gz: 770aed14f9470f3d1f0af53e0411e3f190aa92268a031eb0cfd8af5aea8822e1b9aed8544db21d494cd897ac48f43676ae35a1ac7ce6fefd2a7fc96be59151d7
7
- data.tar.gz: c64ee626011dd6027f48c6a98e86309efc8b8671d1f52cb7ead124650a7cb23d1d3c9850a49f6e3dace01297f7a94b5ee8111e8bd98b931cd8f7933f8885183a
6
+ metadata.gz: ebd89e1970ddaad3e8062c9c5e5815ac3095c3a1b0897645bcb5c307f95dd3a38f39fcf37ee2c405a6e954f8383cc1b339c74af6926b7d47f38094aa153e88dd
7
+ data.tar.gz: aaf3a97b00bd56921805985eb06a6dbbc9109281d7d96e6e9a7ae1924c967edaed4d0b8f7a6118a2128189bc4ca3f52648df7b72c634d2462e5c967d262f8fa7
@@ -22,6 +22,10 @@ module MetadataPresenter
22
22
  to_h.reject { |k, _| k.in?(NOT_EDITABLE) }
23
23
  end
24
24
 
25
+ def all_components
26
+ [components, extra_components].flatten.compact
27
+ end
28
+
25
29
  def components
26
30
  to_components(metadata.components, collection: :components)
27
31
  end
@@ -30,6 +34,14 @@ module MetadataPresenter
30
34
  to_components(metadata.extra_components, collection: :extra_components)
31
35
  end
32
36
 
37
+ def components_by_type(type)
38
+ supported_components = page_components(raw_type)[type]
39
+
40
+ all_components.select do |component|
41
+ supported_components.include?(component.type)
42
+ end
43
+ end
44
+
33
45
  def to_partial_path
34
46
  type.gsub('.', '/')
35
47
  end
@@ -39,11 +51,11 @@ module MetadataPresenter
39
51
  end
40
52
 
41
53
  def input_components
42
- page_components(raw_type)[:input_components]
54
+ page_components(raw_type)[:input]
43
55
  end
44
56
 
45
57
  def content_components
46
- page_components(raw_type)[:content_components]
58
+ page_components(raw_type)[:content]
47
59
  end
48
60
 
49
61
  private
@@ -1,11 +1,16 @@
1
1
  module MetadataPresenter
2
2
  class PageAnswersPresenter
3
3
  FIRST_ANSWER = 0
4
- NO_USER_INPUT = %w[page.checkanswers page.confirmation page.content].freeze
4
+ NO_USER_INPUT = %w[
5
+ page.checkanswers
6
+ page.confirmation
7
+ page.content
8
+ page.start
9
+ ].freeze
5
10
 
6
11
  def self.map(view:, pages:, answers:)
7
12
  user_input_pages(pages).map { |page|
8
- Array(page.components).map do |component|
13
+ Array(page.components_by_type(:input)).map do |component|
9
14
  new(
10
15
  view: view,
11
16
  component: component,
@@ -47,11 +52,19 @@ module MetadataPresenter
47
52
  end
48
53
 
49
54
  def display_heading?(index)
50
- page.type == 'page.multiplequestions' && index == FIRST_ANSWER
55
+ multiplequestions_page? && index == FIRST_ANSWER
56
+ end
57
+
58
+ def last_multiple_question?(index, presenters_count_for_page)
59
+ multiplequestions_page? && index == presenters_count_for_page - 1
51
60
  end
52
61
 
53
62
  private
54
63
 
64
+ def multiplequestions_page?
65
+ page.type == 'page.multiplequestions'
66
+ end
67
+
55
68
  def date(value)
56
69
  I18n.l(
57
70
  Date.civil(value.year.to_i, value.month.to_i, value.day.to_i),
@@ -49,6 +49,11 @@
49
49
  <% end %>
50
50
  </dd>
51
51
  </div>
52
+
53
+ <% if page_answers_presenter.last_multiple_question?(index, page_answers_presenters.size) %>
54
+ </dl>
55
+ <dl class="fb-block fb-block-answers govuk-summary-list">
56
+ <% end %>
52
57
  <% end %>
53
58
  <% end %>
54
59
  </dl>
@@ -1,19 +1,23 @@
1
1
  Rails.application.config.page_components =
2
2
  ActiveSupport::HashWithIndifferentAccess.new({
3
3
  checkanswers: {
4
- input_components: %w(),
5
- content_components: %w(content)
4
+ input: %w(),
5
+ content: %w(content)
6
6
  },
7
7
  confirmation: {
8
- input_components: %w(),
9
- content_components: %w(content)
8
+ input: %w(),
9
+ content: %w(content)
10
10
  },
11
11
  content: {
12
- input_components: %w(),
13
- content_components: %w(content)
12
+ input: %w(),
13
+ content: %w(content)
14
14
  },
15
15
  multiplequestions: {
16
- input_components: %w(text textarea number date radios checkboxes),
17
- content_components: %w(content)
18
- }
16
+ input: %w(text textarea number date radios checkboxes),
17
+ content: %w(content)
18
+ },
19
+ singlequestion: {
20
+ input: %w(text textarea number date radios checkboxes),
21
+ content: %w()
22
+ }
19
23
  })
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '0.28.9'.freeze
2
+ VERSION = '0.28.10'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metadata_presenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.9
4
+ version: 0.28.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - MoJ Online
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-16 00:00:00.000000000 Z
11
+ date: 2021-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder