metadata_presenter 0.20.0 → 0.21.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/helpers/metadata_presenter/application_helper.rb +2 -8
- data/app/models/metadata_presenter/component.rb +4 -0
- data/app/presenters/metadata_presenter/page_answers_presenter.rb +6 -1
- data/app/views/metadata_presenter/component/_components.html.erb +20 -0
- data/app/views/metadata_presenter/page/checkanswers.html.erb +8 -4
- data/app/views/metadata_presenter/page/confirmation.html.erb +8 -0
- data/app/views/metadata_presenter/page/content.html.erb +7 -13
- data/app/views/metadata_presenter/page/multiplequestions.html.erb +7 -11
- data/default_metadata/page/confirmation.json +2 -1
- data/fixtures/version.json +23 -5
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/page/checkanswers.json +8 -10
- data/schemas/page/confirmation.json +8 -0
- data/schemas/page/content.json +8 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca4bd2a3c36d8d5c7c21cf4105aacb4b5cdd5e347a976c7a83d21dc473b35a86
|
4
|
+
data.tar.gz: eb4131ac71104e5c62772cf0a93176156eb946d7d968c1c1e36a92e9e2a5ad36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '068e67ec41b9add6e7d9629656dc0a3d39ed32ec0b374ba01599a0b29ec275db7296ebfd120eecd428d13c403cf4edb25a7843f3beba362004e723c74f75dd79'
|
7
|
+
data.tar.gz: 85c7e4caf55464ec1f95f85519f90aabd16c9324889daed683617736a5f54034645dc302248690ccdcd21ba908f4f930d06d421e70a1594e2fe48bb43658b68b
|
@@ -1,14 +1,8 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
module ApplicationHelper
|
3
3
|
def main_title(component:, tag: :h1, classes: 'govuk-heading-xl')
|
4
|
-
|
5
|
-
|
6
|
-
component.legend
|
7
|
-
end
|
8
|
-
else
|
9
|
-
content_tag(tag, class: classes) do
|
10
|
-
component.label
|
11
|
-
end
|
4
|
+
content_tag(tag, class: classes) do
|
5
|
+
component.humanised_title
|
12
6
|
end
|
13
7
|
end
|
14
8
|
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
class PageAnswersPresenter
|
3
3
|
FIRST_ANSWER = 0.freeze
|
4
|
+
NO_USER_INPUT = %w(page.checkanswers page.confirmation page.content).freeze
|
4
5
|
|
5
6
|
def self.map(view:, pages:, answers:)
|
6
|
-
pages.map do |page|
|
7
|
+
user_input_pages(pages).map do |page|
|
7
8
|
Array(page.components).map do |component|
|
8
9
|
new(
|
9
10
|
view: view,
|
@@ -15,6 +16,10 @@ module MetadataPresenter
|
|
15
16
|
end.reject { |page| page.empty? }
|
16
17
|
end
|
17
18
|
|
19
|
+
def self.user_input_pages(pages)
|
20
|
+
pages.reject { |page| page.type.in?(NO_USER_INPUT) }
|
21
|
+
end
|
22
|
+
|
18
23
|
attr_reader :view, :component, :page, :answers
|
19
24
|
delegate :url, to: :page
|
20
25
|
delegate :humanised_title, to: :component
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<% @page.components.each_with_index do |component, index| %>
|
2
|
+
<div class="fb-editable"
|
3
|
+
id="<%= component.id %>"
|
4
|
+
data-fb-content-type="<%= component.type %>"
|
5
|
+
data-fb-content-id="<%= "page[components[#{index}]]" %>"
|
6
|
+
data-fb-content-data="<%= component.to_json %>">
|
7
|
+
|
8
|
+
<%= render partial: component, locals: {
|
9
|
+
f: f,
|
10
|
+
component: component,
|
11
|
+
component_id: "page[components[#{index}]]",
|
12
|
+
input_title: main_title(
|
13
|
+
component: component,
|
14
|
+
tag: :h2,
|
15
|
+
classes: classes
|
16
|
+
)
|
17
|
+
}
|
18
|
+
%>
|
19
|
+
</div>
|
20
|
+
<% end %>
|
@@ -11,10 +11,6 @@
|
|
11
11
|
</h1>
|
12
12
|
<% end %>
|
13
13
|
|
14
|
-
<%= render 'metadata_presenter/attribute/lede' %>
|
15
|
-
|
16
|
-
<%= render 'metadata_presenter/attribute/body' %>
|
17
|
-
|
18
14
|
<%= form_for @page, url: reserved_submissions_path do |f| %>
|
19
15
|
<div data-block-id="page.checkanswers.answers" data-block-type="answers">
|
20
16
|
<dl class="fb-block fb-block-answers govuk-summary-list">
|
@@ -68,6 +64,14 @@
|
|
68
64
|
</div>
|
69
65
|
<% end %>
|
70
66
|
|
67
|
+
<%= render partial: 'metadata_presenter/component/components',
|
68
|
+
locals: {
|
69
|
+
f: f,
|
70
|
+
components: @page.components,
|
71
|
+
tag: nil,
|
72
|
+
classes: nil
|
73
|
+
} %>
|
74
|
+
|
71
75
|
<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">
|
72
76
|
Accept and send application
|
73
77
|
</button>
|
@@ -17,20 +17,14 @@
|
|
17
17
|
<%= render 'metadata_presenter/attribute/body' %>
|
18
18
|
|
19
19
|
<%= form_for @page_answers, as: :answers, url: @page.url, method: :post do |f| %>
|
20
|
-
<%= f.govuk_error_summary %>
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
f: f,
|
30
|
-
input_title: main_title(component: component) }
|
31
|
-
%>
|
32
|
-
</div>
|
33
|
-
<% end %>
|
21
|
+
<%= render partial: 'metadata_presenter/component/components',
|
22
|
+
locals: {
|
23
|
+
f: f,
|
24
|
+
components: @page.components,
|
25
|
+
tag: nil,
|
26
|
+
classes: nil
|
27
|
+
} %>
|
34
28
|
|
35
29
|
<%= f.govuk_submit(disabled: editable?) %>
|
36
30
|
<% end %>
|
@@ -8,18 +8,14 @@
|
|
8
8
|
|
9
9
|
<%= form_for @page_answers, as: :answers, url: @page.url, method: :post do |f| %>
|
10
10
|
<%= f.govuk_error_summary %>
|
11
|
-
|
12
|
-
|
13
|
-
component: component,
|
14
|
-
component_id: "page[components[#{index}]]",
|
11
|
+
|
12
|
+
<%= render partial: 'metadata_presenter/component/components', locals: {
|
15
13
|
f: f,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
%>
|
22
|
-
<% end %>
|
14
|
+
components: @page.components,
|
15
|
+
tag: :h2,
|
16
|
+
classes: 'govuk-heading-m govuk-!-margin-top-8'
|
17
|
+
}
|
18
|
+
%>
|
23
19
|
|
24
20
|
<%= f.govuk_submit(disabled: editable?) %>
|
25
21
|
<% end %>
|
data/fixtures/version.json
CHANGED
@@ -326,20 +326,31 @@
|
|
326
326
|
"section_heading": "Chain of Command",
|
327
327
|
"heading": "Tell me how many lights you see",
|
328
328
|
"body": "There are four lights!",
|
329
|
-
"components": [
|
329
|
+
"components": [
|
330
|
+
{
|
331
|
+
"_id": "how-many-lights_content_1",
|
332
|
+
"_type": "content",
|
333
|
+
"html": "What lights?"
|
334
|
+
}
|
335
|
+
],
|
330
336
|
"url": "how-many-lights"
|
331
337
|
},
|
332
338
|
{
|
333
339
|
"_uuid": "e819d0c2-7062-4997-89cf-44d26d098404",
|
334
340
|
"_id": "page._check-answers",
|
335
341
|
"_type": "page.checkanswers",
|
336
|
-
"body": "Optional content",
|
337
342
|
"heading": "Review your answer",
|
338
|
-
"lede": "First paragraph",
|
339
343
|
"section_heading": "This section is optional",
|
340
344
|
"send_body": "By submitting this answer you confirm all your answers",
|
341
345
|
"send_heading": "Send your answer",
|
342
|
-
"url": "/check-answers"
|
346
|
+
"url": "/check-answers",
|
347
|
+
"components": [
|
348
|
+
{
|
349
|
+
"_id": "check-answers_content_1",
|
350
|
+
"_type": "content",
|
351
|
+
"html": "Check yourself before you wreck yourself."
|
352
|
+
}
|
353
|
+
]
|
343
354
|
},
|
344
355
|
{
|
345
356
|
"_uuid": "b238a22f-c180-48d0-a7d9-8aad2036f1f2",
|
@@ -348,7 +359,14 @@
|
|
348
359
|
"body": "You'll receive a confirmation email",
|
349
360
|
"heading": "Complaint sent",
|
350
361
|
"lede": "Optional lede",
|
351
|
-
"url": "/confirmation"
|
362
|
+
"url": "/confirmation",
|
363
|
+
"components": [
|
364
|
+
{
|
365
|
+
"_id": "confirmation_content_1",
|
366
|
+
"_type": "content",
|
367
|
+
"html": "Some day I will be the most powerful Jedi ever!"
|
368
|
+
}
|
369
|
+
]
|
352
370
|
}
|
353
371
|
],
|
354
372
|
"locale": "en"
|
@@ -17,16 +17,6 @@
|
|
17
17
|
"type": "string",
|
18
18
|
"default": "Check your answers"
|
19
19
|
},
|
20
|
-
"lede": {
|
21
|
-
"title": "Lede",
|
22
|
-
"type": "string",
|
23
|
-
"description": "Content before the body"
|
24
|
-
},
|
25
|
-
"body": {
|
26
|
-
"title": "Body",
|
27
|
-
"type": "string",
|
28
|
-
"description": "Optional content before showing the summary"
|
29
|
-
},
|
30
20
|
"summary_of": {
|
31
21
|
"title": "Summary of",
|
32
22
|
"description": "Page/section that summary summarises"
|
@@ -45,6 +35,14 @@
|
|
45
35
|
"content": true,
|
46
36
|
"multiline": true,
|
47
37
|
"default": "By submitting this application you confirm that, to the best of your knowledge, the details you are providing are correct."
|
38
|
+
},
|
39
|
+
"components": {
|
40
|
+
"title": "Components",
|
41
|
+
"description": "The form or content elements used on the page",
|
42
|
+
"type": "array",
|
43
|
+
"items": {
|
44
|
+
"$ref": "component.content"
|
45
|
+
}
|
48
46
|
}
|
49
47
|
},
|
50
48
|
"required": [
|
@@ -19,6 +19,14 @@
|
|
19
19
|
},
|
20
20
|
"lede": {
|
21
21
|
"multiline": true
|
22
|
+
},
|
23
|
+
"components": {
|
24
|
+
"title": "Components",
|
25
|
+
"description": "The form or content elements used on the page",
|
26
|
+
"type": "array",
|
27
|
+
"items": {
|
28
|
+
"$ref": "component.content"
|
29
|
+
}
|
22
30
|
}
|
23
31
|
},
|
24
32
|
"required": [
|
data/schemas/page/content.json
CHANGED
@@ -7,6 +7,14 @@
|
|
7
7
|
"properties": {
|
8
8
|
"_type": {
|
9
9
|
"const": "page.content"
|
10
|
+
},
|
11
|
+
"components": {
|
12
|
+
"title": "Components",
|
13
|
+
"description": "The form or content elements used on the page",
|
14
|
+
"type": "array",
|
15
|
+
"items": {
|
16
|
+
"$ref": "component.content"
|
17
|
+
}
|
10
18
|
}
|
11
19
|
},
|
12
20
|
"allOf": [
|
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.21.0
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- app/views/metadata_presenter/attribute/_lede.html.erb
|
257
257
|
- app/views/metadata_presenter/attribute/_section_heading.html.erb
|
258
258
|
- app/views/metadata_presenter/component/_checkboxes.html.erb
|
259
|
+
- app/views/metadata_presenter/component/_components.html.erb
|
259
260
|
- app/views/metadata_presenter/component/_content.html.erb
|
260
261
|
- app/views/metadata_presenter/component/_date.html.erb
|
261
262
|
- app/views/metadata_presenter/component/_number.html.erb
|