metadata_presenter 0.5.0 → 0.8.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 +8 -0
- 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/app/views/metadata_presenter/component/_textarea.html.erb +11 -0
- data/app/views/metadata_presenter/page/checkanswers.html.erb +1 -1
- data/app/views/metadata_presenter/page/start.html.erb +1 -1
- data/config/routes.rb +3 -1
- data/default_metadata/component/number.json +12 -0
- data/default_metadata/component/text.json +4 -1
- data/default_metadata/component/textarea.json +12 -0
- data/default_metadata/string/error.number.json +6 -0
- data/fixtures/version.json +41 -0
- data/lib/metadata_presenter/version.rb +1 -1
- data/schemas/component/number.json +29 -0
- data/schemas/{text → component}/text.json +1 -1
- data/schemas/component/textarea.json +55 -0
- data/schemas/{definition/page.singlequestion.json → page/singlequestion.json} +0 -0
- metadata +12 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 066133455b4cf94730e5bebe20ac439262cacd2128e3004d988035e822efc818
|
|
4
|
+
data.tar.gz: c4513e4dc197c1730ba538b2fc50f1c5302ad70c5a31d3377cb0a23f581fae33
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6a83357fac7381b7191f9c46edf93f4090be55e40491e06427f108430e5ee4069cc5d797da46d32f289d7785e05a02ae2808059eb7bf470b113bdbf56caf4b91
|
|
7
|
+
data.tar.gz: 31760a4dcedb66f45ac8be4bb93882d8278d58fcccf686f734dbf3dc0a762c09608cd54bf20718220ae2b8d0c7e3b47bd546a3f2edb9bf53aa30fe9e19703ca3
|
|
@@ -18,6 +18,14 @@ module MetadataPresenter
|
|
|
18
18
|
end
|
|
19
19
|
alias answer a
|
|
20
20
|
|
|
21
|
+
## Display user answers on the view formatted.
|
|
22
|
+
##
|
|
23
|
+
def formatted_answer(component_key)
|
|
24
|
+
user_answer = answer(component_key)
|
|
25
|
+
|
|
26
|
+
simple_format(user_answer) if user_answer.present?
|
|
27
|
+
end
|
|
28
|
+
|
|
21
29
|
# Renders markdown given a text.
|
|
22
30
|
#
|
|
23
31
|
# @example
|
|
@@ -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>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%=
|
|
2
|
+
f.govuk_text_area component.id.to_sym,
|
|
3
|
+
label: { text: component.label },
|
|
4
|
+
hint: { text: component.hint },
|
|
5
|
+
name: "answers[#{component.name}]",
|
|
6
|
+
value: answer(component.name),
|
|
7
|
+
max_chars: component.maxchars,
|
|
8
|
+
max_words: component.maxwords,
|
|
9
|
+
threshold: component.threshold,
|
|
10
|
+
rows: component.rows
|
|
11
|
+
%>
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
</p>
|
|
26
26
|
<%- end %>
|
|
27
27
|
|
|
28
|
-
<%= form_tag(
|
|
28
|
+
<%= form_tag(root_path, method: :post) do %>
|
|
29
29
|
<button <%= 'disabled' if editable? %> class='govuk-button govuk-button--start govuk-!-margin-top-2'>
|
|
30
30
|
Start
|
|
31
31
|
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
|
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,47 @@
|
|
|
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
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"_uuid": "7b748584-100e-4d81-a54a-5049190136cc",
|
|
151
|
+
"_id": "page.family_hobbies",
|
|
152
|
+
"_type": "page.singlequestion",
|
|
153
|
+
"components": [
|
|
154
|
+
{
|
|
155
|
+
"_id": "page.family-hobbies--text.auto_name__3",
|
|
156
|
+
"_type": "textarea",
|
|
157
|
+
"label": "Your family hobbies",
|
|
158
|
+
"name": "family_hobbies",
|
|
159
|
+
"rows": 5,
|
|
160
|
+
"validation": {
|
|
161
|
+
"required": true
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
],
|
|
165
|
+
"heading": "Family Hobbies",
|
|
166
|
+
"url": "/family-hobbies"
|
|
167
|
+
},
|
|
127
168
|
{
|
|
128
169
|
"_uuid": "e819d0c2-7062-4997-89cf-44d26d098404",
|
|
129
170
|
"_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,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "http://gov.uk/schema/v1.0.0/textarea",
|
|
3
|
+
"_name": "component.textarea",
|
|
4
|
+
"title": "Textarea",
|
|
5
|
+
"description": "Let users enter text that can be longer than a single line",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"_type": {
|
|
9
|
+
"const": "textarea"
|
|
10
|
+
},
|
|
11
|
+
"maxwords": {
|
|
12
|
+
"type": "number",
|
|
13
|
+
"title": "Maximum words",
|
|
14
|
+
"description": "Set a word limit",
|
|
15
|
+
"category": [
|
|
16
|
+
"userinput"
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
"maxchars": {
|
|
20
|
+
"type": "number",
|
|
21
|
+
"title": "Maximum characters",
|
|
22
|
+
"description": "Set a character limit",
|
|
23
|
+
"category": [
|
|
24
|
+
"userinput"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"threshold": {
|
|
28
|
+
"type": "number",
|
|
29
|
+
"title": "Threshold percentage",
|
|
30
|
+
"description": "Display the message about maximum length or words after a user has entered a certain amount",
|
|
31
|
+
"category": [
|
|
32
|
+
"userinput"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"rows": {
|
|
36
|
+
"type": "number",
|
|
37
|
+
"title": "Number of rows in the textarea",
|
|
38
|
+
"description": "Set the number of rows",
|
|
39
|
+
"category": [
|
|
40
|
+
"userinput"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"allOf": [
|
|
45
|
+
{
|
|
46
|
+
"$ref": "definition.field"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"$ref": "validations#/definitions/string_bundle"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"$ref": "definition.width_class.input"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
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.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-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,12 +240,15 @@ 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
|
|
251
|
+
- app/views/metadata_presenter/component/_textarea.html.erb
|
|
249
252
|
- app/views/metadata_presenter/header/show.html.erb
|
|
250
253
|
- app/views/metadata_presenter/page/checkanswers.html.erb
|
|
251
254
|
- app/views/metadata_presenter/page/confirmation.html.erb
|
|
@@ -255,7 +258,9 @@ files:
|
|
|
255
258
|
- config/initializers/default_metadata.rb
|
|
256
259
|
- config/initializers/schemas.rb
|
|
257
260
|
- config/routes.rb
|
|
261
|
+
- default_metadata/component/number.json
|
|
258
262
|
- default_metadata/component/text.json
|
|
263
|
+
- default_metadata/component/textarea.json
|
|
259
264
|
- default_metadata/config/meta.json
|
|
260
265
|
- default_metadata/config/service.json
|
|
261
266
|
- default_metadata/page/checkanswers.json
|
|
@@ -265,6 +270,7 @@ files:
|
|
|
265
270
|
- default_metadata/service/base.json
|
|
266
271
|
- default_metadata/string/error.max_length.json
|
|
267
272
|
- default_metadata/string/error.min_length.json
|
|
273
|
+
- default_metadata/string/error.number.json
|
|
268
274
|
- default_metadata/string/error.required.json
|
|
269
275
|
- fixtures/non_finished_service.json
|
|
270
276
|
- fixtures/service.json
|
|
@@ -274,6 +280,9 @@ files:
|
|
|
274
280
|
- lib/metadata_presenter/test_helpers.rb
|
|
275
281
|
- lib/metadata_presenter/version.rb
|
|
276
282
|
- lib/tasks/metadata_presenter_tasks.rake
|
|
283
|
+
- schemas/component/number.json
|
|
284
|
+
- schemas/component/text.json
|
|
285
|
+
- schemas/component/textarea.json
|
|
277
286
|
- schemas/condition/condition.json
|
|
278
287
|
- schemas/config/meta.json
|
|
279
288
|
- schemas/config/service.json
|
|
@@ -303,7 +312,6 @@ files:
|
|
|
303
312
|
- schemas/definition/page.content.json
|
|
304
313
|
- schemas/definition/page.form.json
|
|
305
314
|
- schemas/definition/page.json
|
|
306
|
-
- schemas/definition/page.singlequestion.json
|
|
307
315
|
- schemas/definition/repeatable.json
|
|
308
316
|
- schemas/definition/width_class.input.json
|
|
309
317
|
- schemas/definition/width_class.json
|
|
@@ -311,12 +319,12 @@ files:
|
|
|
311
319
|
- schemas/link/link.json
|
|
312
320
|
- schemas/page/checkanswers.json
|
|
313
321
|
- schemas/page/confirmation.json
|
|
322
|
+
- schemas/page/singlequestion.json
|
|
314
323
|
- schemas/page/start.json
|
|
315
324
|
- schemas/request/service.json
|
|
316
325
|
- schemas/service/base.json
|
|
317
326
|
- schemas/service/configuration.json
|
|
318
327
|
- schemas/service/locale.json
|
|
319
|
-
- schemas/text/text.json
|
|
320
328
|
- schemas/validations/validations.json
|
|
321
329
|
homepage: https://moj-online.service.justice.gov.uk
|
|
322
330
|
licenses:
|