metadata_presenter 0.3.0 → 0.6.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 +33 -1
- data/app/models/metadata_presenter/metadata.rb +4 -0
- data/app/models/metadata_presenter/service.rb +13 -1
- data/app/views/metadata_presenter/component/_text.html.erb +1 -1
- data/app/views/metadata_presenter/component/_textarea.html.erb +11 -0
- data/app/views/metadata_presenter/page/checkanswers.html.erb +2 -2
- data/app/views/metadata_presenter/page/start.html.erb +1 -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/textarea/textarea.json +55 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 951d82f5f5c4cb5ac86290e44bab1301c7e3c0d3d803dd323024339108d1af02
|
4
|
+
data.tar.gz: 669f233609d32a82bffb442ce9f666d5af1de8f831da3e5e38f8ff85a2da9709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76a0540b501f5d5b2ca999da539001ecc793cb21bdab95b2a885753ef84bd74e755a4849b1deb23c28d93947be79ac5f06672a9cbbb7bbe6f8e8016e58d96638
|
7
|
+
data.tar.gz: c89a2d3db1f7bcacd7ad40c4cb550349685822c1914164f9fc5f0d800b00d93ae8ee58f6a50397cf096372451fd4b54479f4fe68aee62b57d4ea46bbc5446317
|
@@ -1,7 +1,39 @@
|
|
1
1
|
module MetadataPresenter
|
2
2
|
module ApplicationHelper
|
3
|
-
|
3
|
+
## Display user answers on the view
|
4
|
+
## When the user doesn't answered yet the component will be blank
|
5
|
+
# or with data otherwise, so doing the if in every output is not
|
6
|
+
# pratical.
|
7
|
+
#
|
8
|
+
# The below example search for 'first_name' in the user data instance
|
9
|
+
# variable as long your load_user_data in the controller sets the variable.
|
10
|
+
#
|
11
|
+
# @example
|
12
|
+
# <%=a 'first_name' %>
|
13
|
+
#
|
14
|
+
def a(component_key)
|
15
|
+
if @user_data.present?
|
16
|
+
@user_data[component_key]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
alias answer a
|
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
|
+
|
29
|
+
# Renders markdown given a text.
|
30
|
+
#
|
31
|
+
# @example
|
32
|
+
# <%=m '# Some markdown' %>
|
33
|
+
#
|
34
|
+
def m(text)
|
4
35
|
(Kramdown::Document.new(text).to_html).html_safe
|
5
36
|
end
|
37
|
+
alias to_markdown m
|
6
38
|
end
|
7
39
|
end
|
@@ -7,8 +7,12 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
|
|
7
7
|
pages.first
|
8
8
|
end
|
9
9
|
|
10
|
+
def service_slug
|
11
|
+
service_name.parameterize
|
12
|
+
end
|
13
|
+
|
10
14
|
def find_page_by_url(url)
|
11
|
-
pages.find { |page| page.url == url }
|
15
|
+
pages.find { |page| strip_slash(page.url) == strip_slash(url) }
|
12
16
|
end
|
13
17
|
|
14
18
|
def find_page_by_uuid(uuid)
|
@@ -29,4 +33,12 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
|
|
29
33
|
page.type == 'page.confirmation'
|
30
34
|
end
|
31
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def strip_slash(url)
|
40
|
+
return url if url == '/'
|
41
|
+
|
42
|
+
url.gsub(/^\//, '')
|
43
|
+
end
|
32
44
|
end
|
@@ -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
|
+
%>
|
@@ -35,7 +35,7 @@
|
|
35
35
|
</dt>
|
36
36
|
|
37
37
|
<dd class="govuk-summary-list__value">
|
38
|
-
<%=
|
38
|
+
<%= formatted_answer(component.name) %>
|
39
39
|
</dd>
|
40
40
|
<dd class="govuk-summary-list__actions">
|
41
41
|
<%= link_to(
|
@@ -66,7 +66,7 @@
|
|
66
66
|
</div>
|
67
67
|
<% end %>
|
68
68
|
|
69
|
-
<button 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">
|
69
|
+
<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">
|
70
70
|
Accept and send application
|
71
71
|
</button>
|
72
72
|
<% end %>
|
@@ -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/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": "component.textarea",
|
3
|
+
"_name": "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
|
+
}
|
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.6.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-02-08 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
|
@@ -317,6 +319,7 @@ files:
|
|
317
319
|
- schemas/service/configuration.json
|
318
320
|
- schemas/service/locale.json
|
319
321
|
- schemas/text/text.json
|
322
|
+
- schemas/textarea/textarea.json
|
320
323
|
- schemas/validations/validations.json
|
321
324
|
homepage: https://moj-online.service.justice.gov.uk
|
322
325
|
licenses:
|