metadata_presenter 3.2.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e690363ac373962c0478469b6b501d6ecc255473d6bbd04aff6cf012aa098843
4
- data.tar.gz: 907eced7e4a09a2b247130deb082ef5c05766dd3d995d18483c69d5dcb8babf7
3
+ metadata.gz: ab2bc3fe5f1c4bedbd29dffd70a0bf35aa4d8db36a2c6d3885fc54fa38efeaea
4
+ data.tar.gz: af43aacebeca0de805984284454e7a872c9824b5aa3f589a804802a42998cf86
5
5
  SHA512:
6
- metadata.gz: a061114f4db7608516af2da01234bedd45b11708c47c9f693ebffa0b13d7f1fe2814313ce79bfc4bf555b2db3526d63743193789297e1bf2f3d8a87ec6611a40
7
- data.tar.gz: 78b39e5035fe137a52b83c2b3f6a42edcc72c2d921247a67f6958608acf2a5df8ba15795986e56f5d75e602c530a1d83005c30a89d51c0ce1362f2ce9984be91
6
+ metadata.gz: a90400837b76e91165bc82a7ef916b10132691fa9eed5b2d6587da55915664ae2b343fe41e3784db72cfff775d453b9735af0d5f258343c3985b87c7fcb7d933
7
+ data.tar.gz: e9d8656b711277409d1b621334e68c435e3a560f4b3c5d4ecd8d27a480ca3bfd125b630e833361a04346d4d6da9c8fa726ad7828b6d66172b54e0325d3bffa74
@@ -113,6 +113,35 @@ module MetadataPresenter
113
113
  end
114
114
  helper_method :external_or_relative_link
115
115
 
116
+ def load_conditional_content
117
+ if @page.content_component_present?
118
+ if components_without_conditionals(@page).present?
119
+ return components_without_conditionals(@page) + show_components(@page).compact
120
+ end
121
+
122
+ show_components(@page).compact
123
+ end
124
+ end
125
+ helper_method :load_conditional_content
126
+
127
+ def components_without_conditionals(page)
128
+ page.content_components.select { |component|
129
+ component.conditionals.blank?
130
+ }.map(&:uuid)
131
+ end
132
+
133
+ def show_components(page)
134
+ return @page.content_components.map(&:uuid) if editor_preview?
135
+
136
+ page.content_components.map do |content_component|
137
+ EvaluateContentConditionals.new(
138
+ service:,
139
+ component: content_component,
140
+ user_data: load_user_data
141
+ ).show_component
142
+ end
143
+ end
144
+
116
145
  private
117
146
 
118
147
  def not_found
@@ -8,6 +8,7 @@ module MetadataPresenter
8
8
  @page ||= service.find_page_by_url(request.env['PATH_INFO'])
9
9
  if @page
10
10
  load_autocomplete_items
11
+ load_conditional_content
11
12
 
12
13
  @page_answers = PageAnswers.new(@page, @user_data)
13
14
  render template: @page.template
@@ -82,6 +82,12 @@ class MetadataPresenter::Component < MetadataPresenter::Metadata
82
82
  metadata.max_files.presence || '0'
83
83
  end
84
84
 
85
+ def conditionals
86
+ Array(metadata['conditionals']).map do |conditional_metadata|
87
+ MetadataPresenter::Conditional.new(conditional_metadata)
88
+ end
89
+ end
90
+
85
91
  private
86
92
 
87
93
  def validation_bundle_key
@@ -1,5 +1,5 @@
1
1
  module MetadataPresenter
2
- class EvaluateConditionals
2
+ class EvaluateBranchConditionals
3
3
  include ActiveModel::Model
4
4
  attr_accessor :service, :flow, :user_data
5
5
 
@@ -0,0 +1,35 @@
1
+ module MetadataPresenter
2
+ class EvaluateContentConditionals
3
+ include ActiveModel::Model
4
+ attr_accessor :service, :component, :user_data
5
+
6
+ def show_component
7
+ component_uuid
8
+ end
9
+
10
+ def component_uuid
11
+ @results ||=
12
+ conditionals.map do |conditional|
13
+ evaluated_expressions = conditional.expressions.map do |expression|
14
+ expression.service = service
15
+
16
+ Operator.new(
17
+ expression.operator
18
+ ).evaluate(
19
+ expression.field_label,
20
+ user_data[expression.expression_component.id]
21
+ )
22
+ end
23
+
24
+ if conditional.type == 'or' && evaluated_expressions.any?
25
+ component.uuid
26
+ elsif evaluated_expressions.all?
27
+ component.uuid
28
+ end
29
+ end
30
+ @results.flatten.compact.first
31
+ end
32
+
33
+ delegate :conditionals, to: :component
34
+ end
35
+ end
@@ -7,7 +7,7 @@ module MetadataPresenter
7
7
  return check_answers_page if return_to_check_your_answer?
8
8
 
9
9
  if conditionals?
10
- evaluate_conditionals
10
+ evaluate_branch_conditionals
11
11
  else
12
12
  service.find_page_by_uuid(current_page_flow.default_next)
13
13
  end
@@ -66,8 +66,8 @@ module MetadataPresenter
66
66
  next_flow_branch_object?
67
67
  end
68
68
 
69
- def evaluate_conditionals
70
- EvaluateConditionals.new(
69
+ def evaluate_branch_conditionals
70
+ EvaluateBranchConditionals.new(
71
71
  service:,
72
72
  flow: next_flow,
73
73
  user_data:
@@ -141,6 +141,10 @@ module MetadataPresenter
141
141
  end
142
142
  end
143
143
 
144
+ def content_component_present?
145
+ components.any?(&:content?)
146
+ end
147
+
144
148
  private
145
149
 
146
150
  def heading?
@@ -28,7 +28,7 @@ module MetadataPresenter
28
28
  private
29
29
 
30
30
  def evaluated_page(flow_object)
31
- EvaluateConditionals.new(
31
+ EvaluateBranchConditionals.new(
32
32
  service:,
33
33
  flow: flow_object,
34
34
  user_data:
@@ -1,5 +1,5 @@
1
1
  <% components.each_with_index do |component, index| %>
2
- <% if component.type == 'content' %>
2
+ <% if component.type == 'content' && (component.uuid).in?(load_conditional_content) %>
3
3
  <editable-content id="<%= "page[#{component.collection}[#{index}]]" %>"
4
4
  class="fb-editable govuk-!-margin-top-8"
5
5
  type="<%= component.type %>"
@@ -9,7 +9,9 @@
9
9
  data-config="<%= component.to_json %>">
10
10
  <%= to_html(component.content) %>
11
11
  </editable-content>
12
- <% else %>
12
+ <% end %>
13
+
14
+ <% unless component.type == 'content' %>
13
15
  <div class="fb-editable govuk-!-margin-top-8"
14
16
  id="<%= component.id %>"
15
17
  data-fb-content-type="<%= component.type %>"
@@ -0,0 +1,650 @@
1
+ {
2
+ "_id": "service.base",
3
+ "flow": {
4
+ "07635f6d-34a8-45c8-884f-87696eba6a1f": {
5
+ "next": {
6
+ "default": "e2b45429-5a5e-45c1-95f8-8970af92790a"
7
+ },
8
+ "_type": "flow.page"
9
+ },
10
+ "432d2b1c-4242-466a-8978-2657f96e63d9": {
11
+ "next": {
12
+ "default": "e6df0eaa-76a7-494a-9468-68b093e111ce"
13
+ },
14
+ "_type": "flow.page"
15
+ },
16
+ "93b54d92-4fbf-44aa-8f5d-d94cb72a10e8": {
17
+ "next": {
18
+ "default": "be656508-ffa1-4c40-815e-ca1859c9514f"
19
+ },
20
+ "_type": "flow.page"
21
+ },
22
+ "be656508-ffa1-4c40-815e-ca1859c9514f": {
23
+ "next": {
24
+ "default": "fcbdca1e-2a09-485b-951b-5b596115defc"
25
+ },
26
+ "_type": "flow.page"
27
+ },
28
+ "c5525c09-c817-4280-9812-8c70b309b073": {
29
+ "next": {
30
+ "default": "07635f6d-34a8-45c8-884f-87696eba6a1f"
31
+ },
32
+ "_type": "flow.page"
33
+ },
34
+ "d0f7b265-17c9-4c22-8739-d7c46d6d1426": {
35
+ "next": {
36
+ "default": "c5525c09-c817-4280-9812-8c70b309b073"
37
+ },
38
+ "_type": "flow.page"
39
+ },
40
+ "e2b45429-5a5e-45c1-95f8-8970af92790a": {
41
+ "next": {
42
+ "default": "432d2b1c-4242-466a-8978-2657f96e63d9"
43
+ },
44
+ "_type": "flow.page"
45
+ },
46
+ "e6df0eaa-76a7-494a-9468-68b093e111ce": {
47
+ "next": {
48
+ "default": ""
49
+ },
50
+ "_type": "flow.page"
51
+ },
52
+ "fcbdca1e-2a09-485b-951b-5b596115defc": {
53
+ "next": {
54
+ "default": "d0f7b265-17c9-4c22-8739-d7c46d6d1426"
55
+ },
56
+ "_type": "flow.page"
57
+ }
58
+ },
59
+ "_type": "service.base",
60
+ "pages": [
61
+ {
62
+ "_id": "page.start",
63
+ "url": "/",
64
+ "body": "Use this service to apply for a service or contact us about a case.\r\n\r\n## Before you start\r\nYou will need:\r\n\r\n* your 8-digit reference number\r\n* a copy of your photo ID\r\n* something else\r\n\r\nThis form will take around 5 minutes to complete. We will reply within 10 working days.",
65
+ "_type": "page.start",
66
+ "_uuid": "93b54d92-4fbf-44aa-8f5d-d94cb72a10e8",
67
+ "heading": "Service name goes here",
68
+ "before_you_start": "## Other ways to get in touch\r\nYou can also apply or contact us about your case by:\r\n\r\n* telephone: 01234 567889\r\n* email: <example.service@justice.gov.uk>\r\n\r\nThis form is also [available in Welsh (Cymraeg)](https://example-service.form.service.justice.gov.uk/)."
69
+ },
70
+ {
71
+ "_id": "page.ice-cream",
72
+ "url": "ice-cream",
73
+ "body": "Body section",
74
+ "lede": "",
75
+ "_type": "page.singlequestion",
76
+ "_uuid": "be656508-ffa1-4c40-815e-ca1859c9514f",
77
+ "heading": "",
78
+ "components": [
79
+ {
80
+ "_id": "ice-cream_checkboxes_1",
81
+ "hint": "",
82
+ "name": "ice-cream_checkboxes_1",
83
+ "_type": "checkboxes",
84
+ "_uuid": "ea13126a-7ae2-45a5-a08f-949bd1953877",
85
+ "items": [
86
+ {
87
+ "_id": "ice-cream_checkboxes_1_item_1",
88
+ "hint": "",
89
+ "name": "ice-cream_checkboxes_1",
90
+ "_type": "checkbox",
91
+ "_uuid": "acbfc0d8-7dbf-437f-8d9b-3c140140958e",
92
+ "label": "Chocolate",
93
+ "value": "value-1",
94
+ "errors": {
95
+ },
96
+ "legend": "Question",
97
+ "collection": "components",
98
+ "validation": {
99
+ "required": true
100
+ }
101
+ },
102
+ {
103
+ "_id": "ice-cream_checkboxes_1_item_2",
104
+ "hint": "",
105
+ "name": "ice-cream_checkboxes_1",
106
+ "_type": "checkbox",
107
+ "_uuid": "3bf08f98-ad1f-4a9d-b150-9ae917c4f711",
108
+ "label": "Hokey Pokey",
109
+ "value": "value-2",
110
+ "errors": {
111
+ },
112
+ "legend": "Question",
113
+ "collection": "components",
114
+ "validation": {
115
+ "required": true
116
+ }
117
+ },
118
+ {
119
+ "_id": "ice-cream_checkboxes_1_item_3",
120
+ "hint": "",
121
+ "name": "ice-cream_checkboxes_1",
122
+ "_type": "checkbox",
123
+ "_uuid": "d14b0d78-3977-4c58-8c05-2c2853d4dbbb",
124
+ "label": "Mango",
125
+ "value": "value-3",
126
+ "errors": {
127
+ },
128
+ "legend": "Question",
129
+ "collection": "components",
130
+ "validation": {
131
+ "required": true
132
+ }
133
+ },
134
+ {
135
+ "_id": "ice-cream_checkboxes_1_item_4",
136
+ "hint": "",
137
+ "name": "ice-cream_checkboxes_1",
138
+ "_type": "checkbox",
139
+ "_uuid": "b8571aa4-a208-4c8c-92e6-4fdffbba9d48",
140
+ "label": "Pistachio",
141
+ "value": "value-4",
142
+ "errors": {
143
+ },
144
+ "legend": "Question",
145
+ "collection": "components",
146
+ "validation": {
147
+ "required": true
148
+ }
149
+ }
150
+ ],
151
+ "errors": {
152
+ },
153
+ "legend": "Checkbox",
154
+ "collection": "components",
155
+ "validation": {
156
+ "required": true
157
+ }
158
+ }
159
+ ],
160
+ "section_heading": ""
161
+ },
162
+ {
163
+ "_id": "page.flavours",
164
+ "url": "flavours",
165
+ "body": "",
166
+ "lede": "",
167
+ "_type": "page.content",
168
+ "_uuid": "fcbdca1e-2a09-485b-951b-5b596115defc",
169
+ "heading": "Ice cream flavours",
170
+ "components": [
171
+ {
172
+ "_id": "flavours_content_1",
173
+ "name": "flavours_content_1",
174
+ "_type": "content",
175
+ "_uuid": "b4b7fae6-cc1a-4ed6-b7e2-89ae6da74ffb",
176
+ "content": "Chocolate, Hokey Pokey, Mango and Pistachio. All of the flavours.",
177
+ "collection": "components",
178
+ "conditionals": [
179
+ {
180
+ "_type": "and",
181
+ "_uuid": "98cfd843-7c02-4534-9055-201487e9be16",
182
+ "expressions": [
183
+ {
184
+ "page": "be656508-ffa1-4c40-815e-ca1859c9514f",
185
+ "field": "acbfc0d8-7dbf-437f-8d9b-3c140140958e",
186
+ "operator": "contains",
187
+ "component": "ea13126a-7ae2-45a5-a08f-949bd1953877"
188
+ },
189
+ {
190
+ "page": "be656508-ffa1-4c40-815e-ca1859c9514f",
191
+ "field": "3bf08f98-ad1f-4a9d-b150-9ae917c4f711",
192
+ "operator": "contains",
193
+ "component": "ea13126a-7ae2-45a5-a08f-949bd1953877"
194
+ },
195
+ {
196
+ "page": "be656508-ffa1-4c40-815e-ca1859c9514f",
197
+ "field": "d14b0d78-3977-4c58-8c05-2c2853d4dbbb",
198
+ "operator": "contains",
199
+ "component": "ea13126a-7ae2-45a5-a08f-949bd1953877"
200
+ },
201
+ {
202
+ "page": "be656508-ffa1-4c40-815e-ca1859c9514f",
203
+ "field": "b8571aa4-a208-4c8c-92e6-4fdffbba9d48",
204
+ "operator": "contains",
205
+ "component": "ea13126a-7ae2-45a5-a08f-949bd1953877"
206
+ }
207
+ ]
208
+ }
209
+ ]
210
+ },
211
+ {
212
+ "_id": "flavours_content_2",
213
+ "name": "flavours_content_2",
214
+ "_type": "content",
215
+ "_uuid": "02826f69-13e7-4f65-a636-366ee1f08655",
216
+ "content": "You didn't choose Mango.",
217
+ "collection": "components",
218
+ "conditionals": [
219
+ {
220
+ "_type": "if",
221
+ "_uuid": "98cfd843-7c02-4534-9055-201487e9be16",
222
+ "expressions": [
223
+ {
224
+ "page": "be656508-ffa1-4c40-815e-ca1859c9514f",
225
+ "field": "d14b0d78-3977-4c58-8c05-2c2853d4dbbb",
226
+ "operator": "does_not_contain",
227
+ "component": "ea13126a-7ae2-45a5-a08f-949bd1953877"
228
+ }
229
+ ]
230
+ }
231
+ ]
232
+ }
233
+ ],
234
+ "add_component": "content",
235
+ "section_heading": ""
236
+ },
237
+ {
238
+ "_id": "page.colours",
239
+ "url": "colours",
240
+ "body": "",
241
+ "lede": "",
242
+ "_type": "page.singlequestion",
243
+ "_uuid": "d0f7b265-17c9-4c22-8739-d7c46d6d1426",
244
+ "heading": "",
245
+ "components": [
246
+ {
247
+ "_id": "colours_radios_1",
248
+ "hint": "",
249
+ "name": "colours_radios_1",
250
+ "_type": "radios",
251
+ "_uuid": "bfa711a6-e937-4d73-acbd-be19cc334645",
252
+ "items": [
253
+ {
254
+ "_id": "colours_radios_1_item_1",
255
+ "hint": "",
256
+ "name": "colours_radios_1",
257
+ "_type": "radio",
258
+ "_uuid": "2d62e730-dbf4-45ee-b91f-266170b2bb29",
259
+ "label": "red",
260
+ "value": "value-1",
261
+ "errors": {
262
+ },
263
+ "legend": "Colours",
264
+ "collection": "components",
265
+ "validation": {
266
+ "required": true
267
+ }
268
+ },
269
+ {
270
+ "_id": "colours_radios_1_item_2",
271
+ "hint": "",
272
+ "name": "colours_radios_1",
273
+ "_type": "radio",
274
+ "_uuid": "bf7b849d-550a-48bd-b31e-9331242703f5",
275
+ "label": "yellow",
276
+ "value": "value-2",
277
+ "errors": {
278
+ },
279
+ "legend": "Question",
280
+ "collection": "components",
281
+ "validation": {
282
+ "required": true
283
+ }
284
+ },
285
+ {
286
+ "_id": "colours_radios_1_item_3",
287
+ "hint": "",
288
+ "name": "colours_radios_1",
289
+ "_type": "radio",
290
+ "_uuid": "8ec6802d-6a5e-4b5f-bea3-e7418584acad",
291
+ "label": "blue",
292
+ "value": "value-3",
293
+ "errors": {
294
+ },
295
+ "legend": "Question",
296
+ "collection": "components",
297
+ "validation": {
298
+ "required": true
299
+ }
300
+ }
301
+ ],
302
+ "errors": {
303
+ },
304
+ "legend": "Colours",
305
+ "collection": "components",
306
+ "validation": {
307
+ "required": true
308
+ }
309
+ }
310
+ ],
311
+ "section_heading": ""
312
+ },
313
+ {
314
+ "_id": "page.checkanswers",
315
+ "url": "check-answers",
316
+ "_type": "page.checkanswers",
317
+ "_uuid": "432d2b1c-4242-466a-8978-2657f96e63d9",
318
+ "heading": "Check your answers",
319
+ "send_body": "By submitting this application you confirm that, to the best of your knowledge, the details you are providing are correct.",
320
+ "components": [
321
+ {
322
+ "_id": "check-answers_content_2",
323
+ "name": "check-answers_content_2",
324
+ "_type": "content",
325
+ "_uuid": "a0f2a2e1-dccf-4a36-aeae-b8d593f7118f",
326
+ "content": "### No conditionals on this component\nThis content should always show because there are no conditionals attached to it.",
327
+ "collection": "components"
328
+ }
329
+ ],
330
+ "send_heading": "Now send your application",
331
+ "add_component": "content",
332
+ "extra_components": [
333
+ {
334
+ "_id": "check-answers_content_1",
335
+ "name": "check-answers_content_1",
336
+ "_type": "content",
337
+ "_uuid": "f5ce7110-33c5-487d-9b2e-b96b10b6ef84",
338
+ "content": "Your pet is a turtle",
339
+ "collection": "extra_components",
340
+ "conditionals": [
341
+ {
342
+ "_type": "if",
343
+ "_uuid": "ac914bb1-c4b8-44a0-bacd-2d23a6597f1a",
344
+ "expressions": [
345
+ {
346
+ "page": "07635f6d-34a8-45c8-884f-87696eba6a1f",
347
+ "field": "46c218d5-018a-482a-a66d-0d84be80f543",
348
+ "operator": "is",
349
+ "component": "612f5bc2-8766-4296-9b9c-47f92bdc4b62"
350
+ }
351
+ ]
352
+ }
353
+ ]
354
+ }
355
+ ],
356
+ "add_extra_component": "content"
357
+ },
358
+ {
359
+ "_id": "page.confirmation",
360
+ "url": "form-sent",
361
+ "_type": "page.confirmation",
362
+ "_uuid": "e6df0eaa-76a7-494a-9468-68b093e111ce",
363
+ "heading": "Application complete",
364
+ "components": [
365
+
366
+ ]
367
+ },
368
+ {
369
+ "_id": "page.show-colours",
370
+ "url": "show-colours",
371
+ "body": "",
372
+ "lede": "",
373
+ "_type": "page.content",
374
+ "_uuid": "c5525c09-c817-4280-9812-8c70b309b073",
375
+ "heading": "Show choosen colour",
376
+ "components": [
377
+ {
378
+ "_id": "show-colours_content_1",
379
+ "name": "show-colours_content_1",
380
+ "_type": "content",
381
+ "_uuid": "d53f1548-3cda-4002-9d00-5e61f854334f",
382
+ "content": "You choose YELLOW",
383
+ "collection": "components",
384
+ "conditionals": [
385
+ {
386
+ "_uuid": "ecd60ac9-c3ea-47b1-8f79-c4e42df9a9dd",
387
+ "_type": "if",
388
+ "expressions": [
389
+ {
390
+ "operator": "is",
391
+ "page": "d0f7b265-17c9-4c22-8739-d7c46d6d1426",
392
+ "component": "bfa711a6-e937-4d73-acbd-be19cc334645",
393
+ "field": "bf7b849d-550a-48bd-b31e-9331242703f5"
394
+ }
395
+ ]
396
+ }
397
+ ]
398
+ },
399
+ {
400
+ "_id": "show-colours_content_3",
401
+ "name": "show-colours_content_3",
402
+ "_type": "content",
403
+ "_uuid": "c343502a-3d4b-4c99-9da3-69eb83c1d3ff",
404
+ "content": "Show RED",
405
+ "collection": "components",
406
+ "conditionals": [
407
+ {
408
+ "_uuid": "ecd60ac9-c3ea-47b1-8f79-c4e42df9a9dd",
409
+ "_type": "if",
410
+ "expressions": [
411
+ {
412
+ "operator": "is",
413
+ "page": "d0f7b265-17c9-4c22-8739-d7c46d6d1426",
414
+ "component": "bfa711a6-e937-4d73-acbd-be19cc334645",
415
+ "field": "2d62e730-dbf4-45ee-b91f-266170b2bb29"
416
+ }
417
+ ]
418
+ }
419
+ ]
420
+ },
421
+ {
422
+ "_id": "show-colours_content_4",
423
+ "name": "show-colours_content_4",
424
+ "_type": "content",
425
+ "_uuid": "eb40d6c7-6c07-4c64-8891-f0b4d36ca517",
426
+ "content": "You choose a chocolate ice cream or the colour RED",
427
+ "collection": "components",
428
+ "conditionals": [
429
+ {
430
+ "_type": "or",
431
+ "_uuid": "ad9e5a31-8a83-4089-94d4-a1e14d2dc42a",
432
+ "expressions": [
433
+ {
434
+ "page": "be656508-ffa1-4c40-815e-ca1859c9514f",
435
+ "field": "acbfc0d8-7dbf-437f-8d9b-3c140140958e",
436
+ "operator": "is",
437
+ "component": "ea13126a-7ae2-45a5-a08f-949bd1953877"
438
+ },
439
+ {
440
+ "page": "d0f7b265-17c9-4c22-8739-d7c46d6d1426",
441
+ "field": "2d62e730-dbf4-45ee-b91f-266170b2bb29",
442
+ "operator": "contains",
443
+ "component": "bfa711a6-e937-4d73-acbd-be19cc334645"
444
+ }
445
+ ]
446
+ }
447
+ ]
448
+ }
449
+ ],
450
+ "add_component": "content",
451
+ "section_heading": ""
452
+ },
453
+ {
454
+ "_id": "page.pets",
455
+ "url": "pets",
456
+ "body": "Body section",
457
+ "lede": "",
458
+ "_type": "page.singlequestion",
459
+ "_uuid": "07635f6d-34a8-45c8-884f-87696eba6a1f",
460
+ "heading": "",
461
+ "components": [
462
+ {
463
+ "_id": "pets_radios_1",
464
+ "hint": "",
465
+ "name": "pets_radios_1",
466
+ "_type": "radios",
467
+ "_uuid": "612f5bc2-8766-4296-9b9c-47f92bdc4b62",
468
+ "items": [
469
+ {
470
+ "_id": "pets_radios_1_item_1",
471
+ "hint": "",
472
+ "name": "pets_radios_1",
473
+ "_type": "radio",
474
+ "_uuid": "9364d7e0-98ca-4375-8334-c5f9a26c7b0d",
475
+ "label": "Dog",
476
+ "value": "value-1",
477
+ "errors": {
478
+ },
479
+ "legend": "Question",
480
+ "collection": "components",
481
+ "validation": {
482
+ "required": true
483
+ }
484
+ },
485
+ {
486
+ "_id": "pets_radios_1_item_2",
487
+ "hint": "",
488
+ "name": "pets_radios_1",
489
+ "_type": "radio",
490
+ "_uuid": "7f856bb3-d079-4dd2-a10d-4a9ed310a9bd",
491
+ "label": "Cat",
492
+ "value": "value-2",
493
+ "errors": {
494
+ },
495
+ "legend": "Question",
496
+ "collection": "components",
497
+ "validation": {
498
+ "required": true
499
+ }
500
+ },
501
+ {
502
+ "_id": "pets_radios_1_item_3",
503
+ "hint": "",
504
+ "name": "pets_radios_1",
505
+ "_type": "radio",
506
+ "_uuid": "46c218d5-018a-482a-a66d-0d84be80f543",
507
+ "label": "Turtle",
508
+ "value": "value-3",
509
+ "errors": {
510
+ },
511
+ "legend": "Question",
512
+ "collection": "components",
513
+ "validation": {
514
+ "required": true
515
+ }
516
+ }
517
+ ],
518
+ "errors": {
519
+ },
520
+ "legend": "Pet choice",
521
+ "collection": "components",
522
+ "validation": {
523
+ "required": true
524
+ }
525
+ }
526
+ ],
527
+ "section_heading": ""
528
+ },
529
+ {
530
+ "_id": "page.furry",
531
+ "url": "furry",
532
+ "_type": "page.multiplequestions",
533
+ "_uuid": "e2b45429-5a5e-45c1-95f8-8970af92790a",
534
+ "heading": "Furry Pet",
535
+ "components": [
536
+ {
537
+ "_id": "furry_content_1",
538
+ "name": "furry_content_1",
539
+ "_type": "content",
540
+ "_uuid": "46a49bb2-349d-47f2-bb75-eaed3892d5d7",
541
+ "content": "Your pet is furry land dwelling pet",
542
+ "collection": "components",
543
+ "conditionals": [
544
+ {
545
+ "_type": "if",
546
+ "_uuid": "ac914bb1-c4b8-44a0-bacd-2d23a6597f1a",
547
+ "expressions": [
548
+ {
549
+ "page": "07635f6d-34a8-45c8-884f-87696eba6a1f",
550
+ "field": "46c218d5-018a-482a-a66d-0d84be80f543",
551
+ "operator": "is_not",
552
+ "component": "612f5bc2-8766-4296-9b9c-47f92bdc4b62"
553
+ }
554
+ ]
555
+ }
556
+ ]
557
+ },
558
+ {
559
+ "_id": "furry_email_1",
560
+ "hint": "",
561
+ "name": "furry_email_1",
562
+ "_type": "email",
563
+ "_uuid": "c533f44d-5d38-4258-883e-22b5653a59b1",
564
+ "label": "Email address question",
565
+ "errors": {
566
+ },
567
+ "collection": "components",
568
+ "validation": {
569
+ "email": true,
570
+ "required": true,
571
+ "max_length": 256
572
+ }
573
+ }
574
+ ],
575
+ "add_component": "email",
576
+ "section_heading": ""
577
+ }
578
+ ],
579
+ "locale": "en",
580
+ "created_at": "2023-07-12T14:56:50Z",
581
+ "created_by": "b7eff904-9fec-4c48-b6ac-4572b490a040",
582
+ "service_id": "9427e585-9f60-4c9a-b1a9-95dc304fbff2",
583
+ "version_id": "520ba187-894b-4601-972c-ffc8c7efff30",
584
+ "service_name": "conditional component test",
585
+ "configuration": {
586
+ "meta": {
587
+ "_id": "config.meta",
588
+ "_type": "config.meta",
589
+ "items": [
590
+ {
591
+ "_id": "config.meta--link",
592
+ "href": "/cookies",
593
+ "text": "Cookies",
594
+ "_type": "link"
595
+ },
596
+ {
597
+ "_id": "config.meta--link--2",
598
+ "href": "/privacy",
599
+ "text": "Privacy",
600
+ "_type": "link"
601
+ },
602
+ {
603
+ "_id": "config.meta--link--3",
604
+ "href": "/accessibility",
605
+ "text": "Accessibility",
606
+ "_type": "link"
607
+ }
608
+ ]
609
+ },
610
+ "service": {
611
+ "_id": "config.service",
612
+ "_type": "config.service"
613
+ }
614
+ },
615
+ "standalone_pages": [
616
+ {
617
+ "_id": "page.cookies",
618
+ "url": "cookies",
619
+ "body": "This form saves small files (known as 'cookies') onto your device.\r\n \r\nCookies are used to:\r\n \r\n* remember your progress\r\n* measure how you use the form so it can be updated and improved based on your needs\r\n \r\nThese cookies are not used to identify you personally.\r\n \r\nYou will normally see a message on the form before we store a cookie on your computer. Essential cookies are necessary for the form to work but you can still complete the form if you choose not to accept analytics cookies.\r\n \r\nFind out more about [how to manage cookies](https://www.aboutcookies.org/).\r\n \r\n## Essential cookies\r\n \r\nEssential cookies are required to make this form work and keep your information secure while you use it.\r\n \r\nWe use the following essential cookies: \r\n \r\n| Name | Purpose | Expires |\r\n|---|---|---|\r\n| \\_fb\\_runner\\_session | Saves your current progress on this computer and tracks inactivity periods | After 30 minutes of inactivity or when you close your browser |\r\n| analytics | Remembers whether you accept or reject analytics cookies on this form | After 1 year |\r\n \r\n## Analytics cookies\r\n \r\nAnalytics cookies collect information about how you use this form. This helps us make sure the form is meeting the needs of its users and to help us make improvements.\r\n \r\nWe use Google Analytics to learn about:\r\n \r\n* the pages you visit\r\n* how long you spend on each page\r\n* how you got to the form\r\n* what you click on while you are using the form\r\n \r\nWe do not collect or store your personal information (for example your name or address) so this information can't be used to identify who you are. We do not allow third parties to use or share our analytics data.\r\n \r\nThis form may use different versions of Google Analytics and could save some or all of the following cookies:\r\n \r\n| Name | Purpose | Expires |\r\n|---|---|---|\r\n| \\_ga | Helps us count how many people visit this form | 2 years |\r\n| \\_gid | Helps us count how many people visit this form | 1 day |\r\n| \\_ga\\_\\<container-id> | Used to persist session state | 2 years |\r\n| \\_gac\\_gb\\_\\<container-id> | Contains campaign-related information | 90 days |\r\n| \\_gat | Used to throttle request rate | 1 minute |\r\n| \\_dc\\_gtm\\_\\<property-id>| Used to throttle request rate | 1 minute |\r\n| AMP\\_TOKEN | Contains a token that can be used to retrieve a Client ID from AMP Client ID service | 30 seconds to 1 year |\r\n| \\_gac\\_\\<property-id> | Contains campaign related information | 90 days |\r\n \r\nYou can use a browser addon to [opt out of Google Analytics cookies](https://tools.google.com/dlpage/gaoptout) on all websites.",
620
+ "_type": "page.standalone",
621
+ "_uuid": "80d0ae4f-08bf-4fb5-bb76-7372485d9609",
622
+ "heading": "Cookies",
623
+ "components": [
624
+
625
+ ]
626
+ },
627
+ {
628
+ "_id": "page.privacy",
629
+ "url": "privacy",
630
+ "body": "[[Guidance notes on completing this notice](https://intranet.justice.gov.uk/documents/2018/03/privacy-notice-guidance.pdf) - delete before publishing]\r\n\r\n##[Name of your form or service]\r\n\r\nThe Ministry of Justice (MoJ) is committed to the protection and security of your personal information.\r\n\r\nIt is important that you read this notice so that you are aware of how and why we are using such information. This privacy notice describes how we collect and use personal information during and after your relationship with us, in accordance with data protection law. \r\n\r\n[Insert name – delete if not an EA or ALB] is an Executive Agency/Arm’s Length Body of the MoJ. MoJ is the data controller for the personal data used for the purposes of [Insert overarching purpose].\r\n\r\n###The type of personal data we process\r\n\r\nWe currently collect and use the following information:\r\n\r\n[list the type of personal data used e.g. name, address, contact details etc]\r\n\r\nWe also collect special categories of information, such as [delete this section if not applicable]:\r\n\r\n* race or ethnicity \r\n* political opinions\r\n* religious or philosophical beliefs\r\n* trade union membership\r\n* health, sex life or sexual orientation \r\n* genetics or biometrics\r\n* criminal convictions\r\n\r\n\r\n###How we get your personal data and why we have it\r\n\r\nMost of the personal information we process is provided to us directly by you for one of the following reasons: [List reasons e.g. providing an online service]\r\n\r\nWe also receive personal information indirectly, from the following sources in the following scenarios: [Include details of the source of the personal data unless the data is collected directly from the data subject]\r\n\r\nWe use the personal data we receive in order to: [list how you use the personal data] \r\n\r\nWe may share this information with: [enter organisations or individuals]\r\n\r\nUnder the UK General Data Protection Regulation (UK GDPR), the lawful bases we rely on for processing this information are: [delete as appropriate]\r\n\r\n* Your consent. You may withdraw your consent at any time by contacting [enter contact details].\r\n* We have a contractual obligation.\r\n* We have a legal obligation.\r\n* We have a vital interest.\r\n* We need it to perform a public task.\r\n* We have a legitimate interest.\r\n\r\n[Explain the purpose and lawful basis for processing the personal data you collect. If lawful basis is a legal obligation or public task, explain what this is e.g. refer to legislation or policy.] \r\n\r\nThe legal bases on which the MoJ processes special categories of information you have provided, is on the basis of: [delete this section if not applicable]\r\n\r\n* Your explicit consent. You may withdraw your consent at any time by contacting [insert contact details].\r\n* The processing being necessary for the MoJ in the field of employment, social security and social protection law.\r\n* The information being manifestly made public by you.\r\n* The processing being necessary for the establishment, exercise or defence of legal claims.\r\n* The substantial public interest in the MoJ [tailor as required and choose relevant [substantial public interest condition](https://ico.org.uk/for-organisations/guide-to-data-protection/guide-to-the-general-data-protection-regulation-gdpr/special-category-data/what-are-the-substantial-public-interest-conditions/)]. \r\n* The processing is necessary for historical research purposes/statistical purposes.\r\n\r\n###International data transfers\r\n\r\n[Delete one of the following paragraphs as appropriate]\r\n\r\nPersonal data is transferred to [insert name of country] for the purpose of [insert purpose]. This international transfer complies with UK data protection law [delete as appropriate].\r\n\r\n\r\nThere are no international transfers.\r\n\r\n###How we store your personal data\r\n\r\n[set out how long the information is retained, or the criteria used to determine how long the information is retained]\r\n\r\nPersonal data is stored securely and in accordance with our data retention schedule [insert link to the schedule or details of retention periods]. At the end of this period your data is [insert with it is retained as a public record or whether it is disposed of].\r\n\r\n###Your rights\r\n\r\n[This section lists all data subject rights found in the UKGDPR and the Data Protection Act 2018. You should only include those relevant to your lawful basis for processing. [Find out more about which rights apply and when](https://ico.org.uk/for-organisations/guide-to-data-protection/guide-to-the-general-data-protection-regulation-gdpr/individual-rights/)]\r\n\r\n* Your right of access - You have the right to ask us for copies of your personal information. \r\n* Your right to rectification - You have the right to ask us to rectify personal information you think is inaccurate. You also have the right to ask us to complete information you think is incomplete. \r\n* Your right to erasure - You have the right to ask us to erase your personal information in certain circumstances. \r\n* Your right to restriction of processing - You have the right to ask us to restrict the processing of your personal information in certain circumstances. \r\n* Your right to object to processing - You have the right to object to the processing of your personal information in certain circumstances. \r\n* Your right to data portability - You have the right to ask that we transfer the personal information you gave us to another organisation, or to you, in certain circumstances. \r\n\r\nDepending on the lawful basis on which your personal data is being processed, not all rights will apply.\r\n\r\nYou are not required to pay any charge for exercising your rights. If you make a request, we have one month to respond to you. If you wish to exercise your data protection rights please contact one of these teams.\r\n\r\nIf you have ever been convicted of a criminal offence, contact:\r\n\r\n\r\nBranston Registry<br> \r\nBuilding 16, S & T Store<br> \r\nBurton Road<br>\r\nBranston<br>\r\nBurton-on-Trent<br> \r\nStaffordshire<br>\r\nDE14 3EG\r\nEmail: <data.access1@justice.gov.uk>\r\n\r\nOtherwise, contact:\r\n\r\n\r\nDisclosure Team<br>\r\nPost point 10.38<br>\r\n102 petty France<br>\r\nLondon<br>\r\nSW1H 9AJ\r\nEmail: <data.access@justice.gov.uk> \r\n\r\n###How to complain\r\n\r\nIf you have any concerns about our use of your personal data, you can contact the MoJ data protection officer:\r\n\r\nData Protection Officer<br>\r\nMinistry of Justice<br>\r\n3rd Floor, Post Point 3.20<br>\r\n10 South Colonnades<br>\r\nCanary Wharf<br>\r\nLondon<br>\r\nE14 4PU\r\n\r\nEmail: <dpo@justice.gov.uk> \r\n\r\n\r\nYou can also complain to the Information Commissioner’s Office (ICO) if you are unhappy with how we have used your data:\r\n\r\n\r\nInformation Commissioner’s Office<br>\r\nWycliffe House<br>\r\nWater Lane<br>\r\nWilmslow<br>\r\nCheshire<br>\r\nSK9 5AF\r\n\r\nTelephone: 0303 123 1113<br>\r\n[ICO website](https://www.ico.org.uk)\r\n\r\nDate of last review: [Insert publication or update date]",
631
+ "_type": "page.standalone",
632
+ "_uuid": "d22ddf83-8803-4efd-a2d8-1f9b483d481d",
633
+ "heading": "Privacy notice",
634
+ "components": [
635
+
636
+ ]
637
+ },
638
+ {
639
+ "_id": "page.accessibility",
640
+ "url": "accessibility",
641
+ "body": "This accessibility statement applies to [describe your form here - for example, the general enquiries form for the CICA]. There is a separate [accessibility statement for the main GOV.UK website](https://www.gov.uk/help/accessibility-statement).\r\n\r\n###Using this online form\r\n\r\nThis form was built using MoJ Forms, a tool developed by the Ministry of Justice, and uses components from the [GOV.UK Design System](https://design-system.service.gov.uk/).\r\n\r\n[insert your organisation here] is responsible for the content of this online form. The Ministry of Justice is responsible for its technical aspects.\r\n\r\nWe want as many people as possible to be able to use this online form. For example, that means you should be able to:\r\n\r\n- change colours, contrast levels and fonts\r\n- zoom in up to 300% without the text spilling off the screen\r\n- navigate the form using just a keyboard\r\n- navigate the form using speech recognition software\r\n- listen to the form using a screen reader (including recent versions of JAWS, NVDA and VoiceOver)\r\n\r\nWe’ve also made the text as simple as possible to understand.\r\n\r\n[AbilityNet](https://mcmw.abilitynet.org.uk/) has advice on making your device easier to use if you have a disability.\r\n\r\n###Feedback and contact information\r\n\r\nIf you need information on this website in a different format:\r\n\r\n[insert your contact details for user requests here - add other channels, such as text phones or Relay UK, as required]\r\n\r\n- email: [your email address]\r\n- call: [your telephone number]\r\n- [Hours - e.g. Monday to Friday, 9am to 5pm]\r\n\r\nWe'll consider your request and get back to you in [add your SLA - e.g. a week or 5 working days].\r\n\r\n###Reporting accessibility problems with this form\r\n\r\nWe’re always looking to improve the accessibility of this form. If you find any problems not listed on this page or think we’re not meeting accessibility requirements, contact:\r\n\r\n[insert your contact details for user feedback here - add other channels, such as text phones or Relay UK, as required]\r\n\r\n- email: [your email address]\r\n- call: [your telephone number]\r\n- [Hours - e.g. Monday to Friday, 9am to 5pm]\r\n\r\n###Enforcement procedure\r\n\r\nThe Equality and Human Rights Commission (EHRC) is responsible for enforcing the Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018 (the ‘accessibility regulations’). If you’re not happy with how we respond to your complaint, contact the [Equality Advisory and Support Service (EASS)](https://www.equalityadvisoryservice.com/).\r\n\r\n###Technical information about this online form’s accessibility\r\n\r\nWe are committed to making our online forms and services accessible, in accordance with the Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018.\r\n\r\n####Compliance status\r\n\r\nThis online form is fully compliant with the [Web Content Accessibility Guidelines version 2.1 AA standard](https://www.w3.org/TR/WCAG21/)\r\n\r\n###Preparation of this accessibility statement\r\n\r\nThis statement was prepared on [date when it was first published]. It was last reviewed on [date when it was last reviewed].\r\n\r\nThis form was last tested on [date when you performed your basic accessibility check].\r\n\r\nIn order to test the compliance of all forms built using the MoJ Forms tool, the Ministry of Justice commissioned The Digital Accessibility Centre (DAC) to carry out a WCAG 2.1 AA level audit of a sample form. This included extensive testing by users with a wide range of disabilities. The audit was performed on 8 April 2021. The audit highlighted a number of non-compliance issues which were fixed on 11 May 2021.\r\n\r\nIn addition, this form was tested by [insert team or organisation here]. It was tested using the [WAVE Web Accessibility Evaluation Tool](https://wave.webaim.org/) following guidance from the Ministry of Justice and the Government Digital Service (GDS).\r\n\r\n###What we’re doing to improve accessibility\r\n\r\nWe will monitor the accessibility of this website on an ongoing basis and fix any accessibility issues reported to us.",
642
+ "_type": "page.standalone",
643
+ "_uuid": "1539fd9b-efb7-42d4-a1b7-618116fa30d8",
644
+ "heading": "Accessibility statement",
645
+ "components": [
646
+
647
+ ]
648
+ }
649
+ ]
650
+ }
@@ -689,7 +689,21 @@
689
689
  "_type": "content",
690
690
  "_uuid": "b065ff4f-90c5-4ba2-b4ac-c984a9dd2470",
691
691
  "content": "Take the cannoli.",
692
- "collection": "components"
692
+ "collection": "components",
693
+ "conditionals": [
694
+ {
695
+ "_type": "if",
696
+ "_uuid": "98cfd843-7c02-4534-9055-201487e9be16",
697
+ "expressions": [
698
+ {
699
+ "page": "68fbb180-9a2a-48f6-9da6-545e28b8d35a",
700
+ "field": "c5571937-9388-4411-b5fa-34ddf9bc4ca0",
701
+ "operator": "is",
702
+ "component": "ac41be35-914e-4b22-8683-f5477716b7d4"
703
+ }
704
+ ]
705
+ }
706
+ ]
693
707
  }
694
708
  ],
695
709
  "send_heading": "Now send your application",
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '3.2.0'.freeze
2
+ VERSION = '3.2.1'.freeze
3
3
  end
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: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MoJ Forms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-27 00:00:00.000000000 Z
11
+ date: 2023-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder
@@ -337,7 +337,8 @@ files:
337
337
  - app/models/metadata_presenter/coordinates.rb
338
338
  - app/models/metadata_presenter/date_field.rb
339
339
  - app/models/metadata_presenter/email_confirmation.rb
340
- - app/models/metadata_presenter/evaluate_conditionals.rb
340
+ - app/models/metadata_presenter/evaluate_branch_conditionals.rb
341
+ - app/models/metadata_presenter/evaluate_content_conditionals.rb
341
342
  - app/models/metadata_presenter/expression.rb
342
343
  - app/models/metadata_presenter/file_uploader.rb
343
344
  - app/models/metadata_presenter/flow.rb
@@ -536,6 +537,7 @@ files:
536
537
  - fixtures/branching_8.png
537
538
  - fixtures/branching_9.json
538
539
  - fixtures/branching_9.png
540
+ - fixtures/conditional_content.json
539
541
  - fixtures/countries.json
540
542
  - fixtures/exit_only_service.json
541
543
  - fixtures/invalid_content_page.json