metadata_presenter 0.4.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/metadata_presenter/application_helper.rb +16 -2
- data/app/models/metadata_presenter/service.rb +4 -0
- data/app/views/layouts/metadata_presenter/application.html.erb +1 -1
- 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/text.json +4 -1
- data/default_metadata/component/textarea.json +12 -0
- data/fixtures/version.json +19 -0
- data/lib/metadata_presenter/version.rb +1 -1
- 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 +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b189562f676341b0c9b1d6ad3e06eb514e7563d43273bb5397a27871bba72d3b
|
4
|
+
data.tar.gz: 65fbe4941dfca36471ce0e4349f932d0209fa7abef0155416b4e855fd54fa568
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c872d7137b780e33cfa485e6d6d7dbd6647e7eaf48fea01d94003faede70531d22caf02867d8bdea634ff43b1f7878fee1ac060855d16b3db27bc9e8de7eea0
|
7
|
+
data.tar.gz: 517418f03929151d2dfbc420e1fec644903bf4b72cbda01f2a3d1f4fe2192d433dbda1799ed73ef664791c0be36c5dc2c92e346085de6087d48e3eecf917c794
|
@@ -9,7 +9,7 @@ module MetadataPresenter
|
|
9
9
|
# variable as long your load_user_data in the controller sets the variable.
|
10
10
|
#
|
11
11
|
# @example
|
12
|
-
# <%=
|
12
|
+
# <%=a 'first_name' %>
|
13
13
|
#
|
14
14
|
def a(component_key)
|
15
15
|
if @user_data.present?
|
@@ -18,8 +18,22 @@ module MetadataPresenter
|
|
18
18
|
end
|
19
19
|
alias answer a
|
20
20
|
|
21
|
-
|
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
|
+
|
29
|
+
# Renders markdown given a text.
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# <%=m '# Some markdown' %>
|
33
|
+
#
|
34
|
+
def m(text)
|
22
35
|
(Kramdown::Document.new(text).to_html).html_safe
|
23
36
|
end
|
37
|
+
alias to_markdown m
|
24
38
|
end
|
25
39
|
end
|
@@ -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,25 @@
|
|
124
124
|
"heading": "Parent name",
|
125
125
|
"url": "/parent-name"
|
126
126
|
},
|
127
|
+
{
|
128
|
+
"_uuid": "7b748584-100e-4d81-a54a-5049190136cc",
|
129
|
+
"_id": "page.family_hobbies",
|
130
|
+
"_type": "page.singlequestion",
|
131
|
+
"components": [
|
132
|
+
{
|
133
|
+
"_id": "page.family-hobbies--text.auto_name__3",
|
134
|
+
"_type": "textarea",
|
135
|
+
"label": "Your family hobbies",
|
136
|
+
"name": "family_hobbies",
|
137
|
+
"rows": 5,
|
138
|
+
"validation": {
|
139
|
+
"required": true
|
140
|
+
}
|
141
|
+
}
|
142
|
+
],
|
143
|
+
"heading": "Family Hobbies",
|
144
|
+
"url": "/family-hobbies"
|
145
|
+
},
|
127
146
|
{
|
128
147
|
"_uuid": "e819d0c2-7062-4997-89cf-44d26d098404",
|
129
148
|
"_id": "page._check-answers",
|
@@ -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.7.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
|
@@ -246,6 +246,7 @@ files:
|
|
246
246
|
- app/views/errors/404.html
|
247
247
|
- app/views/layouts/metadata_presenter/application.html.erb
|
248
248
|
- app/views/metadata_presenter/component/_text.html.erb
|
249
|
+
- app/views/metadata_presenter/component/_textarea.html.erb
|
249
250
|
- app/views/metadata_presenter/header/show.html.erb
|
250
251
|
- app/views/metadata_presenter/page/checkanswers.html.erb
|
251
252
|
- app/views/metadata_presenter/page/confirmation.html.erb
|
@@ -256,6 +257,7 @@ files:
|
|
256
257
|
- config/initializers/schemas.rb
|
257
258
|
- config/routes.rb
|
258
259
|
- default_metadata/component/text.json
|
260
|
+
- default_metadata/component/textarea.json
|
259
261
|
- default_metadata/config/meta.json
|
260
262
|
- default_metadata/config/service.json
|
261
263
|
- default_metadata/page/checkanswers.json
|
@@ -274,6 +276,8 @@ files:
|
|
274
276
|
- lib/metadata_presenter/test_helpers.rb
|
275
277
|
- lib/metadata_presenter/version.rb
|
276
278
|
- lib/tasks/metadata_presenter_tasks.rake
|
279
|
+
- schemas/component/text.json
|
280
|
+
- schemas/component/textarea.json
|
277
281
|
- schemas/condition/condition.json
|
278
282
|
- schemas/config/meta.json
|
279
283
|
- schemas/config/service.json
|
@@ -303,7 +307,6 @@ files:
|
|
303
307
|
- schemas/definition/page.content.json
|
304
308
|
- schemas/definition/page.form.json
|
305
309
|
- schemas/definition/page.json
|
306
|
-
- schemas/definition/page.singlequestion.json
|
307
310
|
- schemas/definition/repeatable.json
|
308
311
|
- schemas/definition/width_class.input.json
|
309
312
|
- schemas/definition/width_class.json
|
@@ -311,12 +314,12 @@ files:
|
|
311
314
|
- schemas/link/link.json
|
312
315
|
- schemas/page/checkanswers.json
|
313
316
|
- schemas/page/confirmation.json
|
317
|
+
- schemas/page/singlequestion.json
|
314
318
|
- schemas/page/start.json
|
315
319
|
- schemas/request/service.json
|
316
320
|
- schemas/service/base.json
|
317
321
|
- schemas/service/configuration.json
|
318
322
|
- schemas/service/locale.json
|
319
|
-
- schemas/text/text.json
|
320
323
|
- schemas/validations/validations.json
|
321
324
|
homepage: https://moj-online.service.justice.gov.uk
|
322
325
|
licenses:
|