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 +4 -4
- data/app/models/metadata_presenter/page.rb +14 -2
- data/app/presenters/metadata_presenter/page_answers_presenter.rb +16 -3
- data/app/views/metadata_presenter/page/checkanswers.html.erb +5 -0
- data/config/initializers/page_components.rb +13 -9
- data/lib/metadata_presenter/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab52764aea2d132a57111ec99a9d7523362e8163a4d78a6254667c47cbb35f2a
|
4
|
+
data.tar.gz: bc5f21431c95fbd7ca139adb76376879eb712b31b360694ed98cf3941dfcb318
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)[:
|
54
|
+
page_components(raw_type)[:input]
|
43
55
|
end
|
44
56
|
|
45
57
|
def content_components
|
46
|
-
page_components(raw_type)[:
|
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[
|
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.
|
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
|
-
|
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),
|
@@ -1,19 +1,23 @@
|
|
1
1
|
Rails.application.config.page_components =
|
2
2
|
ActiveSupport::HashWithIndifferentAccess.new({
|
3
3
|
checkanswers: {
|
4
|
-
|
5
|
-
|
4
|
+
input: %w(),
|
5
|
+
content: %w(content)
|
6
6
|
},
|
7
7
|
confirmation: {
|
8
|
-
|
9
|
-
|
8
|
+
input: %w(),
|
9
|
+
content: %w(content)
|
10
10
|
},
|
11
11
|
content: {
|
12
|
-
|
13
|
-
|
12
|
+
input: %w(),
|
13
|
+
content: %w(content)
|
14
14
|
},
|
15
15
|
multiplequestions: {
|
16
|
-
|
17
|
-
|
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
|
})
|
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.
|
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-
|
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
|