metadata_presenter 0.15.1 → 0.16.2
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/controllers/metadata_presenter/pages_controller.rb +2 -2
- data/app/helpers/metadata_presenter/application_helper.rb +4 -6
- data/app/presenters/metadata_presenter/page_answers_presenter.rb +7 -1
- data/app/views/metadata_presenter/component/_text.html.erb +6 -8
- data/app/views/metadata_presenter/component/_textarea.html.erb +10 -12
- data/app/views/metadata_presenter/page/checkanswers.html.erb +29 -18
- data/app/views/metadata_presenter/page/multiplequestions.html.erb +33 -0
- data/app/views/metadata_presenter/page/singlequestion.html.erb +11 -6
- data/default_metadata/component/checkboxes.json +3 -3
- data/default_metadata/component/date.json +2 -2
- data/default_metadata/component/number.json +2 -2
- data/default_metadata/component/radios.json +3 -3
- data/default_metadata/component/text.json +2 -2
- data/default_metadata/component/textarea.json +2 -2
- data/default_metadata/page/confirmation.json +1 -1
- data/default_metadata/page/multiplequestions.json +8 -0
- data/fixtures/version.json +53 -0
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/page/multiplequestions.json +20 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09f9fc6e7ed4404617573ba3531101418a53dc43b731dbbd92faeeb95325db28'
|
4
|
+
data.tar.gz: ecf8c3777cebe819ce26bc3bd7ba69dce8b8de1bb5ae450658355935a2e69d9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf80b5fb3e1d6f0eaed3baa06626d72ebdd4f8e379e332ede82578140b580b7901cd961a0544e63726ed1c9a6d9aaa52af26f4829730fc23e9df6c78c2a950e
|
7
|
+
data.tar.gz: f815e89fcf290f637a7ee38da32a0957bb097f7fe25ffd83612152f8dd70fd3aed8d8d9a00eb18b444399b9f3fe01f60a0295547dc50fd2cc9b4d1a7075b1783
|
@@ -12,13 +12,13 @@ module MetadataPresenter
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def
|
15
|
+
def pages_presenters
|
16
16
|
PageAnswersPresenter.map(
|
17
17
|
view: view_context,
|
18
18
|
pages: service.pages,
|
19
19
|
answers: @user_data
|
20
20
|
)
|
21
21
|
end
|
22
|
-
helper_method :
|
22
|
+
helper_method :pages_presenters
|
23
23
|
end
|
24
24
|
end
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
module ApplicationHelper
|
3
|
-
def
|
3
|
+
def main_title(component:, tag: :h1, classes: 'govuk-heading-xl')
|
4
4
|
if component.legend.present?
|
5
|
-
content_tag(:
|
6
|
-
|
7
|
-
component.legend
|
8
|
-
end
|
5
|
+
content_tag(:h1, class: 'govuk-heading-xl') do
|
6
|
+
component.legend
|
9
7
|
end
|
10
8
|
else
|
11
|
-
content_tag(
|
9
|
+
content_tag(tag, class: classes) do
|
12
10
|
component.label
|
13
11
|
end
|
14
12
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
class PageAnswersPresenter
|
3
|
+
FIRST_ANSWER = 0.freeze
|
4
|
+
|
3
5
|
def self.map(view:, pages:, answers:)
|
4
6
|
pages.map do |page|
|
5
7
|
Array(page.components).map do |component|
|
@@ -10,7 +12,7 @@ module MetadataPresenter
|
|
10
12
|
answers: answers
|
11
13
|
)
|
12
14
|
end
|
13
|
-
end.
|
15
|
+
end.reject { |page| page.empty? }
|
14
16
|
end
|
15
17
|
|
16
18
|
attr_reader :view, :component, :page, :answers
|
@@ -37,6 +39,10 @@ module MetadataPresenter
|
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
42
|
+
def display_heading?(index)
|
43
|
+
page.type == 'page.multiplequestions' && index == FIRST_ANSWER
|
44
|
+
end
|
45
|
+
|
40
46
|
private
|
41
47
|
|
42
48
|
def date(value)
|
@@ -1,8 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
%>
|
8
|
-
</div>
|
1
|
+
<%=
|
2
|
+
f.govuk_text_field component.id.to_sym,
|
3
|
+
label: { text: input_title },
|
4
|
+
hint: { text: component.hint },
|
5
|
+
name: "answers[#{component.name}]"
|
6
|
+
%>
|
@@ -1,12 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
%>
|
12
|
-
</div>
|
1
|
+
<%=
|
2
|
+
f.govuk_text_area component.id.to_sym,
|
3
|
+
label: { text: input_title },
|
4
|
+
hint: { text: component.hint },
|
5
|
+
name: "answers[#{component.name}]",
|
6
|
+
max_chars: component.maxchars,
|
7
|
+
max_words: component.maxwords,
|
8
|
+
threshold: component.threshold,
|
9
|
+
rows: component.rows
|
10
|
+
%>
|
@@ -35,25 +35,36 @@
|
|
35
35
|
<%= form_for @page, url: reserved_submissions_path do |f| %>
|
36
36
|
<div data-block-id="page.checkanswers.answers" data-block-type="answers">
|
37
37
|
<dl class="fb-block fb-block-answers govuk-summary-list">
|
38
|
-
<%
|
39
|
-
|
40
|
-
<dt class="govuk-summary-list__key">
|
41
|
-
<%= page_answers_presenter.humanised_title %>
|
42
|
-
</dt>
|
38
|
+
<% pages_presenters.each do |page_answers_presenters| %>
|
39
|
+
<% page_answers_presenters.each_with_index do |page_answers_presenter, index| %>
|
43
40
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
41
|
+
<% if page_answers_presenter.display_heading?(index) %>
|
42
|
+
</dl>
|
43
|
+
|
44
|
+
<h3 class="govuk-heading-m"><%= page_answers_presenter.page.heading %></h3>
|
45
|
+
|
46
|
+
<dl class="fb-block fb-block-answers govuk-summary-list">
|
47
|
+
<% end %>
|
48
|
+
|
49
|
+
<div class="govuk-summary-list__row">
|
50
|
+
<dt class="govuk-summary-list__key">
|
51
|
+
<%= page_answers_presenter.humanised_title %>
|
52
|
+
</dt>
|
53
|
+
|
54
|
+
<dd class="govuk-summary-list__value">
|
55
|
+
<%= page_answers_presenter.answer %>
|
56
|
+
</dd>
|
57
|
+
<dd class="govuk-summary-list__actions">
|
58
|
+
<%= link_to(
|
59
|
+
change_answer_path(url: page_answers_presenter.url),
|
60
|
+
class: 'govuk-link'
|
61
|
+
) do %>
|
62
|
+
Change<span class="govuk-visually-hidden"> Your answer for <%= page_answers_presenter.humanised_title %></span>
|
63
|
+
<% end %>
|
64
|
+
</a>
|
65
|
+
</dd>
|
66
|
+
</div>
|
67
|
+
<% end %>
|
57
68
|
<% end %>
|
58
69
|
</dl>
|
59
70
|
</div>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<div class="fb-main-grid-wrapper" data-block-id="<%= @page.id %>" data-block-type="page" data-block-pagetype="<%= @page.type %>">
|
2
|
+
<div class="govuk-grid-row">
|
3
|
+
<div class="govuk-grid-column-two-thirds">
|
4
|
+
<% if @page.section_heading %>
|
5
|
+
<p class="fb-editable govuk-caption-l fb-section_heading"
|
6
|
+
data-fb-content-type="element"
|
7
|
+
data-fb-content-id="page[section_heading]">
|
8
|
+
<%= @page.section_heading.html_safe %>
|
9
|
+
</p>
|
10
|
+
<%- end %>
|
11
|
+
|
12
|
+
<h1 class="govuk-heading-xl"><%= @page.heading %></h1>
|
13
|
+
|
14
|
+
<%= form_for @page_answers, as: :answers, url: @page.url, method: :post do |f| %>
|
15
|
+
<%= f.govuk_error_summary %>
|
16
|
+
<% @page.components.each_with_index do |component, index| %>
|
17
|
+
<%= render partial: component, locals: {
|
18
|
+
component: component,
|
19
|
+
component_id: "page[components[#{index}]]",
|
20
|
+
f: f,
|
21
|
+
input_title: main_title(
|
22
|
+
component: component,
|
23
|
+
tag: :h2,
|
24
|
+
classes: 'govuk-heading-m govuk-!-margin-top-8'
|
25
|
+
) }
|
26
|
+
%>
|
27
|
+
<% end %>
|
28
|
+
|
29
|
+
<%= f.govuk_submit(disabled: editable?) %>
|
30
|
+
<% end %>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
</div>
|
@@ -3,13 +3,18 @@
|
|
3
3
|
<div class="govuk-grid-column-two-thirds">
|
4
4
|
<%= form_for @page_answers, as: :answers, url: @page.url, method: :post do |f| %>
|
5
5
|
<%= f.govuk_error_summary %>
|
6
|
+
|
6
7
|
<% @page.components.each_with_index do |component, index| %>
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
<div class="fb-editable"
|
9
|
+
data-fb-content-type="<%= component._type %>"
|
10
|
+
data-fb-content-id="<%= "page[components[#{index}]]" %>"
|
11
|
+
data-fb-content-data="<%= component.to_json %>">
|
12
|
+
<%= render partial: component, locals: {
|
13
|
+
component: component,
|
14
|
+
f: f,
|
15
|
+
input_title: main_title(component: component) }
|
16
|
+
%>
|
17
|
+
</div>
|
13
18
|
<% end %>
|
14
19
|
|
15
20
|
<%= f.govuk_submit(disabled: editable?) %>
|
@@ -2,20 +2,20 @@
|
|
2
2
|
"_id": "component.checkboxes",
|
3
3
|
"_type": "checkboxes",
|
4
4
|
"errors": {},
|
5
|
-
"hint": "[
|
5
|
+
"hint": "[Optional hint text]",
|
6
6
|
"items": [
|
7
7
|
{
|
8
8
|
"_id": "component_checkbox_1",
|
9
9
|
"_type": "checkbox",
|
10
10
|
"label": "Option",
|
11
|
-
"hint": "[
|
11
|
+
"hint": "[Optional hint text]",
|
12
12
|
"value": "value-1"
|
13
13
|
},
|
14
14
|
{
|
15
15
|
"_id": "component_checkbox_2",
|
16
16
|
"_type": "checkbox",
|
17
17
|
"label": "Option",
|
18
|
-
"hint": "[
|
18
|
+
"hint": "[Optional hint text]",
|
19
19
|
"value": "value-2"
|
20
20
|
}
|
21
21
|
],
|
@@ -2,20 +2,20 @@
|
|
2
2
|
"_id": "component.radios",
|
3
3
|
"_type": "radios",
|
4
4
|
"errors": {},
|
5
|
-
"hint": "[
|
5
|
+
"hint": "[Optional hint text]",
|
6
6
|
"items": [
|
7
7
|
{
|
8
8
|
"_id": "component_radio_1",
|
9
9
|
"_type": "radio",
|
10
10
|
"label": "Option",
|
11
|
-
"hint": "[
|
11
|
+
"hint": "[Optional hint text]",
|
12
12
|
"value": "value-1"
|
13
13
|
},
|
14
14
|
{
|
15
15
|
"_id": "component_radio_2",
|
16
16
|
"_type": "radio",
|
17
17
|
"label": "Option",
|
18
|
-
"hint": "[
|
18
|
+
"hint": "[Optional hint text]",
|
19
19
|
"value": "value-2"
|
20
20
|
}
|
21
21
|
],
|
data/fixtures/version.json
CHANGED
@@ -266,6 +266,59 @@
|
|
266
266
|
"heading": "Checkboxes",
|
267
267
|
"url": "/burgers"
|
268
268
|
},
|
269
|
+
{
|
270
|
+
"_uuid": "9403b67a-19b5-4422-a91d-0774537e4c96",
|
271
|
+
"_id": "page.star-wars-knowledge",
|
272
|
+
"_type": "page.multiplequestions",
|
273
|
+
"components": [
|
274
|
+
{
|
275
|
+
"_id": "star-wars-knowledge_text_1",
|
276
|
+
"_type": "text",
|
277
|
+
"label": "What was the name of the band playing in Jabba's palace?",
|
278
|
+
"name": "star-wars-knowledge_text_1",
|
279
|
+
"validation": {
|
280
|
+
"required": true
|
281
|
+
}
|
282
|
+
},
|
283
|
+
{
|
284
|
+
"_id": "star-wars-knowledge_radios_1",
|
285
|
+
"_type": "radios",
|
286
|
+
"errors": {},
|
287
|
+
"hint": "Component hint",
|
288
|
+
"legend": "What is The Mandalorian's real name?",
|
289
|
+
"items": [
|
290
|
+
{
|
291
|
+
"_id": "star-wars-knowledge_radio_1",
|
292
|
+
"_type": "radio",
|
293
|
+
"label": "Harry Potter",
|
294
|
+
"hint": "Optional item hint",
|
295
|
+
"value": "harry-potter"
|
296
|
+
},
|
297
|
+
{
|
298
|
+
"_id": "star-wars-knowledge_radio_2",
|
299
|
+
"_type": "radio",
|
300
|
+
"label": "Din Jarrin",
|
301
|
+
"hint": "Optional item hint",
|
302
|
+
"value": "din-jarrin"
|
303
|
+
},
|
304
|
+
{
|
305
|
+
"_id": "star-wars-knowledge_radio_3",
|
306
|
+
"_type": "radio",
|
307
|
+
"label": "Tony Stark",
|
308
|
+
"hint": "Optional item hint",
|
309
|
+
"value": "tony-stark"
|
310
|
+
}
|
311
|
+
],
|
312
|
+
"name": "star-wars-knowledge_radios_1",
|
313
|
+
"validation": {
|
314
|
+
"required": true
|
315
|
+
}
|
316
|
+
}
|
317
|
+
],
|
318
|
+
"heading": "How well do you know Star Wars?",
|
319
|
+
"section_heading": "That's no moon",
|
320
|
+
"url": "/star-wars-knowledge"
|
321
|
+
},
|
269
322
|
{
|
270
323
|
"_uuid": "e819d0c2-7062-4997-89cf-44d26d098404",
|
271
324
|
"_id": "page._check-answers",
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/page/multiplequestions",
|
3
|
+
"_name": "page.multiplequestions",
|
4
|
+
"title": "Multiple questions",
|
5
|
+
"description": "Ask users more than one question on a page",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"_type": {
|
9
|
+
"const": "page.multiplequestions"
|
10
|
+
}
|
11
|
+
},
|
12
|
+
"allOf": [
|
13
|
+
{
|
14
|
+
"$ref": "definition.page.form"
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"required": [
|
18
|
+
"heading"
|
19
|
+
]
|
20
|
+
}
|
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.
|
4
|
+
version: 0.16.2
|
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-03-
|
11
|
+
date: 2021-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- app/views/metadata_presenter/page/checkanswers.html.erb
|
262
262
|
- app/views/metadata_presenter/page/confirmation.html.erb
|
263
263
|
- app/views/metadata_presenter/page/form.html.erb
|
264
|
+
- app/views/metadata_presenter/page/multiplequestions.html.erb
|
264
265
|
- app/views/metadata_presenter/page/singlequestion.html.erb
|
265
266
|
- app/views/metadata_presenter/page/start.html.erb
|
266
267
|
- config/initializers/default_metadata.rb
|
@@ -278,6 +279,7 @@ files:
|
|
278
279
|
- default_metadata/definition/radio.json
|
279
280
|
- default_metadata/page/checkanswers.json
|
280
281
|
- default_metadata/page/confirmation.json
|
282
|
+
- default_metadata/page/multiplequestions.json
|
281
283
|
- default_metadata/page/singlequestion.json
|
282
284
|
- default_metadata/page/start.json
|
283
285
|
- default_metadata/service/base.json
|
@@ -342,6 +344,7 @@ files:
|
|
342
344
|
- schemas/link/link.json
|
343
345
|
- schemas/page/checkanswers.json
|
344
346
|
- schemas/page/confirmation.json
|
347
|
+
- schemas/page/multiplequestions.json
|
345
348
|
- schemas/page/singlequestion.json
|
346
349
|
- schemas/page/start.json
|
347
350
|
- schemas/request/service.json
|