metadata_presenter 0.23.0 → 0.27.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 +3 -4
- data/app/models/metadata_presenter/page.rb +26 -0
- data/app/views/metadata_presenter/attribute/_body.html.erb +1 -1
- data/app/views/metadata_presenter/component/_content.html.erb +1 -1
- data/app/views/metadata_presenter/page/checkanswers.html.erb +14 -1
- data/app/views/metadata_presenter/page/confirmation.html.erb +3 -1
- data/app/views/metadata_presenter/page/content.html.erb +3 -1
- data/app/views/metadata_presenter/page/form.html.erb +1 -1
- data/app/views/metadata_presenter/page/multiplequestions.html.erb +3 -1
- data/app/views/metadata_presenter/page/start.html.erb +1 -1
- data/config/initializers/page_components.rb +19 -0
- data/default_metadata/component/content.json +1 -1
- data/default_metadata/page/checkanswers.json +2 -1
- data/default_text/content.json +1 -1
- data/fixtures/version.json +10 -9
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/component/content.json +2 -2
- data/schemas/page/checkanswers.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: 4048587e07e7a5b2b4919a71d0183200b3f88068377b284a307ad917d1a30add
|
4
|
+
data.tar.gz: 4fb293d2eb67132d9f68b8da4f142847864d748a8a3e4dd1bb93151b327aab0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4110ca082033d1bbdbe271b70942c37b6bb0424d4202874e3016ab96c85d226bb8da432bdc63079918cd544ada93d869add4b45e2d961bf9c0272fc5ba4969ff
|
7
|
+
data.tar.gz: 146b09fa25fc4305b3193b0a932bff1b6846b4d8cf8bf55246b0fc5c01df55b7de41cb701d12f74aab38e365045edb0fd489a78175f7728ef967c363f81084df
|
@@ -6,15 +6,14 @@ module MetadataPresenter
|
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
|
-
# Renders
|
9
|
+
# Renders html given markdown.
|
10
10
|
#
|
11
11
|
# @example
|
12
|
-
# <%=
|
12
|
+
# <%=to_html '# Some markdown' %>
|
13
13
|
#
|
14
|
-
def
|
14
|
+
def to_html(text)
|
15
15
|
Kramdown::Document.new(text).to_html.html_safe
|
16
16
|
end
|
17
|
-
alias_method :to_markdown, :m
|
18
17
|
|
19
18
|
def default_text(property)
|
20
19
|
MetadataPresenter::DefaultText[property]
|
@@ -1,4 +1,7 @@
|
|
1
1
|
module MetadataPresenter
|
2
|
+
class PageComponentsNotDefinedError < StandardError
|
3
|
+
end
|
4
|
+
|
2
5
|
class Page < MetadataPresenter::Metadata
|
3
6
|
include ActiveModel::Validations
|
4
7
|
|
@@ -27,5 +30,28 @@ module MetadataPresenter
|
|
27
30
|
def template
|
28
31
|
"metadata_presenter/#{type.gsub('.', '/')}"
|
29
32
|
end
|
33
|
+
|
34
|
+
def input_components
|
35
|
+
page_components(raw_type)[:input_components]
|
36
|
+
end
|
37
|
+
|
38
|
+
def content_components
|
39
|
+
page_components(raw_type)[:content_components]
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def page_components(page_type)
|
45
|
+
values = Rails.application.config.page_components[page_type]
|
46
|
+
if values.blank?
|
47
|
+
raise PageComponentsNotDefinedError, "No page components defined for #{page_type} in config initialiser"
|
48
|
+
end
|
49
|
+
|
50
|
+
values
|
51
|
+
end
|
52
|
+
|
53
|
+
def raw_type
|
54
|
+
type.gsub('page.', '')
|
55
|
+
end
|
30
56
|
end
|
31
57
|
end
|
@@ -1 +1 @@
|
|
1
|
-
<%=
|
1
|
+
<%= to_html(component.content) %>
|
@@ -12,6 +12,17 @@
|
|
12
12
|
<% end %>
|
13
13
|
|
14
14
|
<%= form_for @page, url: reserved_submissions_path do |f| %>
|
15
|
+
|
16
|
+
<%= render partial: 'metadata_presenter/component/components',
|
17
|
+
locals: {
|
18
|
+
f: f,
|
19
|
+
components: @page.extra_components,
|
20
|
+
tag: nil,
|
21
|
+
classes: nil,
|
22
|
+
input_components: @page.input_components,
|
23
|
+
content_components: @page.content_components
|
24
|
+
} %>
|
25
|
+
|
15
26
|
<div data-block-id="page.checkanswers.answers" data-block-type="answers">
|
16
27
|
<dl class="fb-block fb-block-answers govuk-summary-list">
|
17
28
|
<% pages_presenters.each do |page_answers_presenters| %>
|
@@ -69,7 +80,9 @@
|
|
69
80
|
f: f,
|
70
81
|
components: @page.components,
|
71
82
|
tag: nil,
|
72
|
-
classes: nil
|
83
|
+
classes: nil,
|
84
|
+
input_components: @page.input_components,
|
85
|
+
content_components: @page.content_components
|
73
86
|
} %>
|
74
87
|
|
75
88
|
<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">
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<div class="govuk-grid-column-two-thirds">
|
4
4
|
<% if @page.body %>
|
5
5
|
<p class="govuk-body-l" data-block-id="<%= @page.id %>" data-block-property="body">
|
6
|
-
<%=
|
6
|
+
<%= to_html(@page.body) %>
|
7
7
|
</p>
|
8
8
|
<%- end %>
|
9
9
|
<%= form_tag(reserved_answers_path, method: :post) do %>
|
@@ -12,7 +12,9 @@
|
|
12
12
|
f: f,
|
13
13
|
components: @page.components,
|
14
14
|
tag: :h2,
|
15
|
-
classes: 'govuk-heading-m govuk-!-margin-top-8'
|
15
|
+
classes: 'govuk-heading-m govuk-!-margin-top-8',
|
16
|
+
input_components: @page.input_components,
|
17
|
+
content_components: @page.content_components
|
16
18
|
}
|
17
19
|
%>
|
18
20
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Rails.application.config.page_components =
|
2
|
+
ActiveSupport::HashWithIndifferentAccess.new({
|
3
|
+
checkanswers: {
|
4
|
+
input_components: %w(),
|
5
|
+
content_components: %w(content)
|
6
|
+
},
|
7
|
+
confirmation: {
|
8
|
+
input_components: %w(),
|
9
|
+
content_components: %w(content)
|
10
|
+
},
|
11
|
+
content: {
|
12
|
+
input_components: %w(),
|
13
|
+
content_components: %w(content)
|
14
|
+
},
|
15
|
+
multiplequestions: {
|
16
|
+
input_components: %w(text textarea number date radios checkboxes),
|
17
|
+
content_components: %w(content)
|
18
|
+
}
|
19
|
+
})
|
@@ -4,5 +4,6 @@
|
|
4
4
|
"heading": "Check your answers",
|
5
5
|
"send_heading": "Now send your application",
|
6
6
|
"send_body": "By submitting this application you confirm that, to the best of your knowledge, the details you are providing are correct.",
|
7
|
-
"components": []
|
7
|
+
"components": [],
|
8
|
+
"extra_components": []
|
8
9
|
}
|
data/default_text/content.json
CHANGED
data/fixtures/version.json
CHANGED
@@ -178,14 +178,14 @@
|
|
178
178
|
"legend": "Do you like Star Wars?",
|
179
179
|
"items": [
|
180
180
|
{
|
181
|
-
"_id": "do-you-like-star-
|
181
|
+
"_id": "do-you-like-star-wars_radios_1_item_1",
|
182
182
|
"_type": "radio",
|
183
183
|
"label": "Only on weekends",
|
184
184
|
"hint": "Optional item hint",
|
185
185
|
"value": "only-on-weekends"
|
186
186
|
},
|
187
187
|
{
|
188
|
-
"_id": "do-you-like-star-
|
188
|
+
"_id": "do-you-like-star-wars_radios_1_item_2",
|
189
189
|
"_type": "radio",
|
190
190
|
"label": "Hell no!",
|
191
191
|
"hint": "Optional item hint",
|
@@ -236,21 +236,21 @@
|
|
236
236
|
"legend": "What would you like on your burger?",
|
237
237
|
"items": [
|
238
238
|
{
|
239
|
-
"_id": "
|
239
|
+
"_id": "burgers_checkboxes_1_item_1",
|
240
240
|
"_type": "checkbox",
|
241
241
|
"label": "Beef, cheese, tomato",
|
242
242
|
"hint": "Optional item hint",
|
243
243
|
"value": "beef-cheese-tomato"
|
244
244
|
},
|
245
245
|
{
|
246
|
-
"_id": "
|
246
|
+
"_id": "burgers_checkboxes_1_item_2",
|
247
247
|
"_type": "checkbox",
|
248
248
|
"label": "Chicken, cheese, tomato",
|
249
249
|
"hint": "Optional item hint",
|
250
250
|
"value": "chicken-cheese-tomato"
|
251
251
|
},
|
252
252
|
{
|
253
|
-
"_id": "
|
253
|
+
"_id": "burgers_checkboxes_1_item_3",
|
254
254
|
"_type": "checkbox",
|
255
255
|
"label": "Mozzarella, cheddar, feta",
|
256
256
|
"hint": "Optional item hint",
|
@@ -330,7 +330,7 @@
|
|
330
330
|
{
|
331
331
|
"_id": "how-many-lights_content_1",
|
332
332
|
"_type": "content",
|
333
|
-
"
|
333
|
+
"content": "What lights?"
|
334
334
|
}
|
335
335
|
],
|
336
336
|
"url": "how-many-lights"
|
@@ -348,9 +348,10 @@
|
|
348
348
|
{
|
349
349
|
"_id": "check-answers_content_1",
|
350
350
|
"_type": "content",
|
351
|
-
"
|
351
|
+
"content": "Check yourself before you wreck yourself."
|
352
352
|
}
|
353
|
-
]
|
353
|
+
],
|
354
|
+
"extra_components": []
|
354
355
|
},
|
355
356
|
{
|
356
357
|
"_uuid": "b238a22f-c180-48d0-a7d9-8aad2036f1f2",
|
@@ -364,7 +365,7 @@
|
|
364
365
|
{
|
365
366
|
"_id": "confirmation_content_1",
|
366
367
|
"_type": "content",
|
367
|
-
"
|
368
|
+
"content": "Some day I will be the most powerful Jedi ever!"
|
368
369
|
}
|
369
370
|
]
|
370
371
|
}
|
@@ -11,7 +11,7 @@
|
|
11
11
|
"_type": {
|
12
12
|
"const": "content"
|
13
13
|
},
|
14
|
-
"
|
14
|
+
"content": {
|
15
15
|
"title": "Content",
|
16
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
17
|
"type": "string",
|
@@ -25,6 +25,6 @@
|
|
25
25
|
}
|
26
26
|
],
|
27
27
|
"required": [
|
28
|
-
"
|
28
|
+
"content"
|
29
29
|
]
|
30
30
|
}
|
@@ -43,6 +43,14 @@
|
|
43
43
|
"items": {
|
44
44
|
"$ref": "component.content"
|
45
45
|
}
|
46
|
+
},
|
47
|
+
"extra_components": {
|
48
|
+
"title": "Extra Components",
|
49
|
+
"description": "More form or content elements used on the page",
|
50
|
+
"type": "array",
|
51
|
+
"items": {
|
52
|
+
"$ref": "component.content"
|
53
|
+
}
|
46
54
|
}
|
47
55
|
},
|
48
56
|
"required": [
|
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.27.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-
|
11
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: govuk_design_system_formbuilder
|
@@ -303,6 +303,7 @@ files:
|
|
303
303
|
- app/views/metadata_presenter/page/start.html.erb
|
304
304
|
- config/initializers/default_metadata.rb
|
305
305
|
- config/initializers/default_text.rb
|
306
|
+
- config/initializers/page_components.rb
|
306
307
|
- config/initializers/schemas.rb
|
307
308
|
- config/routes.rb
|
308
309
|
- default_metadata/component/checkboxes.json
|