metadata_presenter 0.12.0 → 0.13.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/metadata_presenter/engine_controller.rb +3 -1
- data/app/presenters/metadata_presenter/page_answers_presenter.rb +19 -8
- data/app/views/metadata_presenter/component/_checkboxes.html.erb +10 -0
- data/app/views/metadata_presenter/header/show.html.erb +1 -1
- data/default_metadata/component/checkboxes.json +24 -0
- data/default_metadata/component/radios.json +18 -3
- data/default_metadata/definition/checkbox.json +7 -0
- data/default_metadata/definition/radio.json +2 -1
- data/fixtures/version.json +43 -0
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/component/checkboxes.json +33 -0
- data/schemas/definition/checkbox.json +46 -0
- 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: de545a65e6ccee32e11d74efe9a5932294cbcb8b09a40cc63ad808f68fecd7c2
|
4
|
+
data.tar.gz: ba5459e1f91ae72bb860b8f1aa31cc5501240c60c9fa50fafee4da1af9f11f49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31704652aee121aee8686f5416facb56d950a7fcdd86a396aab43381647db1b5dc4ba763cc62d4ebb66f546da3413259416b44cf1a764cbccbcdf12fd98e6924
|
7
|
+
data.tar.gz: b8e3c60faa3d8085d6126c21e327ff9572699b1b651d15236ae4a16915059082bab167fb3a2f3e57238ff80c76888eb84861738764a111d6082ff62e1bd08d73
|
@@ -8,7 +8,9 @@ module MetadataPresenter
|
|
8
8
|
def back_link
|
9
9
|
return if @page.blank?
|
10
10
|
|
11
|
-
|
11
|
+
previous_page = service.previous_page(current_page: @page)&.url
|
12
|
+
|
13
|
+
@back_link ||= File.join(request.script_name, previous_page) if previous_page
|
12
14
|
end
|
13
15
|
helper_method :back_link
|
14
16
|
|
@@ -30,17 +30,28 @@ module MetadataPresenter
|
|
30
30
|
value = @page_answers.send(component.id)
|
31
31
|
|
32
32
|
return '' if value.blank?
|
33
|
-
|
34
|
-
|
35
|
-
I18n.l(
|
36
|
-
Date.civil(value.year.to_i, value.month.to_i, value.day.to_i),
|
37
|
-
format: '%d %B %Y'
|
38
|
-
)
|
39
|
-
elsif component.type == 'textarea'
|
40
|
-
view.simple_format(value)
|
33
|
+
if self.class.private_method_defined?(component.type.to_sym)
|
34
|
+
send(component.type.to_sym, value)
|
41
35
|
else
|
42
36
|
value
|
43
37
|
end
|
44
38
|
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def date(value)
|
43
|
+
I18n.l(
|
44
|
+
Date.civil(value.year.to_i, value.month.to_i, value.day.to_i),
|
45
|
+
format: '%d %B %Y'
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def textarea(value)
|
50
|
+
view.simple_format(value, {}, wrapper_tag: 'span')
|
51
|
+
end
|
52
|
+
|
53
|
+
def checkboxes(value)
|
54
|
+
value.join("<br>").html_safe
|
55
|
+
end
|
45
56
|
end
|
46
57
|
end
|
@@ -26,7 +26,7 @@
|
|
26
26
|
</div>
|
27
27
|
<% if service.service_name.present? %>
|
28
28
|
<div class="govuk-header__content">
|
29
|
-
<a href="
|
29
|
+
<a href="<%= root_path %>" class="govuk-header__link govuk-header__link--service-name">
|
30
30
|
<%= service.service_name %>
|
31
31
|
</a>
|
32
32
|
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"_id": "component.checkboxes",
|
3
|
+
"_type": "checkboxes",
|
4
|
+
"errors": {},
|
5
|
+
"hint": "[Hint text (optional)]",
|
6
|
+
"items": [
|
7
|
+
{
|
8
|
+
"_id": "component_checkbox_1",
|
9
|
+
"_type": "checkbox",
|
10
|
+
"label": "Option",
|
11
|
+
"hint": "[Hint text (optional)]",
|
12
|
+
"value": "value-1"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"_id": "component_checkbox_2",
|
16
|
+
"_type": "checkbox",
|
17
|
+
"label": "Option",
|
18
|
+
"hint": "[Hint text (optional)]",
|
19
|
+
"value": "value-2"
|
20
|
+
}
|
21
|
+
],
|
22
|
+
"name": "component-name",
|
23
|
+
"legend": "Question"
|
24
|
+
}
|
@@ -2,8 +2,23 @@
|
|
2
2
|
"_id": "component.radios",
|
3
3
|
"_type": "radios",
|
4
4
|
"errors": {},
|
5
|
-
"hint": "
|
6
|
-
"items": [
|
5
|
+
"hint": "[Hint text (optional)]",
|
6
|
+
"items": [
|
7
|
+
{
|
8
|
+
"_id": "component_radio_1",
|
9
|
+
"_type": "radio",
|
10
|
+
"label": "Option",
|
11
|
+
"hint": "[Hint text (optional)]",
|
12
|
+
"value": "value-1"
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"_id": "component_radio_2",
|
16
|
+
"_type": "radio",
|
17
|
+
"label": "Option",
|
18
|
+
"hint": "[Hint text (optional)]",
|
19
|
+
"value": "value-2"
|
20
|
+
}
|
21
|
+
],
|
7
22
|
"name": "component-name",
|
8
|
-
"legend": "
|
23
|
+
"legend": "Question"
|
9
24
|
}
|
data/fixtures/version.json
CHANGED
@@ -223,6 +223,49 @@
|
|
223
223
|
}
|
224
224
|
]
|
225
225
|
},
|
226
|
+
{
|
227
|
+
"_uuid": "7b748584-100e-4d81-a54a-5049190136cc",
|
228
|
+
"_id": "page.burgers",
|
229
|
+
"_type": "page.singlequestion",
|
230
|
+
"components": [
|
231
|
+
{
|
232
|
+
"_id": "burgers_checkboxes_1",
|
233
|
+
"_type": "checkboxes",
|
234
|
+
"errors": {},
|
235
|
+
"hint": "Select all that apply",
|
236
|
+
"legend": "What would you like on your burger?",
|
237
|
+
"items": [
|
238
|
+
{
|
239
|
+
"_id": "burgers_checkbox_1",
|
240
|
+
"_type": "checkbox",
|
241
|
+
"label": "Beef, cheese, tomato",
|
242
|
+
"hint": "Optional item hint",
|
243
|
+
"value": "beef-cheese-tomato"
|
244
|
+
},
|
245
|
+
{
|
246
|
+
"_id": "burgers_checkbox_2",
|
247
|
+
"_type": "checkbox",
|
248
|
+
"label": "Chicken, cheese, tomato",
|
249
|
+
"hint": "Optional item hint",
|
250
|
+
"value": "chicken-cheese-tomato"
|
251
|
+
},
|
252
|
+
{
|
253
|
+
"_id": "burgers_checkbox_3",
|
254
|
+
"_type": "checkbox",
|
255
|
+
"label": "Mozzarella, cheddar, feta",
|
256
|
+
"hint": "Optional item hint",
|
257
|
+
"value": "mozzarella-cheddar-feta"
|
258
|
+
}
|
259
|
+
],
|
260
|
+
"name": "burgers_checkboxes_1",
|
261
|
+
"validation": {
|
262
|
+
"required": true
|
263
|
+
}
|
264
|
+
}
|
265
|
+
],
|
266
|
+
"heading": "Checkboxes",
|
267
|
+
"url": "/burgers"
|
268
|
+
},
|
226
269
|
{
|
227
270
|
"_uuid": "e819d0c2-7062-4997-89cf-44d26d098404",
|
228
271
|
"_id": "page._check-answers",
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/checkboxes",
|
3
|
+
"_name": "component.checkboxes",
|
4
|
+
"title": "Checkboxes",
|
5
|
+
"description": "Let users select one or more options from a list",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"_type": {
|
9
|
+
"const": "checkboxes"
|
10
|
+
},
|
11
|
+
"items": {
|
12
|
+
"title": "Options",
|
13
|
+
"description": "Items that users can select",
|
14
|
+
"type": "array",
|
15
|
+
"items": {
|
16
|
+
"$ref": "definition.checkbox"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"allOf": [
|
21
|
+
{
|
22
|
+
"$ref": "definition.fieldset"
|
23
|
+
}
|
24
|
+
],
|
25
|
+
"transforms": {
|
26
|
+
"namespace": {
|
27
|
+
"propagation": "items[?(@._type === 'checkbox')]"
|
28
|
+
}
|
29
|
+
},
|
30
|
+
"required": [
|
31
|
+
"items"
|
32
|
+
]
|
33
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/checkbox",
|
3
|
+
"_name": "definition.checkbox",
|
4
|
+
"title": "Checkbox item",
|
5
|
+
"description": "Component that provides a checkbox item",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"_type": {
|
9
|
+
"const": "checkbox"
|
10
|
+
},
|
11
|
+
"value": {
|
12
|
+
"default": "yes"
|
13
|
+
},
|
14
|
+
"label": {
|
15
|
+
"skipOptional": true
|
16
|
+
},
|
17
|
+
"hint": {
|
18
|
+
"title": "Hint text",
|
19
|
+
"description": "Text to help users understand an option - appears in grey under the label",
|
20
|
+
"type": "string",
|
21
|
+
"content": true
|
22
|
+
},
|
23
|
+
"conditional_component": {
|
24
|
+
"$ref": "definition.conditionalcomponent"
|
25
|
+
}
|
26
|
+
},
|
27
|
+
"allOf": [
|
28
|
+
{
|
29
|
+
"$ref": "definition.namespace"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"$ref": "definition.option"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"$ref": "definition.name"
|
36
|
+
}
|
37
|
+
],
|
38
|
+
"required": [
|
39
|
+
"label"
|
40
|
+
],
|
41
|
+
"transforms": {
|
42
|
+
"namespace": {
|
43
|
+
"propagation": "conditional_component"
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
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.13.4
|
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-02-
|
11
|
+
date: 2021-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -250,6 +250,7 @@ files:
|
|
250
250
|
- app/validators/metadata_presenter/validate_schema.rb
|
251
251
|
- app/views/errors/404.html
|
252
252
|
- app/views/layouts/metadata_presenter/application.html.erb
|
253
|
+
- app/views/metadata_presenter/component/_checkboxes.html.erb
|
253
254
|
- app/views/metadata_presenter/component/_date.html.erb
|
254
255
|
- app/views/metadata_presenter/component/_number.html.erb
|
255
256
|
- app/views/metadata_presenter/component/_radios.html.erb
|
@@ -264,6 +265,7 @@ files:
|
|
264
265
|
- config/initializers/default_metadata.rb
|
265
266
|
- config/initializers/schemas.rb
|
266
267
|
- config/routes.rb
|
268
|
+
- default_metadata/component/checkboxes.json
|
267
269
|
- default_metadata/component/date.json
|
268
270
|
- default_metadata/component/number.json
|
269
271
|
- default_metadata/component/radios.json
|
@@ -271,6 +273,7 @@ files:
|
|
271
273
|
- default_metadata/component/textarea.json
|
272
274
|
- default_metadata/config/meta.json
|
273
275
|
- default_metadata/config/service.json
|
276
|
+
- default_metadata/definition/checkbox.json
|
274
277
|
- default_metadata/definition/radio.json
|
275
278
|
- default_metadata/page/checkanswers.json
|
276
279
|
- default_metadata/page/confirmation.json
|
@@ -290,6 +293,7 @@ files:
|
|
290
293
|
- lib/metadata_presenter/test_helpers.rb
|
291
294
|
- lib/metadata_presenter/version.rb
|
292
295
|
- lib/tasks/metadata_presenter_tasks.rake
|
296
|
+
- schemas/component/checkboxes.json
|
293
297
|
- schemas/component/date.json
|
294
298
|
- schemas/component/number.json
|
295
299
|
- schemas/component/radios.json
|
@@ -299,6 +303,7 @@ files:
|
|
299
303
|
- schemas/config/meta.json
|
300
304
|
- schemas/config/service.json
|
301
305
|
- schemas/definition/block.json
|
306
|
+
- schemas/definition/checkbox.json
|
302
307
|
- schemas/definition/component.json
|
303
308
|
- schemas/definition/components.json
|
304
309
|
- schemas/definition/condition.base.json
|