metadata_presenter 0.15.2 → 0.17.1
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/content.json +5 -0
- 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/component/content.json +30 -0
- data/schemas/definition/page.json +2 -0
- data/schemas/page/checkanswers.json +0 -3
- data/schemas/page/confirmation.json +0 -3
- data/schemas/page/multiplequestions.json +20 -0
- data/schemas/page/singlequestion.json +1 -0
- data/schemas/page/start.json +0 -2
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b653825d328257b11234319575f8742e666a45f2d8502adf79a1a2896c331f01
|
4
|
+
data.tar.gz: d9a3fb7541c8cd077ce66ae3b67c3a828ef97faf15719bb5d278a92d7a3f5bab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34ba78444c9620972472ad35de61a0090b5653cc585ce4b8bab8c28b09560c61015f8b22a2233f741aaa757bce22214d5c381ab54f47900965b7df0d362781ba
|
7
|
+
data.tar.gz: 0ecdff6b63586d59599e6cb69720bd73a949cd4be02929e98625e1c1097f2a201067f0453406459ea458dd4f6c813e08a59717c69b93bcd7e97fcfb36268d99c
|
@@ -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,30 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/content",
|
3
|
+
"_name": "component.content",
|
4
|
+
"title": "Content",
|
5
|
+
"description": "Display ‘flat’ content, such as text",
|
6
|
+
"type": "object",
|
7
|
+
"category": [
|
8
|
+
"content"
|
9
|
+
],
|
10
|
+
"properties": {
|
11
|
+
"_type": {
|
12
|
+
"const": "content"
|
13
|
+
},
|
14
|
+
"html": {
|
15
|
+
"title": "Content",
|
16
|
+
"description": "Content to display - use [markdown](https://www.gov.uk/guidance/how-to-publish-on-gov-uk/markdown) to format text or add hyperlinks",
|
17
|
+
"type": "string",
|
18
|
+
"content": true,
|
19
|
+
"multiline": true
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"allOf": [
|
23
|
+
{
|
24
|
+
"$ref": "definition.component"
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"required": [
|
28
|
+
"html"
|
29
|
+
]
|
30
|
+
}
|
@@ -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
|
+
}
|
data/schemas/page/start.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: 0.
|
4
|
+
version: 0.17.1
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -261,12 +261,14 @@ 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
|
267
268
|
- config/initializers/schemas.rb
|
268
269
|
- config/routes.rb
|
269
270
|
- default_metadata/component/checkboxes.json
|
271
|
+
- default_metadata/component/content.json
|
270
272
|
- default_metadata/component/date.json
|
271
273
|
- default_metadata/component/number.json
|
272
274
|
- default_metadata/component/radios.json
|
@@ -278,6 +280,7 @@ files:
|
|
278
280
|
- default_metadata/definition/radio.json
|
279
281
|
- default_metadata/page/checkanswers.json
|
280
282
|
- default_metadata/page/confirmation.json
|
283
|
+
- default_metadata/page/multiplequestions.json
|
281
284
|
- default_metadata/page/singlequestion.json
|
282
285
|
- default_metadata/page/start.json
|
283
286
|
- default_metadata/service/base.json
|
@@ -295,6 +298,7 @@ files:
|
|
295
298
|
- lib/metadata_presenter/version.rb
|
296
299
|
- lib/tasks/metadata_presenter_tasks.rake
|
297
300
|
- schemas/component/checkboxes.json
|
301
|
+
- schemas/component/content.json
|
298
302
|
- schemas/component/date.json
|
299
303
|
- schemas/component/number.json
|
300
304
|
- schemas/component/radios.json
|
@@ -342,6 +346,7 @@ files:
|
|
342
346
|
- schemas/link/link.json
|
343
347
|
- schemas/page/checkanswers.json
|
344
348
|
- schemas/page/confirmation.json
|
349
|
+
- schemas/page/multiplequestions.json
|
345
350
|
- schemas/page/singlequestion.json
|
346
351
|
- schemas/page/start.json
|
347
352
|
- schemas/request/service.json
|