metadata_presenter 0.1.1 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/app/validators/metadata_presenter/validate_schema.rb +1 -2
  3. data/app/views/metadata_presenter/page/summary.html.erb +4 -3
  4. data/config/routes.rb +1 -1
  5. data/default_metadata/config/meta.json +24 -0
  6. data/default_metadata/config/service.json +4 -0
  7. data/default_metadata/page/confirmation.json +4 -0
  8. data/default_metadata/page/summary.json +6 -0
  9. data/default_metadata/service/base.json +18 -0
  10. data/default_metadata/string/error.max_length.json +6 -0
  11. data/default_metadata/string/error.min_length.json +6 -0
  12. data/default_metadata/string/error.required.json +7 -0
  13. data/fixtures/non_finished_service.json +120 -0
  14. data/fixtures/service.json +48 -0
  15. data/fixtures/version.json +143 -0
  16. data/lib/metadata_presenter/version.rb +1 -1
  17. data/schemas/condition/condition.json +48 -0
  18. data/schemas/config/meta.json +27 -0
  19. data/schemas/config/service.json +106 -0
  20. data/schemas/definition/block.json +28 -0
  21. data/schemas/definition/component.json +13 -0
  22. data/schemas/definition/components.json +15 -0
  23. data/schemas/definition/condition.base.json +25 -0
  24. data/schemas/definition/condition.boolean.json +25 -0
  25. data/schemas/definition/condition.defined.json +25 -0
  26. data/schemas/definition/condition.expression.json +22 -0
  27. data/schemas/definition/condition.number.json +49 -0
  28. data/schemas/definition/condition.text.json +48 -0
  29. data/schemas/definition/condition.value_type.json +24 -0
  30. data/schemas/definition/conditional.boolean.json +20 -0
  31. data/schemas/definition/conditions.all.json +20 -0
  32. data/schemas/definition/conditions.any.json +26 -0
  33. data/schemas/definition/conditions.exactly.json +26 -0
  34. data/schemas/definition/control.json +75 -0
  35. data/schemas/definition/data.json +28 -0
  36. data/schemas/definition/field.json +26 -0
  37. data/schemas/definition/html_attributes.json +37 -0
  38. data/schemas/definition/label.json +30 -0
  39. data/schemas/definition/link_list.json +30 -0
  40. data/schemas/definition/name.json +18 -0
  41. data/schemas/definition/namespace.json +28 -0
  42. data/schemas/definition/next_page.json +40 -0
  43. data/schemas/definition/page.content.json +23 -0
  44. data/schemas/definition/page.form.json +96 -0
  45. data/schemas/definition/page.json +109 -0
  46. data/schemas/definition/page.singlequestion.json +31 -0
  47. data/schemas/definition/repeatable.json +72 -0
  48. data/schemas/definition/width_class.input.json +48 -0
  49. data/schemas/definition/width_class.json +34 -0
  50. data/schemas/errors/errors.json +139 -0
  51. data/schemas/link/link.json +46 -0
  52. data/schemas/page/confirmation.json +35 -0
  53. data/schemas/page/start.json +34 -0
  54. data/schemas/page/summary.json +63 -0
  55. data/schemas/request/service.json +13 -0
  56. data/schemas/service/base.json +52 -0
  57. data/schemas/service/configuration.json +22 -0
  58. data/schemas/service/locale.json +12 -0
  59. data/schemas/text/text.json +23 -0
  60. data/schemas/validations/validations.json +443 -0
  61. metadata +57 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b57caa0d943af622e7d2ced08a3f77f4cedb7ad4d222f35d6a73a2aa7fabd026
4
- data.tar.gz: 8497d6e3f8a4266a49776852106bfdea64f7ec9fd5d31e98f3aca833fca74ec6
3
+ metadata.gz: ec5c5a811a4ff57b7306a6876ce1db7b8ab8dc38a11db49e5922e05bf7b81308
4
+ data.tar.gz: f4dda5fe741a8fdd349d053cfa746b82d62798a32cc306a4d2249bf0db514358
5
5
  SHA512:
6
- metadata.gz: 7b92cb9b0ffee8977ca390ff0e9a58f5309d59390a5443a5017a6feec772157937d642841c8a9b54774afc67a6d5a0300648422142057bc7ced8717eb5eba1f0
7
- data.tar.gz: efffbe7e71673c3b986cf3eda342e51e1a94fbbb4deb778d0b7fdc3596c228e9171bb48903529e86600e9585af1a2e7ff6202b4738aae75dde936b6ce91a8461
6
+ metadata.gz: 0b2546d19e21b30e80d37416cfeb92a3c77ecb4afdcf062dde4bfe8b29be20e9b8e592c2790cd6985b4b4c12a78236f9b6f43a506fcdfa20c646255f3eddaf51
7
+ data.tar.gz: 40ab623c319681fa1e65d0fb612c19fea09a87cf299b8bc9f7d1ab94a103c3b715c7169efc610c361d041120a8141f2e85cd98cf68b5da77ba029ae8ae6a433c
@@ -6,8 +6,7 @@ class MetadataPresenter::ValidateSchema
6
6
  def before(controller)
7
7
  return unless controller.request.post?
8
8
 
9
- schema_name = "request.#{controller.request.params['controller']}"
10
- validate(controller.request.params, schema_name)
9
+ validate(controller.request.params, 'request.service')
11
10
  rescue JSON::Schema::ValidationError, JSON::Schema::SchemaError, SchemaNotFoundError => e
12
11
  controller.render(
13
12
  json: ErrorsSerializer.new(message: e.message).attributes,
@@ -38,9 +38,10 @@
38
38
  <%= @user_data[component.name] %>
39
39
  </dd>
40
40
  <dd class="govuk-summary-list__actions">
41
- <%= link_to(change_answer_path(url: page.url),
42
- class: 'govuk-link',
43
- method: :post) do %>
41
+ <%= link_to(
42
+ change_answer_path(url: page.url),
43
+ class: 'govuk-link'
44
+ ) do %>
44
45
  Change<span class="govuk-visually-hidden"> Your answer for <%= component.label %></span>
45
46
  <% end %>
46
47
  </a>
@@ -3,6 +3,6 @@ MetadataPresenter::Engine.routes.draw do
3
3
 
4
4
  post '/reserved/:page_url/answers', to: 'answers#create', as: :reserved_answers
5
5
  post '/reserved/submissions', to: 'submissions#create', as: :reserved_submissions
6
- post '/reserved/change-answer', to: 'change_answer#create', as: :change_answer
6
+ get '/reserved/change-answer', to: 'change_answer#create', as: :change_answer
7
7
  match '*path', to: 'pages#show', via: :all
8
8
  end
@@ -0,0 +1,24 @@
1
+ {
2
+ "_id": "config.meta",
3
+ "_type": "config.meta",
4
+ "items": [
5
+ {
6
+ "_id": "config.meta--link",
7
+ "_type": "link",
8
+ "href": "/cookies",
9
+ "text": "Cookies"
10
+ },
11
+ {
12
+ "_id": "config.meta--link--2",
13
+ "_type": "link",
14
+ "href": "/privacy",
15
+ "text": "Privacy"
16
+ },
17
+ {
18
+ "_id": "config.meta--link--3",
19
+ "_type": "link",
20
+ "href": "/accessibility",
21
+ "text": "Accessibility"
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_id": "config.service",
3
+ "_type": "config.service"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "_id": "page.confirmation",
3
+ "heading": "Required - Confirmation"
4
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "_id": "page.summary",
3
+ "heading": "Check your answers",
4
+ "send_heading": "Now send your application",
5
+ "send_body": "By submitting this application you confirm that, to the best of your knowledge, the details you are providing are correct."
6
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "_id": "service.base",
3
+ "_type": "service.base",
4
+ "service_name": "Service name",
5
+ "configuration": {},
6
+ "pages": [
7
+ {
8
+ "_id": "page.start",
9
+ "_type": "page.start",
10
+ "heading": "Service name goes here",
11
+ "lede": "This is your start page first paragraph. You can only have one paragraph here.",
12
+ "body": "Use this service to:\r\n\r\n* do something\r\n* update your name, address or other details\r\n* do something else\r\n\r\nRegistering takes around 5 minutes.",
13
+ "steps": [],
14
+ "url": "/"
15
+ }
16
+ ],
17
+ "locale": "en"
18
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "_id": "error.max_length",
3
+ "_type": "string.error",
4
+ "description": "Input (string) is too long",
5
+ "value": "Your answer for '%{control}' is too long (%{max_length} characters at most)"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "_id": "error.min_length",
3
+ "_type": "string.error",
4
+ "description": "Input (string) is too short",
5
+ "value": "Your answer for '%{control}' is too short (%{min_length} characters at least)"
6
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "_id": "error.required",
3
+ "_type": "string.error",
4
+ "description": "Input is required",
5
+ "value": "Enter an answer for %{control}",
6
+ "value:cy": "Rhowch ateb i {control}"
7
+ }
@@ -0,0 +1,120 @@
1
+ {
2
+ "_id": "service.base",
3
+ "_type": "service.base",
4
+ "service_id": "d243f5c0-e8a2-4b13-982c-7b5f3fa128cf",
5
+ "service_name": "Service name",
6
+ "created_by": "4634ec01-5618-45ec-a4e2-bb5aa587e751",
7
+ "configuration": {
8
+ "service": {
9
+ "_id": "config.service",
10
+ "_type": "config.service"
11
+ },
12
+ "meta": {
13
+ "_id": "config.meta",
14
+ "_type": "config.meta",
15
+ "items": [
16
+ {
17
+ "_id": "config.meta--link",
18
+ "_type": "link",
19
+ "href": "/cookies",
20
+ "text": "Cookies"
21
+ },
22
+ {
23
+ "_id": "config.meta--link--2",
24
+ "_type": "link",
25
+ "href": "/privacy",
26
+ "text": "Privacy"
27
+ },
28
+ {
29
+ "_id": "config.meta--link--3",
30
+ "_type": "link",
31
+ "href": "/accessibility",
32
+ "text": "Accessibility"
33
+ }
34
+ ]
35
+ }
36
+ },
37
+ "pages": [
38
+ {
39
+ "_id": "page.start",
40
+ "_type": "page.start",
41
+ "heading": "Service name goes here",
42
+ "lede": "This is your start page first paragraph. You can only have one paragraph here.",
43
+ "body": "Use this service to:\r\n\r\n* do something\r\n* update your name, address or other details\r\n* do something else\r\n\r\nRegistering takes around 5 minutes.",
44
+ "steps": [
45
+ "page.name",
46
+ "page.email-address",
47
+ "page.parent_name"
48
+ ],
49
+ "url": "/"
50
+ },
51
+ {
52
+ "_id": "page.name",
53
+ "_type": "page.singlequestion",
54
+ "components": [
55
+ {
56
+ "_id": "page.name--text.auto_name__1",
57
+ "_type": "text",
58
+ "label": "Full name",
59
+ "name": "full_name",
60
+ "validation": {
61
+ "required": true,
62
+ "max_length": 10,
63
+ "min_length": 2
64
+ }
65
+ }
66
+ ],
67
+ "heading": "Your name",
68
+ "url": "/name"
69
+ },
70
+ {
71
+ "_id": "page.email-address",
72
+ "_type": "page.singlequestion",
73
+ "heading": "Email address",
74
+ "components": [
75
+ {
76
+ "_id": "page.email-address--email.auto_name__2",
77
+ "_type": "text",
78
+ "errors": {
79
+ "format": {},
80
+ "required": {
81
+ "any": "Enter an email address"
82
+ },
83
+ "max_length": {
84
+ "any": "%{control} is too long."
85
+ },
86
+ "min_length": {
87
+ "any": "%{control} is too short."
88
+ }
89
+ },
90
+ "label": "Your email address",
91
+ "name": "email_address",
92
+ "validation": {
93
+ "required": true,
94
+ "max_length": 30,
95
+ "min_length": 2
96
+ }
97
+ }
98
+ ],
99
+ "url": "/email-address"
100
+ },
101
+ {
102
+ "_id": "page.parent_name",
103
+ "_type": "page.singlequestion",
104
+ "components": [
105
+ {
106
+ "_id": "page.parent-name--text.auto_name__3",
107
+ "_type": "text",
108
+ "label": "Parent name",
109
+ "name": "parent_name",
110
+ "validation": {
111
+ "required": false
112
+ }
113
+ }
114
+ ],
115
+ "heading": "Parent name",
116
+ "url": "/parent-name"
117
+ }
118
+ ],
119
+ "locale": "en"
120
+ }
@@ -0,0 +1,48 @@
1
+ {
2
+ "_id": "service.base",
3
+ "_type": "service.base",
4
+ "service_name": "Service name",
5
+ "created_by": "4634ec01-5618-45ec-a4e2-bb5aa587e751",
6
+ "configuration": {
7
+ "service": {
8
+ "_id": "config.service",
9
+ "_type": "config.service"
10
+ },
11
+ "meta": {
12
+ "_id": "config.meta",
13
+ "_type": "config.meta",
14
+ "items": [
15
+ {
16
+ "_id": "config.meta--link",
17
+ "_type": "link",
18
+ "href": "/cookies",
19
+ "text": "Cookies"
20
+ },
21
+ {
22
+ "_id": "config.meta--link--2",
23
+ "_type": "link",
24
+ "href": "/privacy",
25
+ "text": "Privacy"
26
+ },
27
+ {
28
+ "_id": "config.meta--link--3",
29
+ "_type": "link",
30
+ "href": "/accessibility",
31
+ "text": "Accessibility"
32
+ }
33
+ ]
34
+ }
35
+ },
36
+ "pages": [
37
+ {
38
+ "_id": "page.start",
39
+ "_type": "page.start",
40
+ "heading": "Service name goes here",
41
+ "lede": "Use this service to:",
42
+ "body": "Use this service to:\r\n\r\n* do something\r\n* update your name, address or other details\r\n* do something else\r\n\r\nRegistering takes around 5 minutes.",
43
+ "steps": [],
44
+ "url": "/"
45
+ }
46
+ ],
47
+ "locale": "en"
48
+ }
@@ -0,0 +1,143 @@
1
+ {
2
+ "_id": "service.base",
3
+ "_type": "service.base",
4
+ "service_id": "d243f5c0-e8a2-4b13-982c-7b5f3fa128cf",
5
+ "service_name": "Service name",
6
+ "created_by": "4634ec01-5618-45ec-a4e2-bb5aa587e751",
7
+ "configuration": {
8
+ "service": {
9
+ "_id": "config.service",
10
+ "_type": "config.service"
11
+ },
12
+ "meta": {
13
+ "_id": "config.meta",
14
+ "_type": "config.meta",
15
+ "items": [
16
+ {
17
+ "_id": "config.meta--link",
18
+ "_type": "link",
19
+ "href": "/cookies",
20
+ "text": "Cookies"
21
+ },
22
+ {
23
+ "_id": "config.meta--link--2",
24
+ "_type": "link",
25
+ "href": "/privacy",
26
+ "text": "Privacy"
27
+ },
28
+ {
29
+ "_id": "config.meta--link--3",
30
+ "_type": "link",
31
+ "href": "/accessibility",
32
+ "text": "Accessibility"
33
+ }
34
+ ]
35
+ }
36
+ },
37
+ "pages": [
38
+ {
39
+ "_id": "page.start",
40
+ "_type": "page.start",
41
+ "heading": "Service name goes here",
42
+ "lede": "This is your start page first paragraph. You can only have one paragraph here.",
43
+ "body": "Use this service to:\r\n\r\n* do something\r\n* update your name, address or other details\r\n* do something else\r\n\r\nRegistering takes around 5 minutes.",
44
+ "steps": [
45
+ "page.name",
46
+ "page.email-address",
47
+ "page.parent_name",
48
+ "page.check-answers",
49
+ "page._confirmation"
50
+ ],
51
+ "url": "/"
52
+ },
53
+ {
54
+ "_id": "page.name",
55
+ "_type": "page.singlequestion",
56
+ "components": [
57
+ {
58
+ "_id": "page.name--text.auto_name__1",
59
+ "_type": "text",
60
+ "label": "Full name",
61
+ "name": "full_name",
62
+ "validation": {
63
+ "required": true,
64
+ "max_length": 10,
65
+ "min_length": 2
66
+ }
67
+ }
68
+ ],
69
+ "heading": "Your name",
70
+ "url": "/name"
71
+ },
72
+ {
73
+ "_id": "page.email-address",
74
+ "_type": "page.singlequestion",
75
+ "heading": "Email address",
76
+ "components": [
77
+ {
78
+ "_id": "page.email-address--email.auto_name__2",
79
+ "_type": "text",
80
+ "errors": {
81
+ "format": {},
82
+ "required": {
83
+ "any": "Enter an email address"
84
+ },
85
+ "max_length": {
86
+ "any": "%{control} is too long."
87
+ },
88
+ "min_length": {
89
+ "any": "%{control} is too short."
90
+ }
91
+ },
92
+ "label": "Your email address",
93
+ "name": "email_address",
94
+ "validation": {
95
+ "required": true,
96
+ "max_length": 30,
97
+ "min_length": 2
98
+ }
99
+ }
100
+ ],
101
+ "url": "/email-address"
102
+ },
103
+ {
104
+ "_id": "page.parent_name",
105
+ "_type": "page.singlequestion",
106
+ "components": [
107
+ {
108
+ "_id": "page.parent-name--text.auto_name__3",
109
+ "_type": "text",
110
+ "label": "Parent name",
111
+ "name": "parent_name",
112
+ "validation": {
113
+ "required": false,
114
+ "max_length": 10,
115
+ "min_length": 2
116
+ }
117
+ }
118
+ ],
119
+ "heading": "Parent name",
120
+ "url": "/parent-name"
121
+ },
122
+ {
123
+ "_id": "page._check-answers",
124
+ "_type": "page.summary",
125
+ "body": "Optional content",
126
+ "heading": "Review your answer",
127
+ "lede": "First paragraph",
128
+ "section_heading": "This section is optional",
129
+ "send_body": "By submitting this answer you confirm all your answers",
130
+ "send_heading": "Send your answer",
131
+ "url": "/check-answers"
132
+ },
133
+ {
134
+ "_id": "page._confirmation",
135
+ "_type": "page.confirmation",
136
+ "body": "You'll receive a confirmation email",
137
+ "heading": "Complaint sent",
138
+ "lede": "Optional lede",
139
+ "url": "/confirmation"
140
+ }
141
+ ],
142
+ "locale": "en"
143
+ }