metadata_presenter 1.6.1 → 1.7.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03253a540a4143ec0d42a0cac9b78f9eba498a3e293abdcb3638cba9bdf35050
4
- data.tar.gz: a54cc6a26c040cd918562d283a124dc938ecf676484bc63e2e9aa6bb3d7032c7
3
+ metadata.gz: f3ed3876afc6593e2b6108203f7b46401212fc213191d6db6c9a7f3322f6b342
4
+ data.tar.gz: c60618fb9af15d327a198cc8cbcbca389ffc7f3554a1bdcf63596b8d024ef727
5
5
  SHA512:
6
- metadata.gz: 6192e319eb945dcf609b359d9130b9e53f5bcaf0a4d4756eedd97347a939afcd000c7a9f80b79c678301a42aeafa5f36df158c867d75c774aef44f2420e854f3
7
- data.tar.gz: 7e8b14eb5fc34db77fc544baaac72ad2fe18a0c47691b8972fcc449707d3bf1dbf8e83e71f52cba8965ca1545c01f9cf612c94797d2286c217013812c9cdf752
6
+ metadata.gz: 2d294dd3c15cac7c56a99c37b0c59d58a4bfba7ecec43ef17548b587e74113e9b1161a99722b5da9c2d3593623e0aa425f8a55b8778364541a859dd9784cd03a
7
+ data.tar.gz: 35a4408bbe40c5d13cd7bde8924a70380f6ac9d19356050211e1b6ee5683595f5b709b5a275fa7e3d74dac373578d96b8c8af3d08c39775f5d9a286844777159
@@ -4,24 +4,32 @@ module MetadataPresenter
4
4
  attr_accessor :service, :flow, :user_data
5
5
 
6
6
  def page
7
- results = conditions.map do |condition|
8
- condition.criterias.map do |criteria|
7
+ evaluated_page_uuid = page_uuid || flow.default_next
8
+
9
+ service.find_page_by_uuid(evaluated_page_uuid)
10
+ end
11
+
12
+ def page_uuid
13
+ @results ||= conditions.map do |condition|
14
+ evaluated_criterias = condition.criterias.map do |criteria|
9
15
  criteria.service = service
10
16
 
11
- next unless Operator.new(
17
+ Operator.new(
12
18
  criteria.operator
13
- ).evaluate(criteria.field_label, user_data[criteria.criteria_component.id])
19
+ ).evaluate(
20
+ criteria.field_label,
21
+ user_data[criteria.criteria_component.id]
22
+ )
23
+ end
14
24
 
25
+ if condition.condition_type == 'or' && evaluated_criterias.any?
26
+ condition.next
27
+ elsif evaluated_criterias.all?
15
28
  condition.next
16
29
  end
17
30
  end
18
31
 
19
- page_uuid = results.flatten.uniq.compact
20
- if page_uuid.present?
21
- service.find_page_by_uuid(page_uuid.first)
22
- else
23
- service.find_page_by_uuid(flow.default_next)
24
- end
32
+ @results.flatten.compact.first
25
33
  end
26
34
 
27
35
  delegate :conditions, to: :flow
@@ -1,7 +1,7 @@
1
1
  module MetadataPresenter
2
2
  class Flow < MetadataPresenter::Metadata
3
3
  def branch?
4
- type == 'branch'
4
+ type == 'flow.branch'
5
5
  end
6
6
 
7
7
  def default_next
@@ -49,11 +49,11 @@ module MetadataPresenter
49
49
  end
50
50
 
51
51
  def current_page_flow
52
- service.flow(current_page_uuid)
52
+ service.flow_object(current_page_uuid)
53
53
  end
54
54
 
55
55
  def next_flow
56
- service.flow(current_page_flow.default_next)
56
+ service.flow_object(current_page_flow.default_next)
57
57
  end
58
58
 
59
59
  def next_flow_branch_object?
@@ -2,6 +2,7 @@ module MetadataPresenter
2
2
  class PageAnswers
3
3
  include ActiveModel::Model
4
4
  include ActiveModel::Validations
5
+ include ActionView::Helpers
5
6
  attr_reader :page, :answers, :uploaded_files
6
7
 
7
8
  def initialize(page, answers)
@@ -30,7 +31,7 @@ module MetadataPresenter
30
31
  elsif component && component.type == 'checkboxes'
31
32
  answers[method_name.to_s].to_a
32
33
  else
33
- answers[method_name.to_s]
34
+ sanitize(answers[method_name.to_s])
34
35
  end
35
36
  end
36
37
 
@@ -40,10 +41,10 @@ module MetadataPresenter
40
41
  return {} unless file_details
41
42
 
42
43
  if file_details.is_a?(Hash) || file_details.is_a?(ActionController::Parameters)
43
- file_details
44
+ file_details.merge('original_filename' => sanitize(file_details['original_filename']))
44
45
  else
45
46
  {
46
- 'original_filename' => file_details.original_filename,
47
+ 'original_filename' => sanitize(file_details.original_filename),
47
48
  'content_type' => file_details.content_type,
48
49
  'tempfile' => file_details.tempfile.path.to_s
49
50
  }
@@ -62,7 +63,7 @@ module MetadataPresenter
62
63
  GOVUKDesignSystemFormBuilder::Elements::Date::SEGMENTS[:month],
63
64
  GOVUKDesignSystemFormBuilder::Elements::Date::SEGMENTS[:year]
64
65
  ].map do |segment|
65
- answers["#{component_id}(#{segment})"]
66
+ sanitize(answers["#{component_id}(#{segment})"])
66
67
  end
67
68
  end
68
69
  end
@@ -7,7 +7,7 @@ module MetadataPresenter
7
7
  # what happens when a user enters in the middle of the flow
8
8
  return if no_current_or_referrer_pages? || service.no_back_link?(current_page)
9
9
 
10
- if flow.present?
10
+ if service.flow.present?
11
11
  return referrer_page if return_to_referrer?
12
12
 
13
13
  TraversedPages.new(service, user_data, current_page).last
@@ -16,10 +16,6 @@ module MetadataPresenter
16
16
  end
17
17
  end
18
18
 
19
- def flow
20
- service.metadata['flow']
21
- end
22
-
23
19
  private
24
20
 
25
21
  def referrer_page
@@ -5,8 +5,8 @@ class MetadataPresenter::Service < MetadataPresenter::Metadata
5
5
  end
6
6
  end
7
7
 
8
- def flow(page_uuid)
9
- MetadataPresenter::Flow.new(metadata.flow[page_uuid])
8
+ def flow_object(uuid)
9
+ MetadataPresenter::Flow.new(metadata.flow[uuid])
10
10
  rescue StandardError
11
11
  nil
12
12
  end
@@ -14,10 +14,10 @@ module MetadataPresenter
14
14
  def all
15
15
  page_uuid = service.start_page.uuid
16
16
 
17
- service.metadata['flow'].size.times do
17
+ service.flow.size.times do
18
18
  break if page_uuid == current_page.uuid
19
19
 
20
- flow_object = service.flow(page_uuid)
20
+ flow_object = service.flow_object(page_uuid)
21
21
 
22
22
  if flow_object.branch?
23
23
  page = EvaluateConditions.new(
@@ -0,0 +1,8 @@
1
+ {
2
+ "_id": "flow.branch",
3
+ "_type": "flow.branch",
4
+ "next": {
5
+ "default": "",
6
+ "conditions": []
7
+ }
8
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "condition_type": "",
3
+ "next": "",
4
+ "criterias": []
5
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "operator": "",
3
+ "page": "",
4
+ "component": "",
5
+ "field": ""
6
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "_id": "flow.page",
3
+ "_type": "flow.page",
4
+ "next": {
5
+ "default": ""
6
+ }
7
+ }
@@ -3,25 +3,25 @@
3
3
  "_type": "service.base",
4
4
  "flow": {
5
5
  "cf6dc32f-502c-4215-8c27-1151a45735bb": {
6
- "_type": "page",
6
+ "_type": "flow.page",
7
7
  "next": {
8
8
  "default": "9e1ba77f-f1e5-42f4-b090-437aa9af7f73"
9
9
  }
10
10
  },
11
11
  "9e1ba77f-f1e5-42f4-b090-437aa9af7f73": {
12
- "_type": "page",
12
+ "_type": "flow.page",
13
13
  "next": {
14
14
  "default": "68fbb180-9a2a-48f6-9da6-545e28b8d35a"
15
15
  }
16
16
  },
17
17
  "68fbb180-9a2a-48f6-9da6-545e28b8d35a": {
18
- "_type": "page",
18
+ "_type": "flow.page",
19
19
  "next": {
20
20
  "default": "09e91fd9-7a46-4840-adbc-244d545cfef7"
21
21
  }
22
22
  },
23
23
  "09e91fd9-7a46-4840-adbc-244d545cfef7": {
24
- "_type": "branch",
24
+ "_type": "flow.branch",
25
25
  "next": {
26
26
  "default": "0b297048-aa4d-49b6-ac74-18e069118185",
27
27
  "conditions": [
@@ -41,19 +41,19 @@
41
41
  }
42
42
  },
43
43
  "e8708909-922e-4eaf-87a5-096f7a713fcb": {
44
- "_type": "page",
44
+ "_type": "flow.page",
45
45
  "next": {
46
46
  "default": "0b297048-aa4d-49b6-ac74-18e069118185"
47
47
  }
48
48
  },
49
49
  "0b297048-aa4d-49b6-ac74-18e069118185": {
50
- "_type": "page",
50
+ "_type": "flow.page",
51
51
  "next": {
52
52
  "default": "ffadeb22-063b-4e4f-9502-bd753c706b1d"
53
53
  }
54
54
  },
55
55
  "ffadeb22-063b-4e4f-9502-bd753c706b1d": {
56
- "_type": "branch",
56
+ "_type": "flow.branch",
57
57
  "next": {
58
58
  "default": "05c3306c-0a39-42d2-9e0f-93fd49248f4e",
59
59
  "conditions": [
@@ -85,25 +85,25 @@
85
85
  }
86
86
  },
87
87
  "d4342dfd-0d09-4a91-a0ea-d7fd67e706cc": {
88
- "_type": "page",
88
+ "_type": "flow.page",
89
89
  "next": {
90
90
  "default": "05c3306c-0a39-42d2-9e0f-93fd49248f4e"
91
91
  }
92
92
  },
93
93
  "91e9f7c6-2f75-4b7d-9eb5-0cf352f7be66": {
94
- "_type": "page",
94
+ "_type": "flow.page",
95
95
  "next": {
96
96
  "default": "05c3306c-0a39-42d2-9e0f-93fd49248f4e"
97
97
  }
98
98
  },
99
99
  "05c3306c-0a39-42d2-9e0f-93fd49248f4e": {
100
- "_type": "page",
100
+ "_type": "flow.page",
101
101
  "next": {
102
102
  "default": "1d02e508-5953-4eca-af2f-9d67511c8648"
103
103
  }
104
104
  },
105
105
  "1d02e508-5953-4eca-af2f-9d67511c8648": {
106
- "_type": "branch",
106
+ "_type": "flow.branch",
107
107
  "next": {
108
108
  "default": "ef2cafe3-37e2-4533-9b0c-09a970cd38d4",
109
109
  "conditions": [
@@ -123,19 +123,19 @@
123
123
  }
124
124
  },
125
125
  "8002df6e-29ab-4cdf-b520-1d7bb931a28f": {
126
- "_type": "page",
126
+ "_type": "flow.page",
127
127
  "next": {
128
128
  "default": "ef2cafe3-37e2-4533-9b0c-09a970cd38d4"
129
129
  }
130
130
  },
131
131
  "ef2cafe3-37e2-4533-9b0c-09a970cd38d4": {
132
- "_type": "page",
132
+ "_type": "flow.page",
133
133
  "next": {
134
134
  "default": "cf8b3e18-dacf-4e91-92e1-018035961003"
135
135
  }
136
136
  },
137
137
  "cf8b3e18-dacf-4e91-92e1-018035961003": {
138
- "_type": "branch",
138
+ "_type": "flow.branch",
139
139
  "next": {
140
140
  "default": "0c022e95-0748-4dda-8ba5-12fd1d2f596b",
141
141
  "conditions": [
@@ -155,21 +155,21 @@
155
155
  }
156
156
  },
157
157
  "b5efc09c-ece7-45ae-b0b3-8a7905e25040": {
158
- "_type": "page",
158
+ "_type": "flow.page",
159
159
  "next": {
160
160
  "default": "0c022e95-0748-4dda-8ba5-12fd1d2f596b"
161
161
  }
162
162
  },
163
163
  "0c022e95-0748-4dda-8ba5-12fd1d2f596b": {
164
- "_type": "page",
164
+ "_type": "flow.page",
165
165
  "next": {
166
166
  "default": "618b7537-b42b-4551-ae7d-053afa4d9ca9"
167
167
  }
168
168
  },
169
169
  "618b7537-b42b-4551-ae7d-053afa4d9ca9": {
170
- "_type": "branch",
170
+ "_type": "flow.branch",
171
171
  "next": {
172
- "default": "e337070b-f636-49a3-a65c-f506675265f0",
172
+ "default": "dc7454f9-4186-48d7-b055-684d57bbcdc7",
173
173
  "conditions": [
174
174
  {
175
175
  "condition_type": "if",
@@ -199,25 +199,161 @@
199
199
  }
200
200
  },
201
201
  "bc666714-c0a2-4674-afe5-faff2e20d847": {
202
- "_type": "page",
202
+ "_type": "flow.page",
203
203
  "next": {
204
- "default": "e337070b-f636-49a3-a65c-f506675265f0"
204
+ "default": "dc7454f9-4186-48d7-b055-684d57bbcdc7"
205
205
  }
206
206
  },
207
207
  "e2887f44-5e8d-4dc0-b1de-496ab6039430": {
208
- "_type": "page",
208
+ "_type": "flow.page",
209
+ "next": {
210
+ "default": "dc7454f9-4186-48d7-b055-684d57bbcdc7"
211
+ }
212
+ },
213
+ "dc7454f9-4186-48d7-b055-684d57bbcdc7": {
214
+ "_type": "flow.page",
215
+ "next": {
216
+ "default": "84a347fc-8d4b-486a-9996-6a86fa9544c5"
217
+ }
218
+ },
219
+ "84a347fc-8d4b-486a-9996-6a86fa9544c5": {
220
+ "_type": "flow.branch",
221
+ "next": {
222
+ "default": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb",
223
+ "conditions": [
224
+ {
225
+ "condition_type": "or",
226
+ "next": "2cc66e51-2c14-4023-86bf-ded49887cdb2",
227
+ "criterias": [
228
+ {
229
+ "operator": "is",
230
+ "page": "dc7454f9-4186-48d7-b055-684d57bbcdc7",
231
+ "component": "5ca01e56-94de-4c33-b5fc-74697e5b95cc",
232
+ "field": "bd14bf31-427e-4267-9926-a18c167fe604"
233
+ },
234
+ {
235
+ "operator": "is",
236
+ "page": "dc7454f9-4186-48d7-b055-684d57bbcdc7",
237
+ "component": "5ca01e56-94de-4c33-b5fc-74697e5b95cc",
238
+ "field": "eb720ef7-bcaf-4c73-8972-6fc80dca6245"
239
+ }
240
+ ]
241
+ },
242
+ {
243
+ "condition_type": "and",
244
+ "next": "f6c51f88-7be8-4cb7-bbfc-6c905727a051",
245
+ "criterias": [
246
+ {
247
+ "operator": "is",
248
+ "page": "68fbb180-9a2a-48f6-9da6-545e28b8d35a",
249
+ "component": "ac41be35-914e-4b22-8683-f5477716b7d4",
250
+ "field": "c5571937-9388-4411-b5fa-34ddf9bc4ca0"
251
+ },
252
+ {
253
+ "operator": "is",
254
+ "page": "dc7454f9-4186-48d7-b055-684d57bbcdc7",
255
+ "component": "5ca01e56-94de-4c33-b5fc-74697e5b95cc",
256
+ "field": "0c4192eb-1441-4f10-b00a-0f03b756269e"
257
+ }
258
+ ]
259
+ }
260
+ ]
261
+ }
262
+ },
263
+ "2cc66e51-2c14-4023-86bf-ded49887cdb2": {
264
+ "_type": "flow.page",
265
+ "next": {
266
+ "default": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb"
267
+ }
268
+ },
269
+ "f6c51f88-7be8-4cb7-bbfc-6c905727a051": {
270
+ "_type": "flow.page",
271
+ "next": {
272
+ "default": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb"
273
+ }
274
+ },
275
+ "48357db5-7c06-4e85-94b1-5e1c9d8f39eb": {
276
+ "_type": "flow.page",
277
+ "next": {
278
+ "default": "1079b5b8-abd0-4bf6-aaac-1f01e69e3b39"
279
+ }
280
+ },
281
+ "1079b5b8-abd0-4bf6-aaac-1f01e69e3b39": {
282
+ "_type": "flow.branch",
283
+ "next": {
284
+ "default": "941137d7-a1da-43fd-994a-98a4f9ea6d46",
285
+ "conditions": [
286
+ {
287
+ "condition_type": "and",
288
+ "next": "56e80942-d0a4-405a-85cd-bd1b100013d6",
289
+ "criterias": [
290
+ {
291
+ "operator": "is",
292
+ "page": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb",
293
+ "component": "3a430712-a75f-4412-836d-4ec7b2cb1ac9",
294
+ "field": "30258b55-ec04-4278-86b7-8382cbd34bea"
295
+ },
296
+ {
297
+ "operator": "is",
298
+ "page": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb",
299
+ "component": "3a430712-a75f-4412-836d-4ec7b2cb1ac9",
300
+ "field": "9339d86e-b53c-42c0-ab6e-1ab3e2340873"
301
+ },
302
+ {
303
+ "operator": "is",
304
+ "page": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb",
305
+ "component": "3a430712-a75f-4412-836d-4ec7b2cb1ac9",
306
+ "field": "5d650e5d-57ac-42a1-9348-c1b93248753a"
307
+ }
308
+ ]
309
+ },
310
+ {
311
+ "condition_type": "or",
312
+ "next": "6324cca4-7770-4765-89b9-1cdc41f49c8b",
313
+ "criterias": [
314
+ {
315
+ "operator": "is",
316
+ "page": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb",
317
+ "component": "3a430712-a75f-4412-836d-4ec7b2cb1ac9",
318
+ "field": "6b82b4e4-6dfd-4b3c-b6ed-2d71be0980bf"
319
+ },
320
+ {
321
+ "operator": "is",
322
+ "page": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb",
323
+ "component": "3a430712-a75f-4412-836d-4ec7b2cb1ac9",
324
+ "field": "8c2c6161-7309-4e4f-9f3c-9fa629bcb459"
325
+ }
326
+ ]
327
+ }
328
+ ]
329
+ }
330
+ },
331
+ "941137d7-a1da-43fd-994a-98a4f9ea6d46": {
332
+ "_type": "flow.page",
333
+ "next": {
334
+ "default": "e337070b-f636-49a3-a65c-f506675265f0"
335
+ }
336
+ },
337
+ "56e80942-d0a4-405a-85cd-bd1b100013d6": {
338
+ "_type": "flow.page",
339
+ "next": {
340
+ "default": "e337070b-f636-49a3-a65c-f506675265f0"
341
+ }
342
+ },
343
+ "6324cca4-7770-4765-89b9-1cdc41f49c8b": {
344
+ "_type": "flow.page",
209
345
  "next": {
210
346
  "default": "e337070b-f636-49a3-a65c-f506675265f0"
211
347
  }
212
348
  },
213
349
  "e337070b-f636-49a3-a65c-f506675265f0": {
214
- "_type": "page",
350
+ "_type": "flow.page",
215
351
  "next": {
216
352
  "default": "778e364b-9a7f-4829-8eb2-510e08f156a3"
217
353
  }
218
354
  },
219
355
  "778e364b-9a7f-4829-8eb2-510e08f156a3": {
220
- "_type": "page",
356
+ "_type": "flow.page",
221
357
  "next": {
222
358
  "default": ""
223
359
  }
@@ -420,6 +556,7 @@
420
556
  "url": "favourite-fruit",
421
557
  "_type": "page.singlequestion",
422
558
  "_uuid": "0b297048-aa4d-49b6-ac74-18e069118185",
559
+ "heading": "",
423
560
  "components": [
424
561
  {
425
562
  "_id": "favourite-fruit_radios_1",
@@ -463,6 +600,7 @@
463
600
  "url": "apple-juice",
464
601
  "_type": "page.singlequestion",
465
602
  "_uuid": "d4342dfd-0d09-4a91-a0ea-d7fd67e706cc",
603
+ "heading": "",
466
604
  "components": [
467
605
  {
468
606
  "_id": "apple-juice_radios_1",
@@ -499,6 +637,7 @@
499
637
  "url": "orange-juice",
500
638
  "_type": "page.singlequestion",
501
639
  "_uuid": "91e9f7c6-2f75-4b7d-9eb5-0cf352f7be66",
640
+ "heading": "",
502
641
  "components": [
503
642
  {
504
643
  "_id": "orange-juice_radios_1",
@@ -535,6 +674,7 @@
535
674
  "url": "favourite-band",
536
675
  "_type": "page.singlequestion",
537
676
  "_uuid": "05c3306c-0a39-42d2-9e0f-93fd49248f4e",
677
+ "heading": "",
538
678
  "components": [
539
679
  {
540
680
  "_id": "favourite-band_radios_1",
@@ -571,6 +711,7 @@
571
711
  "url": "music-app",
572
712
  "_type": "page.singlequestion",
573
713
  "_uuid": "8002df6e-29ab-4cdf-b520-1d7bb931a28f",
714
+ "heading": "",
574
715
  "components": [
575
716
  {
576
717
  "_id": "music-app_radios_1",
@@ -607,6 +748,7 @@
607
748
  "url": "best-formbuilder",
608
749
  "_type": "page.singlequestion",
609
750
  "_uuid": "ef2cafe3-37e2-4533-9b0c-09a970cd38d4",
751
+ "heading": "",
610
752
  "components": [
611
753
  {
612
754
  "_id": "best-formbuilder_radios_1",
@@ -773,6 +915,230 @@
773
915
  ],
774
916
  "section_heading": ""
775
917
  },
918
+ {
919
+ "_id": "page.marvel-series",
920
+ "url": "marvel-series",
921
+ "_type": "page.singlequestion",
922
+ "_uuid": "dc7454f9-4186-48d7-b055-684d57bbcdc7",
923
+ "heading": "",
924
+ "components": [
925
+ {
926
+ "_id": "marvel-series_radios_1",
927
+ "hint": "",
928
+ "name": "marvel-series_radios_1",
929
+ "_type": "radios",
930
+ "_uuid": "5ca01e56-94de-4c33-b5fc-74697e5b95cc",
931
+ "items": [
932
+ {
933
+ "_id": "marvel-series_radios_1_item_1",
934
+ "hint": "",
935
+ "_type": "radio",
936
+ "_uuid": "0c4192eb-1441-4f10-b00a-0f03b756269e",
937
+ "label": "WandaVision"
938
+ },
939
+ {
940
+ "_id": "marvel-series_radios_1_item_2",
941
+ "hint": "",
942
+ "_type": "radio",
943
+ "_uuid": "bd14bf31-427e-4267-9926-a18c167fe604",
944
+ "label": "The Falcon and the Winter Soldier"
945
+ },
946
+ {
947
+ "_id": "marvel-series_radios_1_item_2",
948
+ "hint": "",
949
+ "_type": "radio",
950
+ "_uuid": "eb720ef7-bcaf-4c73-8972-6fc80dca6245",
951
+ "label": "Loki"
952
+ },
953
+ {
954
+ "_id": "marvel-series_radios_1_item_3",
955
+ "hint": "",
956
+ "_type": "radio",
957
+ "_uuid": "d762e328-18dc-4861-bca8-d104609b8299",
958
+ "label": "Hawkeye"
959
+ }
960
+ ],
961
+ "errors": {},
962
+ "legend": "What is the best marvel series?",
963
+ "validation": {
964
+ "required": true
965
+ }
966
+ }
967
+ ]
968
+ },
969
+ {
970
+ "_id": "page.marvel-quotes",
971
+ "url": "marvel-quotes",
972
+ "body": "Marvel quotes",
973
+ "lede": "",
974
+ "_type": "page.content",
975
+ "_uuid": "2cc66e51-2c14-4023-86bf-ded49887cdb2",
976
+ "heading": "Loki",
977
+ "components": [
978
+ {
979
+ "_id": "marvel-quotes_content_1",
980
+ "name": "marvel-quotes_content_1",
981
+ "_type": "content",
982
+ "_uuid": "5cede2fa-5001-4d6a-965c-30addc3c4496",
983
+ "content": "I am Loki of Asgard, and I am burdened with glorious purpose."
984
+ },
985
+ {
986
+ "_id": "marvel-quotes_content_2",
987
+ "name": "marvel-quotes_content_2",
988
+ "_type": "content",
989
+ "_uuid": "816b6afd-4649-455a-b10d-62cb5acb4584",
990
+ "content": "So Who Are You Fighting Now ... Gandalf?"
991
+ }
992
+ ],
993
+ "section_heading": ""
994
+ },
995
+ {
996
+ "_id": "page.other-quotes",
997
+ "url": "other-quotes",
998
+ "body": "Other quotes",
999
+ "lede": "",
1000
+ "_type": "page.content",
1001
+ "_uuid": "f6c51f88-7be8-4cb7-bbfc-6c905727a051",
1002
+ "heading": "Other quotes",
1003
+ "components": [
1004
+ {
1005
+ "_id": "other-quotes_content_1",
1006
+ "name": "other-quotes_content_1",
1007
+ "_type": "content",
1008
+ "_uuid": "2535a867-deab-457b-91aa-c006e3c73d63",
1009
+ "content": "- How we doing? - Same as always... - That bad, huh?"
1010
+ },
1011
+ {
1012
+ "_id": "other-quotes_content_2",
1013
+ "name": "other-quotes_content_2",
1014
+ "_type": "content",
1015
+ "_uuid": "816b6afd-4649-455a-b10d-62cb5acb4584",
1016
+ "content": "Are you using your night vision, Vision?"
1017
+ }
1018
+ ],
1019
+ "section_heading": ""
1020
+ },
1021
+ {
1022
+ "_id": "page.best-arnold-quote",
1023
+ "url": "best-arnold-quote",
1024
+ "body": "Body section",
1025
+ "lede": "",
1026
+ "_type": "page.singlequestion",
1027
+ "_uuid": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb",
1028
+ "heading": "Question",
1029
+ "components": [
1030
+ {
1031
+ "_id": "best-arnold-quote_checkboxes_1",
1032
+ "hint": "",
1033
+ "name": "best-arnold-quote_checkboxes_1",
1034
+ "_type": "checkboxes",
1035
+ "_uuid": "3a430712-a75f-4412-836d-4ec7b2cb1ac9",
1036
+ "items": [
1037
+ {
1038
+ "_id": "best-arnold-quote_checkboxes_1_item_1",
1039
+ "hint": "",
1040
+ "name": "best-arnold-quote_checkboxes_1",
1041
+ "_type": "checkbox",
1042
+ "_uuid": "30258b55-ec04-4278-86b7-8382cbd34bea",
1043
+ "label": "You are not you. You are me"
1044
+ },
1045
+ {
1046
+ "_id": "best-arnold-quote_checkboxes_1_item_2",
1047
+ "hint": "",
1048
+ "name": "best-arnold-quote_checkboxes_1",
1049
+ "_type": "checkbox",
1050
+ "_uuid": "9339d86e-b53c-42c0-ab6e-1ab3e2340873",
1051
+ "label": "Get to the chopper"
1052
+ },
1053
+ {
1054
+ "_id": "best-arnold-quote_checkboxes_1_item_3",
1055
+ "hint": "",
1056
+ "name": "best-arnold-quote_checkboxes_1",
1057
+ "_type": "checkbox",
1058
+ "_uuid": "5d650e5d-57ac-42a1-9348-c1b93248753a",
1059
+ "label": "You have been terminated"
1060
+ },
1061
+ {
1062
+ "_id": "best-arnold-quote_checkboxes_1_item_4",
1063
+ "hint": "",
1064
+ "name": "best-arnold-quote_checkboxes_1",
1065
+ "_type": "checkbox",
1066
+ "_uuid": "6b82b4e4-6dfd-4b3c-b6ed-2d71be0980bf",
1067
+ "label": "I am GROOT"
1068
+ },
1069
+ {
1070
+ "_id": "best-arnold-quote_checkboxes_1_item_5",
1071
+ "hint": "",
1072
+ "name": "best-arnold-quote_checkboxes_1",
1073
+ "_type": "checkbox",
1074
+ "_uuid": "8c2c6161-7309-4e4f-9f3c-9fa629bcb459",
1075
+ "label": "Dance Off, Bro."
1076
+ }
1077
+ ],
1078
+ "legend": "Select all Arnold Schwarzenegger quotes",
1079
+ "validation": {
1080
+ "required": true
1081
+ }
1082
+ }
1083
+ ]
1084
+ },
1085
+ {
1086
+ "_id": "page.arnold-right-answers",
1087
+ "url": "arnold-right-answers",
1088
+ "body": "You are right! Now, talk to the hand!",
1089
+ "lede": "",
1090
+ "_type": "page.content",
1091
+ "_uuid": "56e80942-d0a4-405a-85cd-bd1b100013d6",
1092
+ "heading": "You are right",
1093
+ "components": [
1094
+ {
1095
+ "_id": "arnold-right-answers_content_1",
1096
+ "name": "arnold-right-answers_content_1",
1097
+ "_type": "content",
1098
+ "_uuid": "9a7948f1-9e9a-4273-b52e-e2917c79f37c",
1099
+ "content": "You are right! Now, talk to the hand!"
1100
+ }
1101
+ ],
1102
+ "section_heading": ""
1103
+ },
1104
+ {
1105
+ "_id": "page.arnold-wrong-answers",
1106
+ "url": "arnold-wrong-answers",
1107
+ "body": "You are wrong! These are from the Guardians of the Galaxy!",
1108
+ "lede": "",
1109
+ "_type": "page.content",
1110
+ "_uuid": "6324cca4-7770-4765-89b9-1cdc41f49c8b",
1111
+ "heading": "You are wrong",
1112
+ "components": [
1113
+ {
1114
+ "_id": "arnold-wrong-answers_content_1",
1115
+ "name": "arnold-wrong-answers_content_1",
1116
+ "_type": "content",
1117
+ "_uuid": "3bd3ca1d-fed7-43b0-ab90-b4425b634203",
1118
+ "content": "You need to master the ability of standing so incredibly still, that you become invisible to the eye."
1119
+ }
1120
+ ],
1121
+ "section_heading": ""
1122
+ },
1123
+ {
1124
+ "_id": "page.arnold-incomplete-answers",
1125
+ "url": "arnold-incomplete-answers",
1126
+ "body": "You are wrong! The answers are incomplete.",
1127
+ "lede": "",
1128
+ "_type": "page.content",
1129
+ "_uuid": "941137d7-a1da-43fd-994a-98a4f9ea6d46",
1130
+ "heading": "You are wrong",
1131
+ "components": [
1132
+ {
1133
+ "_id": "arnold-incomplete-answers_content_1",
1134
+ "name": "arnold-incomplete-answers_content_1",
1135
+ "_type": "content",
1136
+ "_uuid": "16252a29-8e00-4247-b47f-3e94c863a540",
1137
+ "content": "The answers are incomplete. You need to remember Arnold saying 'I will be back'. So go back to answer correctly."
1138
+ }
1139
+ ],
1140
+ "section_heading": ""
1141
+ },
776
1142
  {
777
1143
  "_id": "page.check-answers",
778
1144
  "url": "check-answers",
@@ -0,0 +1,189 @@
1
+ {
2
+ "_id": "service.base",
3
+ "_type": "service.base",
4
+ "pages": [
5
+ {
6
+ "_id": "page.start",
7
+ "url": "/",
8
+ "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.",
9
+ "lede": "",
10
+ "_type": "page.start",
11
+ "_uuid": "cf6dc32f-502c-4215-8c27-1151a45735bb",
12
+ "steps": [
13
+ "page.name",
14
+ "page.email-address",
15
+ "page.parent-name",
16
+ "page.check-answers",
17
+ "page.confirmation"
18
+ ],
19
+ "heading": "Service name goes here",
20
+ "before_you_start": "###Before you start\r\nYou can also register by post.\r\n\r\nThe online service is also available in Welsh (Cymraeg).\r\n\r\nYou cannot register for this service if you’re in the UK illegally."
21
+ },
22
+ {
23
+ "_id": "page.name",
24
+ "url": "name",
25
+ "body": "Body section",
26
+ "lede": "",
27
+ "_type": "page.singlequestion",
28
+ "_uuid": "9e1ba77f-f1e5-42f4-b090-437aa9af7f73",
29
+ "heading": "Question",
30
+ "components": [
31
+ {
32
+ "_id": "name_text_1",
33
+ "hint": "",
34
+ "name": "name_text_1",
35
+ "_type": "text",
36
+ "_uuid": "27d377a2-6828-44ca-87d1-b83ddac98284",
37
+ "label": "Full name",
38
+ "errors": {},
39
+ "collection": "components",
40
+ "validation": {
41
+ "required": true,
42
+ "max_length": 10,
43
+ "min_length": 2
44
+ }
45
+ }
46
+ ]
47
+ },
48
+ {
49
+ "_id": "page.email-address",
50
+ "url": "email-address",
51
+ "body": "Body section",
52
+ "lede": "",
53
+ "_type": "page.singlequestion",
54
+ "_uuid": "df1ba645-f748-46d0-ad75-f34112653e37",
55
+ "heading": "Question",
56
+ "components": [
57
+ {
58
+ "_id": "email-address_text_1",
59
+ "hint": "",
60
+ "name": "email-address_text_1",
61
+ "_type": "text",
62
+ "_uuid": "f27e5788-e784-4bfd-8b21-2fab8ce95abb",
63
+ "label": "Email address",
64
+ "errors": {
65
+ "format": {},
66
+ "required": {
67
+ "any": "Enter an email address"
68
+ },
69
+ "max_length": {
70
+ "any": "%{control} is too long."
71
+ },
72
+ "min_length": {
73
+ "any": "%{control} is too short."
74
+ }
75
+ },
76
+ "collection": "components",
77
+ "validation": {
78
+ "required": true,
79
+ "max_length": 30,
80
+ "min_length": 2
81
+ }
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ "_id": "page.parent-name",
87
+ "url": "parent-name",
88
+ "body": "Body section",
89
+ "lede": "",
90
+ "_type": "page.singlequestion",
91
+ "_uuid": "4b8c6bf3-878a-4446-9198-48351b3e2185",
92
+ "heading": "Question",
93
+ "components": [
94
+ {
95
+ "_id": "parent-name_text_1",
96
+ "hint": "",
97
+ "name": "parent-name_text_1",
98
+ "_type": "text",
99
+ "_uuid": "5ad372fa-ed35-477f-b471-4d444f991210",
100
+ "label": "Parent name",
101
+ "errors": {},
102
+ "collection": "components",
103
+ "validation": {
104
+ "required": false,
105
+ "max_length": 10,
106
+ "min_length": 2
107
+ }
108
+ }
109
+ ]
110
+ },
111
+ {
112
+ "_id": "page.check-answers",
113
+ "url": "check-answers",
114
+ "_type": "page.checkanswers",
115
+ "_uuid": "e337070b-f636-49a3-a65c-f506675265f0",
116
+ "heading": "Check your answers",
117
+ "send_body": "By submitting this application you confirm that, to the best of your knowledge, the details you are providing are correct.",
118
+ "components": [
119
+ {
120
+ "_id": "check-answers_content_2",
121
+ "name": "check-answers_content_2",
122
+ "_type": "content",
123
+ "_uuid": "b065ff4f-90c5-4ba2-b4ac-c984a9dd2470",
124
+ "content": "Take the cannoli.",
125
+ "collection": "components"
126
+ }
127
+ ],
128
+ "send_heading": "Now send your application",
129
+ "add_component": "content",
130
+ "extra_components": [
131
+ {
132
+ "_id": "check-answers_content_1",
133
+ "name": "check-answers_content_1",
134
+ "_type": "content",
135
+ "_uuid": "3e6ef27e-91a6-402f-8291-b7ce669e824e",
136
+ "content": "Check yourself before you wreck yourself.",
137
+ "collection": "extra_components"
138
+ }
139
+ ],
140
+ "add_extra_component": "content"
141
+ },
142
+ {
143
+ "_id": "page.confirmation",
144
+ "url": "confirmation",
145
+ "body": "Some day I will be the most powerful Jedi ever!",
146
+ "lede": "",
147
+ "_type": "page.confirmation",
148
+ "_uuid": "778e364b-9a7f-4829-8eb2-510e08f156a3",
149
+ "heading": "Complaint sent",
150
+ "components": []
151
+ }
152
+ ],
153
+ "locale": "en",
154
+ "created_at": "2021-04-21T13:10:19Z",
155
+ "created_by": "099d5bf5-5f7b-444c-86ee-9e189cc1a369",
156
+ "service_id": "488edccd-8411-4ffb-a38b-6a96c6ac28d6",
157
+ "version_id": "27dc30c9-f7b8-4dec-973a-bd153f6797df",
158
+ "service_name": "Version Fixture",
159
+ "configuration": {
160
+ "meta": {
161
+ "_id": "config.meta",
162
+ "_type": "config.meta",
163
+ "items": [
164
+ {
165
+ "_id": "config.meta--link",
166
+ "href": "cookies",
167
+ "text": "Cookies",
168
+ "_type": "link"
169
+ },
170
+ {
171
+ "_id": "config.meta--link--2",
172
+ "href": "privacy",
173
+ "text": "Privacy",
174
+ "_type": "link"
175
+ },
176
+ {
177
+ "_id": "config.meta--link--3",
178
+ "href": "accessibility",
179
+ "text": "Accessibility",
180
+ "_type": "link"
181
+ }
182
+ ]
183
+ },
184
+ "service": {
185
+ "_id": "config.service",
186
+ "_type": "config.service"
187
+ }
188
+ }
189
+ }
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '1.6.1'.freeze
2
+ VERSION = '1.7.4'.freeze
3
3
  end
@@ -45,17 +45,17 @@ module MetadataPresenter
45
45
 
46
46
  def draw_nodes
47
47
  flow.each do |id, _value|
48
- flow_object = service.flow(id)
48
+ flow_object = service.flow_object(id)
49
49
 
50
50
  if flow_object.branch?
51
- full_description = flow_object.conditions.map do |condition|
52
- condition.criterias.map do |criteria|
51
+ full_description = flow_object.conditions.map.each_with_index do |condition, _index|
52
+ condition.criterias.map { |criteria|
53
53
  criteria.service = service
54
54
 
55
- "if #{criteria.criteria_component.humanised_title} #{criteria.operator} #{criteria.field_label}"
56
- end
55
+ "#{criteria.criteria_component.humanised_title} #{criteria.operator} #{criteria.field_label}"
56
+ }.join(" #{condition.condition_type} ")
57
57
  end
58
- nodes[id] = @graphviz.add_nodes(full_description.flatten.join(' - '))
58
+ nodes[id] = @graphviz.add_nodes(full_description.flatten.join(' / '))
59
59
  else
60
60
  current_page = find_page_by_uuid(id)
61
61
  nodes[id] = @graphviz.add_nodes(current_page.url)
@@ -65,7 +65,7 @@ module MetadataPresenter
65
65
 
66
66
  def draw_edges
67
67
  flow.each do |id, _value|
68
- flow_object = service.flow(id)
68
+ flow_object = service.flow_object(id)
69
69
  current_node = nodes[id]
70
70
  node_next = nodes[flow_object.default_next]
71
71
 
@@ -83,7 +83,7 @@ module MetadataPresenter
83
83
  end
84
84
 
85
85
  def flow
86
- metadata['flow']
86
+ service.flow
87
87
  end
88
88
  end
89
89
  end
@@ -0,0 +1,75 @@
1
+ {
2
+ "$id": "http://gov.uk/schema/v1.0.0/flow/branch",
3
+ "_name": "flow.branch",
4
+ "title": "Flow branching object",
5
+ "description": "Flow object that represents a branching object",
6
+ "type": "object",
7
+ "properties": {
8
+ "_type": {
9
+ "type": "string",
10
+ "const": "flow.branch"
11
+ },
12
+ "next": {
13
+ "type": "object",
14
+ "properties": {
15
+ "default": {
16
+ "type": "string"
17
+ },
18
+ "conditions": {
19
+ "$ref": "#/definitions/conditions"
20
+ }
21
+ }
22
+ }
23
+ },
24
+ "additionalProperties": false,
25
+ "definitions": {
26
+ "conditions": {
27
+ "type": "array",
28
+ "items": {
29
+ "type": "object",
30
+ "properties": {
31
+ "condition_type": {
32
+ "type": "string",
33
+ "enum": [
34
+ "if",
35
+ "and",
36
+ "or"
37
+ ]
38
+ },
39
+ "next": {
40
+ "type": "string"
41
+ },
42
+ "criterias": {
43
+ "$ref": "#/definitions/criterias"
44
+ }
45
+ }
46
+ }
47
+ },
48
+ "criterias": {
49
+ "type": "array",
50
+ "items": {
51
+ "type": "object",
52
+ "properties": {
53
+ "operator": {
54
+ "type": "string",
55
+ "enum": [
56
+ "is",
57
+ "is_not",
58
+ "is_answered",
59
+ "is_not_answered"
60
+ ],
61
+ "page": {
62
+ "type": "string"
63
+ },
64
+ "component": {
65
+ "type": "string"
66
+ },
67
+ "field": {
68
+ "type": "string"
69
+ }
70
+ }
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$id": "http://gov.uk/schema/v1.0.0/flow/page",
3
+ "_name": "flow.page",
4
+ "title": "Flow page object",
5
+ "description": "Flow object that represents a page",
6
+ "type": "object",
7
+ "properties": {
8
+ "_type": {
9
+ "type": "string",
10
+ "const": "flow.page"
11
+ },
12
+ "next": {
13
+ "type": "object",
14
+ "properties": {
15
+ "default": {
16
+ "type": "string"
17
+ }
18
+ }
19
+ }
20
+ },
21
+ "additionalProperties": false
22
+ }
@@ -32,6 +32,19 @@
32
32
  "configuration": {
33
33
  "$ref": "configuration"
34
34
  },
35
+ "flow": {
36
+ "type": "object",
37
+ "items": {
38
+ "anyOf": [
39
+ {
40
+ "$ref": "flow.page"
41
+ },
42
+ {
43
+ "$ref": "flow.branch"
44
+ }
45
+ ]
46
+ }
47
+ },
35
48
  "pages": {
36
49
  "type": "array",
37
50
  "items": {
@@ -77,6 +90,5 @@
77
90
  "configuration",
78
91
  "pages",
79
92
  "standalone_pages"
80
- ],
81
- "additionalProperties": false
93
+ ]
82
94
  }
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: 1.6.1
4
+ version: 1.7.4
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-07-01 00:00:00.000000000 Z
11
+ date: 2021-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder
@@ -358,6 +358,10 @@ files:
358
358
  - default_metadata/config/service.json
359
359
  - default_metadata/definition/checkbox.json
360
360
  - default_metadata/definition/radio.json
361
+ - default_metadata/flow/branch.json
362
+ - default_metadata/flow/condition.json
363
+ - default_metadata/flow/criteria.json
364
+ - default_metadata/flow/page.json
361
365
  - default_metadata/page/checkanswers.json
362
366
  - default_metadata/page/confirmation.json
363
367
  - default_metadata/page/content.json
@@ -378,6 +382,7 @@ files:
378
382
  - fixtures/branching.json
379
383
  - fixtures/invalid_content_page.json
380
384
  - fixtures/no_component_page.json
385
+ - fixtures/no_flow_service.json
381
386
  - fixtures/non_finished_service.json
382
387
  - fixtures/service.json
383
388
  - fixtures/version.json
@@ -433,6 +438,8 @@ files:
433
438
  - schemas/definition/width_class.input.json
434
439
  - schemas/definition/width_class.json
435
440
  - schemas/errors/errors.json
441
+ - schemas/flow/branch.json
442
+ - schemas/flow/page.json
436
443
  - schemas/link/link.json
437
444
  - schemas/page/checkanswers.json
438
445
  - schemas/page/confirmation.json