metadata_presenter 2.0.2 → 2.3.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/models/metadata_presenter/page.rb +23 -10
- data/app/models/metadata_presenter/previous_page.rb +0 -13
- data/app/models/metadata_presenter/service.rb +16 -9
- data/app/presenters/metadata_presenter/page_answers_presenter.rb +1 -1
- data/app/views/metadata_presenter/page/checkanswers.html.erb +4 -4
- data/app/views/metadata_presenter/page/confirmation.html.erb +2 -2
- data/app/views/metadata_presenter/page/content.html.erb +2 -2
- data/app/views/metadata_presenter/page/multiplequestions.html.erb +2 -2
- data/config/initializers/{page_components.rb → supported_components.rb} +1 -1
- data/default_metadata/flow/branch.json +1 -0
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/flow/branch.json +3 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b021784e55967939a9588d2e9503b1b572668a6015c4fc5021c1b44b85d99b5
|
4
|
+
data.tar.gz: 9c6784cab9f797a215100a0c1eeb53586a5fe4c9b7ac2afe0ee0b2fa3a7b252f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94aeac55e2766b36fece298133e5a4ed8506f849f9b99c3851e3d5733800469c9512717ed666b4573a17a74f60f11a46750512e23af9ef41f2e06a974bba2549
|
7
|
+
data.tar.gz: be13444b27be0604b4bb7875dffeafb4b014c20affee27438983197eb2f40a3b5d1ca1ab72695def1e810b86d8dda84397818176ce3b53dd70c3785e0c051bc8
|
@@ -12,6 +12,7 @@ module MetadataPresenter
|
|
12
12
|
add_component
|
13
13
|
add_extra_component
|
14
14
|
].freeze
|
15
|
+
QUESTION_PAGES = %w[page.singlequestion page.multiplequestions].freeze
|
15
16
|
|
16
17
|
def editable_attributes
|
17
18
|
to_h.reject { |k, _| k.in?(NOT_EDITABLE) }
|
@@ -33,11 +34,19 @@ module MetadataPresenter
|
|
33
34
|
to_components(metadata.extra_components, collection: :extra_components)
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
-
|
37
|
+
def input_components
|
38
|
+
all_components.reject(&:content?)
|
39
|
+
end
|
40
|
+
|
41
|
+
def content_components
|
42
|
+
all_components.select(&:content?)
|
43
|
+
end
|
44
|
+
|
45
|
+
def supported_components_by_type(type)
|
46
|
+
supported = supported_components(raw_type)[type]
|
38
47
|
|
39
48
|
all_components.select do |component|
|
40
|
-
|
49
|
+
supported.include?(component.type)
|
41
50
|
end
|
42
51
|
end
|
43
52
|
|
@@ -49,12 +58,12 @@ module MetadataPresenter
|
|
49
58
|
"metadata_presenter/#{type.gsub('.', '/')}"
|
50
59
|
end
|
51
60
|
|
52
|
-
def
|
53
|
-
|
61
|
+
def supported_input_components
|
62
|
+
supported_components(raw_type)[:input]
|
54
63
|
end
|
55
64
|
|
56
|
-
def
|
57
|
-
|
65
|
+
def supported_content_components
|
66
|
+
supported_components(raw_type)[:content]
|
58
67
|
end
|
59
68
|
|
60
69
|
def upload_components
|
@@ -65,6 +74,10 @@ module MetadataPresenter
|
|
65
74
|
type == 'page.standalone'
|
66
75
|
end
|
67
76
|
|
77
|
+
def question_page?
|
78
|
+
type.in?(QUESTION_PAGES)
|
79
|
+
end
|
80
|
+
|
68
81
|
def title
|
69
82
|
return heading if heading?
|
70
83
|
|
@@ -87,10 +100,10 @@ module MetadataPresenter
|
|
87
100
|
end
|
88
101
|
end
|
89
102
|
|
90
|
-
def
|
91
|
-
values = Rails.application.config.
|
103
|
+
def supported_components(page_type)
|
104
|
+
values = Rails.application.config.supported_components[page_type]
|
92
105
|
if values.blank?
|
93
|
-
raise PageComponentsNotDefinedError, "No
|
106
|
+
raise PageComponentsNotDefinedError, "No supported components defined for #{page_type} in config initialiser"
|
94
107
|
end
|
95
108
|
|
96
109
|
values
|
@@ -6,24 +6,11 @@ module MetadataPresenter
|
|
6
6
|
def page
|
7
7
|
return if no_current_or_referrer_pages? || service.no_back_link?(current_page)
|
8
8
|
|
9
|
-
return referrer_page if return_to_referrer?
|
10
|
-
|
11
9
|
TraversedPages.new(service, user_data, current_page).last
|
12
10
|
end
|
13
11
|
|
14
12
|
private
|
15
13
|
|
16
|
-
def referrer_page
|
17
|
-
@referrer_page ||= service.find_page_by_url(URI(referrer).path)
|
18
|
-
end
|
19
|
-
|
20
|
-
def return_to_referrer?
|
21
|
-
return false unless current_page.standalone?
|
22
|
-
|
23
|
-
current_page.standalone? ||
|
24
|
-
(referrer_page && referrer_page.standalone?)
|
25
|
-
end
|
26
|
-
|
27
14
|
def no_current_or_referrer_pages?
|
28
15
|
current_page.blank? || referrer.nil?
|
29
16
|
end
|
@@ -5,6 +5,13 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
|
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
8
|
+
def branches
|
9
|
+
collection = flow.map do |_, flow|
|
10
|
+
MetadataPresenter::Flow.new(flow)
|
11
|
+
end
|
12
|
+
collection.select { |flow| flow.type == 'flow.branch' }
|
13
|
+
end
|
14
|
+
|
8
15
|
def flow_object(uuid)
|
9
16
|
MetadataPresenter::Flow.new(metadata.flow[uuid])
|
10
17
|
rescue StandardError
|
@@ -38,14 +45,6 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
|
|
38
45
|
pages[pages.index(current_page) + 1] if current_page.present?
|
39
46
|
end
|
40
47
|
|
41
|
-
def previous_page(current_page:, referrer:)
|
42
|
-
return if current_page.nil? || referrer.nil?
|
43
|
-
|
44
|
-
unless no_back_link?(current_page)
|
45
|
-
flow_page(current_page) || referrer_page(referrer)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
48
|
def confirmation_page
|
50
49
|
@confirmation_page ||= pages.find do |page|
|
51
50
|
page.type == 'page.confirmation'
|
@@ -57,7 +56,15 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
|
|
57
56
|
end
|
58
57
|
|
59
58
|
def no_back_link?(current_page)
|
60
|
-
current_page == start_page ||
|
59
|
+
current_page == start_page ||
|
60
|
+
current_page == confirmation_page ||
|
61
|
+
current_page.standalone?
|
62
|
+
end
|
63
|
+
|
64
|
+
def page_with_component(uuid)
|
65
|
+
pages.find do |page|
|
66
|
+
Array(page.components).any? { |component| component.uuid == uuid }
|
67
|
+
end
|
61
68
|
end
|
62
69
|
|
63
70
|
private
|
@@ -10,7 +10,7 @@ module MetadataPresenter
|
|
10
10
|
|
11
11
|
def self.map(view:, pages:, answers:)
|
12
12
|
user_input_pages(pages).map { |page|
|
13
|
-
Array(page.
|
13
|
+
Array(page.supported_components_by_type(:input)).map do |component|
|
14
14
|
new(
|
15
15
|
view: view,
|
16
16
|
component: component,
|
@@ -16,8 +16,8 @@
|
|
16
16
|
components: @page.extra_components,
|
17
17
|
tag: nil,
|
18
18
|
classes: nil,
|
19
|
-
input_components: @page.
|
20
|
-
content_components: @page.
|
19
|
+
input_components: @page.supported_input_components,
|
20
|
+
content_components: @page.supported_content_components
|
21
21
|
} %>
|
22
22
|
|
23
23
|
<dl class="fb-block fb-block-answers govuk-summary-list">
|
@@ -80,8 +80,8 @@
|
|
80
80
|
components: @page.components,
|
81
81
|
tag: nil,
|
82
82
|
classes: nil,
|
83
|
-
input_components: @page.
|
84
|
-
content_components: @page.
|
83
|
+
input_components: @page.supported_input_components,
|
84
|
+
content_components: @page.supported_content_components
|
85
85
|
} %>
|
86
86
|
|
87
87
|
<button <%= 'disabled' if editable? %> data-prevent-double-click="true" class="fb-block fb-block-actions govuk-button" data-module="govuk-button" data-block-id="actions" data-block-type="actions">
|
@@ -29,7 +29,7 @@
|
|
29
29
|
components: @page.components,
|
30
30
|
tag: nil,
|
31
31
|
classes: nil,
|
32
|
-
input_components: @page.
|
33
|
-
content_components: @page.
|
32
|
+
input_components: @page.supported_input_components,
|
33
|
+
content_components: @page.supported_content_components
|
34
34
|
} %>
|
35
35
|
</div>
|
@@ -21,8 +21,8 @@
|
|
21
21
|
components: @page.components,
|
22
22
|
tag: nil,
|
23
23
|
classes: nil,
|
24
|
-
input_components: @page.
|
25
|
-
content_components: @page.
|
24
|
+
input_components: @page.supported_input_components,
|
25
|
+
content_components: @page.supported_content_components
|
26
26
|
} %>
|
27
27
|
|
28
28
|
<%= f.govuk_submit(disabled: editable?) %>
|
@@ -13,8 +13,8 @@
|
|
13
13
|
components: @page.components,
|
14
14
|
tag: :h2,
|
15
15
|
classes: 'govuk-heading-m govuk-!-margin-top-8',
|
16
|
-
input_components: @page.
|
17
|
-
content_components: @page.
|
16
|
+
input_components: @page.supported_input_components,
|
17
|
+
content_components: @page.supported_content_components
|
18
18
|
}
|
19
19
|
%>
|
20
20
|
|
data/schemas/flow/branch.json
CHANGED
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: 2.0
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- MoJ
|
7
|
+
- MoJ Forms
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_design_system_formbuilder
|
@@ -254,9 +254,9 @@ dependencies:
|
|
254
254
|
- - ">="
|
255
255
|
- !ruby/object:Gem::Version
|
256
256
|
version: '0'
|
257
|
-
description: Service Metadata Presenter for the
|
257
|
+
description: Service Metadata Presenter for the MoJ Forms product
|
258
258
|
email:
|
259
|
-
- moj-
|
259
|
+
- moj-forms@digital.justice.gov.uk
|
260
260
|
executables: []
|
261
261
|
extensions: []
|
262
262
|
extra_rdoc_files: []
|
@@ -343,8 +343,8 @@ files:
|
|
343
343
|
- config/initializers/default_metadata.rb
|
344
344
|
- config/initializers/default_text.rb
|
345
345
|
- config/initializers/inflections.rb
|
346
|
-
- config/initializers/page_components.rb
|
347
346
|
- config/initializers/schemas.rb
|
347
|
+
- config/initializers/supported_components.rb
|
348
348
|
- config/routes.rb
|
349
349
|
- default_metadata/component/checkboxes.json
|
350
350
|
- default_metadata/component/content.json
|
@@ -453,7 +453,7 @@ files:
|
|
453
453
|
- schemas/service/configuration.json
|
454
454
|
- schemas/service/locale.json
|
455
455
|
- schemas/validations/validations.json
|
456
|
-
homepage: https://moj-
|
456
|
+
homepage: https://moj-forms.service.justice.gov.uk/
|
457
457
|
licenses:
|
458
458
|
- MIT
|
459
459
|
metadata: {}
|