metadata_presenter 0.28.6 → 0.28.11
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/helpers/metadata_presenter/application_helper.rb +0 -4
- data/app/models/metadata_presenter/metadata.rb +4 -0
- data/app/models/metadata_presenter/page.rb +22 -5
- data/app/presenters/metadata_presenter/page_answers_presenter.rb +16 -3
- data/app/views/metadata_presenter/footer/_meta.html.erb +1 -1
- data/app/views/metadata_presenter/page/checkanswers.html.erb +5 -2
- data/config/initializers/page_components.rb +13 -9
- data/default_metadata/page/start.json +1 -1
- data/fixtures/version.json +7 -1
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/page/checkanswers.json +0 -5
- 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: f78817e09df43b22a08bde0ef895aab1dad0b5df6c832a4863d3acd65226edc1
|
4
|
+
data.tar.gz: 7abf811d72763e4c898a6f99b39cd0626b2cec3f1669f95c93a76a44cf7366c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b97ab2f1943cd6606c46e1060bade9369c5153dbad518f7703ab9f2031b9c087b7c5c1c00b9e9c04d09ca56caf0249ebf8811ebdc5c3eafb87b1210dc743552
|
7
|
+
data.tar.gz: 8b5332c2a57fdc8c3008b1dba0017a0d858330d81b92ec8560dbee1f1a6f40bebf52965ee109bb8c2bff1019bef7855e3417539736765a226ee7936cc34f61e6
|
@@ -5,16 +5,25 @@ module MetadataPresenter
|
|
5
5
|
class Page < MetadataPresenter::Metadata
|
6
6
|
include ActiveModel::Validations
|
7
7
|
|
8
|
-
|
8
|
+
NOT_EDITABLE = %i[
|
9
9
|
_uuid
|
10
|
-
|
10
|
+
_id
|
11
|
+
_type
|
12
|
+
steps
|
13
|
+
add_component
|
14
|
+
add_extra_component
|
15
|
+
].freeze
|
11
16
|
|
12
17
|
def ==(other)
|
13
18
|
id == other.id if other.respond_to? :id
|
14
19
|
end
|
15
20
|
|
16
21
|
def editable_attributes
|
17
|
-
to_h.reject { |k, _| k.in?(
|
22
|
+
to_h.reject { |k, _| k.in?(NOT_EDITABLE) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def all_components
|
26
|
+
[components, extra_components].flatten.compact
|
18
27
|
end
|
19
28
|
|
20
29
|
def components
|
@@ -25,6 +34,14 @@ module MetadataPresenter
|
|
25
34
|
to_components(metadata.extra_components, collection: :extra_components)
|
26
35
|
end
|
27
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
|
+
|
28
45
|
def to_partial_path
|
29
46
|
type.gsub('.', '/')
|
30
47
|
end
|
@@ -34,11 +51,11 @@ module MetadataPresenter
|
|
34
51
|
end
|
35
52
|
|
36
53
|
def input_components
|
37
|
-
page_components(raw_type)[:
|
54
|
+
page_components(raw_type)[:input]
|
38
55
|
end
|
39
56
|
|
40
57
|
def content_components
|
41
|
-
page_components(raw_type)[:
|
58
|
+
page_components(raw_type)[:content]
|
42
59
|
end
|
43
60
|
|
44
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,6 +1,6 @@
|
|
1
1
|
<h2 class="govuk-visually-hidden">Support links</h2>
|
2
2
|
<ul class="govuk-footer__inline-list">
|
3
|
-
<%
|
3
|
+
<% service.meta.items.each do |item| %>
|
4
4
|
<li class="govuk-footer__inline-list-item">
|
5
5
|
<a class="govuk-footer__link" href=<%= File.join(request.script_name, item.href) %>><%= item.text %></a>
|
6
6
|
</li>
|
@@ -2,8 +2,6 @@
|
|
2
2
|
<div class="govuk-grid-row">
|
3
3
|
<div class="govuk-grid-column-two-thirds">
|
4
4
|
|
5
|
-
<%= render partial: 'metadata_presenter/attribute/section_heading' %>
|
6
|
-
|
7
5
|
<h1 class="fb-editable govuk-heading-xl"
|
8
6
|
data-fb-content-type="element"
|
9
7
|
data-fb-content-id="page[heading]">
|
@@ -51,6 +49,11 @@
|
|
51
49
|
<% end %>
|
52
50
|
</dd>
|
53
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 %>
|
54
57
|
<% end %>
|
55
58
|
<% end %>
|
56
59
|
</dl>
|
@@ -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
|
})
|
@@ -2,7 +2,7 @@
|
|
2
2
|
"_id": "page.start",
|
3
3
|
"_type": "page.start",
|
4
4
|
"heading": "Service name goes here",
|
5
|
-
"lede": "
|
5
|
+
"lede": "",
|
6
6
|
"body": "Use this service to:\r\n\r\n* do something\r\n* update your name, address or other details\r\n* do something else\r\n\r\nRegistering takes around 5 minutes.",
|
7
7
|
"before_you_start": "###Before you start\r\nYou can also register by post.\r\n\r\nThe online service is also available in Welsh (Cymraeg).\r\n\r\nYou cannot register for this service if you’re in the UK illegally.",
|
8
8
|
"steps": [],
|
data/fixtures/version.json
CHANGED
@@ -280,6 +280,11 @@
|
|
280
280
|
"required": true
|
281
281
|
}
|
282
282
|
},
|
283
|
+
{
|
284
|
+
"_id": "star-wars-knowledge_content_1",
|
285
|
+
"_type": "content",
|
286
|
+
"content": "Stay on target"
|
287
|
+
},
|
283
288
|
{
|
284
289
|
"_id": "star-wars-knowledge_radios_1",
|
285
290
|
"_type": "radios",
|
@@ -340,12 +345,12 @@
|
|
340
345
|
"_id": "page._check-answers",
|
341
346
|
"_type": "page.checkanswers",
|
342
347
|
"heading": "Review your answer",
|
343
|
-
"section_heading": "This section is optional",
|
344
348
|
"send_body": "By submitting this answer you confirm all your answers",
|
345
349
|
"send_heading": "Send your answer",
|
346
350
|
"url": "/check-answers",
|
347
351
|
"components": [
|
348
352
|
{
|
353
|
+
"_uuid": "256291c2-8ffa-4bda-8282-88e0724ccd10",
|
349
354
|
"_id": "check-answers_content_1",
|
350
355
|
"_type": "content",
|
351
356
|
"content": "Check yourself before you wreck yourself."
|
@@ -353,6 +358,7 @@
|
|
353
358
|
],
|
354
359
|
"extra_components": [
|
355
360
|
{
|
361
|
+
"_uuid": "09961c6a-29f8-4d4f-a6d2-af00cff15536",
|
356
362
|
"_id": "check-answers_content_1",
|
357
363
|
"_type": "content",
|
358
364
|
"content": "Take the cannoli."
|
@@ -8,11 +8,6 @@
|
|
8
8
|
"_type": {
|
9
9
|
"const": "page.checkanswers"
|
10
10
|
},
|
11
|
-
"section_heading": {
|
12
|
-
"title": "Section heading",
|
13
|
-
"type": "string",
|
14
|
-
"description": "Section to display before the heading"
|
15
|
-
},
|
16
11
|
"heading": {
|
17
12
|
"type": "string",
|
18
13
|
"default": "Check your answers"
|
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.11
|
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
|