metadata_presenter 0.6.0 → 0.8.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/validators/metadata_presenter/base_validator.rb +6 -0
- data/app/validators/metadata_presenter/max_length_validator.rb +1 -1
- data/app/validators/metadata_presenter/min_length_validator.rb +1 -1
- data/app/validators/metadata_presenter/number_validator.rb +7 -0
- data/app/validators/metadata_presenter/required_validator.rb +1 -1
- data/app/views/layouts/metadata_presenter/application.html.erb +1 -1
- data/app/views/metadata_presenter/component/_number.html.erb +8 -0
- data/config/routes.rb +3 -1
- data/default_metadata/component/number.json +12 -0
- data/default_metadata/component/radios.json +10 -0
- data/default_metadata/definition/radio.json +6 -0
- data/default_metadata/string/error.number.json +6 -0
- data/fixtures/version.json +53 -0
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/component/number.json +29 -0
- data/schemas/component/radios.json +37 -0
- data/schemas/{text → component}/text.json +1 -1
- data/schemas/{textarea → component}/textarea.json +2 -2
- data/schemas/definition/conditionalcomponent.json +12 -0
- data/schemas/definition/fieldset.json +37 -0
- data/schemas/definition/grouping.json +27 -0
- data/schemas/definition/option.json +35 -0
- data/schemas/definition/radio.json +30 -0
- data/schemas/{definition/page.singlequestion.json → page/singlequestion.json} +0 -0
- metadata +18 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02defe01ddba9dd12933b6fbd7bc9d87dde76b844ad279fb904f30fef50d0631
|
4
|
+
data.tar.gz: 88b97e4610d868cc64040291d45bc0295f3a2345d52667b4ebd29f1efac742d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec1ae9e71d6a01265aab982505136f6a08ef614c0b90f72680ae80358bbb4af0819648990f16c16963c498784c93acec8e831a2cb6a92eff9fe07ff9fbcfbfcc
|
7
|
+
data.tar.gz: 96a35c0e8ed4bc4bcb4d69375ae3816174a71f1afacbce4797e2d8e18f484344484f7e6cded39d93efa35ba439b27a1949a4c738a2d57cbf6d13c3dfe0980d18
|
@@ -62,6 +62,12 @@ module MetadataPresenter
|
|
62
62
|
message % error_message_hash if message.present?
|
63
63
|
end
|
64
64
|
|
65
|
+
# @return [String] user answer for the specific component
|
66
|
+
#
|
67
|
+
def user_answer
|
68
|
+
answers[component.name]
|
69
|
+
end
|
70
|
+
|
65
71
|
# The default error message will be look using the schema key.
|
66
72
|
# Assuming the schema key is 'grogu' then the default message
|
67
73
|
# will look for 'error.grogu.value'.
|
@@ -14,7 +14,6 @@
|
|
14
14
|
|
15
15
|
<%= stylesheet_pack_tag 'govuk' %>
|
16
16
|
<%= stylesheet_link_tag 'application', media: 'all' %>
|
17
|
-
<%= javascript_pack_tag 'application' %>
|
18
17
|
</head>
|
19
18
|
|
20
19
|
<body class="govuk-template__body">
|
@@ -28,6 +27,7 @@
|
|
28
27
|
<%= yield %>
|
29
28
|
</main>
|
30
29
|
</div>
|
30
|
+
<%= javascript_pack_tag 'application' %>
|
31
31
|
<%= javascript_pack_tag 'govuk' %>
|
32
32
|
</body>
|
33
33
|
</html>
|
data/config/routes.rb
CHANGED
@@ -6,5 +6,7 @@ MetadataPresenter::Engine.routes.draw do
|
|
6
6
|
|
7
7
|
post '/', to: 'answers#create'
|
8
8
|
match '*path', to: 'answers#create', via: :post
|
9
|
-
match '*path', to: 'pages#show',
|
9
|
+
match '*path', to: 'pages#show',
|
10
|
+
via: :all,
|
11
|
+
constraints: lambda {|req| req.path !~ /\.(png|jpg|js|css|ico)$/ }
|
10
12
|
end
|
data/fixtures/version.json
CHANGED
@@ -124,6 +124,28 @@
|
|
124
124
|
"heading": "Parent name",
|
125
125
|
"url": "/parent-name"
|
126
126
|
},
|
127
|
+
{
|
128
|
+
"_id": "page.your_age",
|
129
|
+
"url": "your-age",
|
130
|
+
"_type":"page.singlequestion",
|
131
|
+
"_uuid":"59d1326c-32e6-45e9-b57a-bcc8e2fb6b2c",
|
132
|
+
"heading":"Your age",
|
133
|
+
"components": [
|
134
|
+
{
|
135
|
+
"_id": "your_age_number_1",
|
136
|
+
"hint": "Component hint",
|
137
|
+
"name": "your_age_number_1",
|
138
|
+
"_type": "number",
|
139
|
+
"label": "Your age",
|
140
|
+
"errors": {},
|
141
|
+
"validation": {
|
142
|
+
"required": true,
|
143
|
+
"number": true
|
144
|
+
},
|
145
|
+
"width_class_input": "10"
|
146
|
+
}
|
147
|
+
]
|
148
|
+
},
|
127
149
|
{
|
128
150
|
"_uuid": "7b748584-100e-4d81-a54a-5049190136cc",
|
129
151
|
"_id": "page.family_hobbies",
|
@@ -143,6 +165,37 @@
|
|
143
165
|
"heading": "Family Hobbies",
|
144
166
|
"url": "/family-hobbies"
|
145
167
|
},
|
168
|
+
{
|
169
|
+
"_uuid": "4251b25e-08de-4dcb-8f2f-dd9848dcdca6",
|
170
|
+
"_id": "page.radio-buttons",
|
171
|
+
"_type": "page.singlequestion",
|
172
|
+
"components": [
|
173
|
+
{
|
174
|
+
"_id": "radio-buttons_radios_1",
|
175
|
+
"_type": "radios",
|
176
|
+
"errors": {},
|
177
|
+
"hint": "Component hint",
|
178
|
+
"label": "Component label",
|
179
|
+
"items": [
|
180
|
+
{
|
181
|
+
"_id": "radio-buttons_radio_1",
|
182
|
+
"_type": "radio",
|
183
|
+
"label": "Yes",
|
184
|
+
"value": "radio_value_1"
|
185
|
+
},
|
186
|
+
{
|
187
|
+
"_id": "radio-buttons_radio_2",
|
188
|
+
"_type": "radio",
|
189
|
+
"label": "No",
|
190
|
+
"value": "radio_value_2"
|
191
|
+
}
|
192
|
+
],
|
193
|
+
"name": "radio-buttons_radios_1"
|
194
|
+
}
|
195
|
+
],
|
196
|
+
"heading": "Parent name",
|
197
|
+
"url": "/radio-buttons"
|
198
|
+
},
|
146
199
|
{
|
147
200
|
"_uuid": "e819d0c2-7062-4997-89cf-44d26d098404",
|
148
201
|
"_id": "page._check-answers",
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/number",
|
3
|
+
"_name": "component.number",
|
4
|
+
"title": "Number",
|
5
|
+
"description": "Let users enter a number",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"_type": {
|
9
|
+
"const": "number"
|
10
|
+
},
|
11
|
+
"name": {
|
12
|
+
"inputType": "number"
|
13
|
+
},
|
14
|
+
"width_class_input": {
|
15
|
+
"default": "10"
|
16
|
+
}
|
17
|
+
},
|
18
|
+
"allOf": [
|
19
|
+
{
|
20
|
+
"$ref": "definition.field"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"$ref": "validations#/definitions/number_bundle"
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"$ref": "definition.width_class.input"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/radios",
|
3
|
+
"_name": "component.radios",
|
4
|
+
"title": "Radios",
|
5
|
+
"description": "Let users select one option from a list",
|
6
|
+
"type": "object",
|
7
|
+
"properties": {
|
8
|
+
"_type": {
|
9
|
+
"const": "radios"
|
10
|
+
},
|
11
|
+
"items": {
|
12
|
+
"title": "Options",
|
13
|
+
"description": "Items that users can select",
|
14
|
+
"type": "array",
|
15
|
+
"items": {
|
16
|
+
"$ref": "definition.radio"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"allOf": [
|
21
|
+
{
|
22
|
+
"$ref": "definition.fieldset"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"$ref": "definition.name"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"transforms": {
|
29
|
+
"namespace": {
|
30
|
+
"propagation": "items[*].conditional_component"
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"required": [
|
34
|
+
"name",
|
35
|
+
"items"
|
36
|
+
]
|
37
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/definition/conditionalcomponent",
|
3
|
+
"_name": "definition.conditionalcomponent",
|
4
|
+
"nestable": true,
|
5
|
+
"title": "Conditional component",
|
6
|
+
"description": "Component revealed when user chooses option",
|
7
|
+
"allOf": [
|
8
|
+
{
|
9
|
+
"$ref": "definition.component"
|
10
|
+
}
|
11
|
+
]
|
12
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/definition/fieldset",
|
3
|
+
"_name": "definition.fieldset",
|
4
|
+
"title": "Fieldset",
|
5
|
+
"description": "Group related form inputs",
|
6
|
+
"type": "object",
|
7
|
+
"category": [
|
8
|
+
"control",
|
9
|
+
"fieldset"
|
10
|
+
],
|
11
|
+
"properties": {
|
12
|
+
"_type": {
|
13
|
+
"const": "fieldset"
|
14
|
+
},
|
15
|
+
"legend": {
|
16
|
+
"title": "Legend",
|
17
|
+
"description": "Text to use in fieldset legend",
|
18
|
+
"type": "string"
|
19
|
+
},
|
20
|
+
"hint": {
|
21
|
+
"title": "Hint",
|
22
|
+
"description": "Text to help users answer a question - appears in grey under the legend",
|
23
|
+
"type": "string"
|
24
|
+
}
|
25
|
+
},
|
26
|
+
"allOf": [
|
27
|
+
{
|
28
|
+
"$ref": "definition.repeatable"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"$ref": "definition.grouping"
|
32
|
+
}
|
33
|
+
],
|
34
|
+
"required": [
|
35
|
+
"legend"
|
36
|
+
]
|
37
|
+
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/definition/grouping",
|
3
|
+
"_name": "definition.grouping",
|
4
|
+
"title": "Grouping definition",
|
5
|
+
"allOf": [
|
6
|
+
{
|
7
|
+
"$ref": "definition.component"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"$ref": "definition.components"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"$ref": "definition.namespace"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"$ref": "definition.html_attributes"
|
17
|
+
}
|
18
|
+
],
|
19
|
+
"category": [
|
20
|
+
"grouping"
|
21
|
+
],
|
22
|
+
"transforms": {
|
23
|
+
"namespace": {
|
24
|
+
"propagation": "components[?(@.$control || @.$grouping)]"
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/definition/option",
|
3
|
+
"_name": "definition.option",
|
4
|
+
"title": "Option definition",
|
5
|
+
"properties": {
|
6
|
+
"value": {
|
7
|
+
"title": "Option value",
|
8
|
+
"description": "Value captured by system when users choose this option",
|
9
|
+
"type": "string"
|
10
|
+
},
|
11
|
+
"hasDivider": {
|
12
|
+
"title": "Option divider",
|
13
|
+
"description": "Whether to display a textual divider before the option - defaults to ‘or’",
|
14
|
+
"type": "boolean"
|
15
|
+
}
|
16
|
+
},
|
17
|
+
"allOf": [
|
18
|
+
{
|
19
|
+
"$ref": "definition.block"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"$ref": "definition.label"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"$ref": "definition.namespace"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"required": [
|
29
|
+
"value"
|
30
|
+
],
|
31
|
+
"category": [
|
32
|
+
"component",
|
33
|
+
"option"
|
34
|
+
]
|
35
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/definition/radio",
|
3
|
+
"_name": "definition.radio",
|
4
|
+
"idSeed": "value",
|
5
|
+
"title": "Radio option",
|
6
|
+
"description": "Component that provides a radio option",
|
7
|
+
"type": "object",
|
8
|
+
"properties": {
|
9
|
+
"_type": {
|
10
|
+
"const": "radio"
|
11
|
+
},
|
12
|
+
"hint": {
|
13
|
+
"title": "Hint text",
|
14
|
+
"description": "Text to help users understand an option - appears in grey under the label",
|
15
|
+
"type": "string",
|
16
|
+
"content": true
|
17
|
+
},
|
18
|
+
"conditional_component": {
|
19
|
+
"$ref": "definition.conditionalcomponent"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"allOf": [
|
23
|
+
{
|
24
|
+
"$ref": "definition.option"
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"required": [
|
28
|
+
"label"
|
29
|
+
]
|
30
|
+
}
|
File without changes
|
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.8.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-02-
|
11
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -240,11 +240,13 @@ files:
|
|
240
240
|
- app/validators/metadata_presenter/base_validator.rb
|
241
241
|
- app/validators/metadata_presenter/max_length_validator.rb
|
242
242
|
- app/validators/metadata_presenter/min_length_validator.rb
|
243
|
+
- app/validators/metadata_presenter/number_validator.rb
|
243
244
|
- app/validators/metadata_presenter/required_validator.rb
|
244
245
|
- app/validators/metadata_presenter/validate_answers.rb
|
245
246
|
- app/validators/metadata_presenter/validate_schema.rb
|
246
247
|
- app/views/errors/404.html
|
247
248
|
- app/views/layouts/metadata_presenter/application.html.erb
|
249
|
+
- app/views/metadata_presenter/component/_number.html.erb
|
248
250
|
- app/views/metadata_presenter/component/_text.html.erb
|
249
251
|
- app/views/metadata_presenter/component/_textarea.html.erb
|
250
252
|
- app/views/metadata_presenter/header/show.html.erb
|
@@ -256,10 +258,13 @@ files:
|
|
256
258
|
- config/initializers/default_metadata.rb
|
257
259
|
- config/initializers/schemas.rb
|
258
260
|
- config/routes.rb
|
261
|
+
- default_metadata/component/number.json
|
262
|
+
- default_metadata/component/radios.json
|
259
263
|
- default_metadata/component/text.json
|
260
264
|
- default_metadata/component/textarea.json
|
261
265
|
- default_metadata/config/meta.json
|
262
266
|
- default_metadata/config/service.json
|
267
|
+
- default_metadata/definition/radio.json
|
263
268
|
- default_metadata/page/checkanswers.json
|
264
269
|
- default_metadata/page/confirmation.json
|
265
270
|
- default_metadata/page/singlequestion.json
|
@@ -267,6 +272,7 @@ files:
|
|
267
272
|
- default_metadata/service/base.json
|
268
273
|
- default_metadata/string/error.max_length.json
|
269
274
|
- default_metadata/string/error.min_length.json
|
275
|
+
- default_metadata/string/error.number.json
|
270
276
|
- default_metadata/string/error.required.json
|
271
277
|
- fixtures/non_finished_service.json
|
272
278
|
- fixtures/service.json
|
@@ -276,6 +282,10 @@ files:
|
|
276
282
|
- lib/metadata_presenter/test_helpers.rb
|
277
283
|
- lib/metadata_presenter/version.rb
|
278
284
|
- lib/tasks/metadata_presenter_tasks.rake
|
285
|
+
- schemas/component/number.json
|
286
|
+
- schemas/component/radios.json
|
287
|
+
- schemas/component/text.json
|
288
|
+
- schemas/component/textarea.json
|
279
289
|
- schemas/condition/condition.json
|
280
290
|
- schemas/config/meta.json
|
281
291
|
- schemas/config/service.json
|
@@ -290,22 +300,26 @@ files:
|
|
290
300
|
- schemas/definition/condition.text.json
|
291
301
|
- schemas/definition/condition.value_type.json
|
292
302
|
- schemas/definition/conditional.boolean.json
|
303
|
+
- schemas/definition/conditionalcomponent.json
|
293
304
|
- schemas/definition/conditions.all.json
|
294
305
|
- schemas/definition/conditions.any.json
|
295
306
|
- schemas/definition/conditions.exactly.json
|
296
307
|
- schemas/definition/control.json
|
297
308
|
- schemas/definition/data.json
|
298
309
|
- schemas/definition/field.json
|
310
|
+
- schemas/definition/fieldset.json
|
311
|
+
- schemas/definition/grouping.json
|
299
312
|
- schemas/definition/html_attributes.json
|
300
313
|
- schemas/definition/label.json
|
301
314
|
- schemas/definition/link_list.json
|
302
315
|
- schemas/definition/name.json
|
303
316
|
- schemas/definition/namespace.json
|
304
317
|
- schemas/definition/next_page.json
|
318
|
+
- schemas/definition/option.json
|
305
319
|
- schemas/definition/page.content.json
|
306
320
|
- schemas/definition/page.form.json
|
307
321
|
- schemas/definition/page.json
|
308
|
-
- schemas/definition/
|
322
|
+
- schemas/definition/radio.json
|
309
323
|
- schemas/definition/repeatable.json
|
310
324
|
- schemas/definition/width_class.input.json
|
311
325
|
- schemas/definition/width_class.json
|
@@ -313,13 +327,12 @@ files:
|
|
313
327
|
- schemas/link/link.json
|
314
328
|
- schemas/page/checkanswers.json
|
315
329
|
- schemas/page/confirmation.json
|
330
|
+
- schemas/page/singlequestion.json
|
316
331
|
- schemas/page/start.json
|
317
332
|
- schemas/request/service.json
|
318
333
|
- schemas/service/base.json
|
319
334
|
- schemas/service/configuration.json
|
320
335
|
- schemas/service/locale.json
|
321
|
-
- schemas/text/text.json
|
322
|
-
- schemas/textarea/textarea.json
|
323
336
|
- schemas/validations/validations.json
|
324
337
|
homepage: https://moj-online.service.justice.gov.uk
|
325
338
|
licenses:
|