metadata_presenter 1.6.0 → 1.7.3
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/models/metadata_presenter/evaluate_conditions.rb +18 -10
- data/app/models/metadata_presenter/next_page.rb +2 -2
- data/app/models/metadata_presenter/page_answers.rb +5 -4
- data/app/models/metadata_presenter/previous_page.rb +1 -5
- data/app/models/metadata_presenter/service.rb +2 -2
- data/app/models/metadata_presenter/traversed_pages.rb +2 -2
- data/fixtures/branching.json +368 -2
- data/fixtures/no_flow_service.json +189 -0
- data/lib/metadata_presenter/version.rb +1 -1
- data/lib/tasks/metadata_presenter_tasks.rake +9 -10
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf6c41a569262e3d405b1611d563f30f4e0c5a13134c920349a24a1c2f3365e1
|
4
|
+
data.tar.gz: ac8d4ea6aa1aa1aca3c942ad098ee35b4f680668de3e53b087efc3ae10bb2c1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07f84b9e3fa53d81c7acbc2b108926581d0be3d2ec8d6123afbdc63fdffdef32b1e4c8104a276c454735639c3f580764efbb482ac68347362a640d6406e7c65a
|
7
|
+
data.tar.gz: 29f2f870b2b832bec55069adf227d6de566deb80341d96987f8cd7ef108414db31ed21bde0b4d076f2593ace47498af2d4c4b2f815941ceb1c46f3197a235955
|
@@ -4,24 +4,32 @@ module MetadataPresenter
|
|
4
4
|
attr_accessor :service, :flow, :user_data
|
5
5
|
|
6
6
|
def page
|
7
|
-
|
8
|
-
|
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
|
-
|
17
|
+
Operator.new(
|
12
18
|
criteria.operator
|
13
|
-
).evaluate(
|
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
|
-
|
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
|
@@ -49,11 +49,11 @@ module MetadataPresenter
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def current_page_flow
|
52
|
-
service.
|
52
|
+
service.flow_object(current_page_uuid)
|
53
53
|
end
|
54
54
|
|
55
55
|
def next_flow
|
56
|
-
service.
|
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
|
9
|
-
MetadataPresenter::Flow.new(metadata.flow[
|
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.
|
17
|
+
service.flow.size.times do
|
18
18
|
break if page_uuid == current_page.uuid
|
19
19
|
|
20
|
-
flow_object = service.
|
20
|
+
flow_object = service.flow_object(page_uuid)
|
21
21
|
|
22
22
|
if flow_object.branch?
|
23
23
|
page = EvaluateConditions.new(
|
data/fixtures/branching.json
CHANGED
@@ -169,7 +169,7 @@
|
|
169
169
|
"618b7537-b42b-4551-ae7d-053afa4d9ca9": {
|
170
170
|
"_type": "branch",
|
171
171
|
"next": {
|
172
|
-
"default": "
|
172
|
+
"default": "dc7454f9-4186-48d7-b055-684d57bbcdc7",
|
173
173
|
"conditions": [
|
174
174
|
{
|
175
175
|
"condition_type": "if",
|
@@ -201,10 +201,146 @@
|
|
201
201
|
"bc666714-c0a2-4674-afe5-faff2e20d847": {
|
202
202
|
"_type": "page",
|
203
203
|
"next": {
|
204
|
-
"default": "
|
204
|
+
"default": "dc7454f9-4186-48d7-b055-684d57bbcdc7"
|
205
205
|
}
|
206
206
|
},
|
207
207
|
"e2887f44-5e8d-4dc0-b1de-496ab6039430": {
|
208
|
+
"_type": "page",
|
209
|
+
"next": {
|
210
|
+
"default": "dc7454f9-4186-48d7-b055-684d57bbcdc7"
|
211
|
+
}
|
212
|
+
},
|
213
|
+
"dc7454f9-4186-48d7-b055-684d57bbcdc7": {
|
214
|
+
"_type": "page",
|
215
|
+
"next": {
|
216
|
+
"default": "84a347fc-8d4b-486a-9996-6a86fa9544c5"
|
217
|
+
}
|
218
|
+
},
|
219
|
+
"84a347fc-8d4b-486a-9996-6a86fa9544c5": {
|
220
|
+
"_type": "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": "page",
|
265
|
+
"next": {
|
266
|
+
"default": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb"
|
267
|
+
}
|
268
|
+
},
|
269
|
+
"f6c51f88-7be8-4cb7-bbfc-6c905727a051": {
|
270
|
+
"_type": "page",
|
271
|
+
"next": {
|
272
|
+
"default": "48357db5-7c06-4e85-94b1-5e1c9d8f39eb"
|
273
|
+
}
|
274
|
+
},
|
275
|
+
"48357db5-7c06-4e85-94b1-5e1c9d8f39eb": {
|
276
|
+
"_type": "page",
|
277
|
+
"next": {
|
278
|
+
"default": "1079b5b8-abd0-4bf6-aaac-1f01e69e3b39"
|
279
|
+
}
|
280
|
+
},
|
281
|
+
"1079b5b8-abd0-4bf6-aaac-1f01e69e3b39": {
|
282
|
+
"_type": "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": "page",
|
333
|
+
"next": {
|
334
|
+
"default": "e337070b-f636-49a3-a65c-f506675265f0"
|
335
|
+
}
|
336
|
+
},
|
337
|
+
"56e80942-d0a4-405a-85cd-bd1b100013d6": {
|
338
|
+
"_type": "page",
|
339
|
+
"next": {
|
340
|
+
"default": "e337070b-f636-49a3-a65c-f506675265f0"
|
341
|
+
}
|
342
|
+
},
|
343
|
+
"6324cca4-7770-4765-89b9-1cdc41f49c8b": {
|
208
344
|
"_type": "page",
|
209
345
|
"next": {
|
210
346
|
"default": "e337070b-f636-49a3-a65c-f506675265f0"
|
@@ -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
|
+
}
|
@@ -5,6 +5,7 @@ namespace :metadata do
|
|
5
5
|
|
6
6
|
desc 'Represent the flow objects in human readable form'
|
7
7
|
task flow: :environment do
|
8
|
+
require 'ruby-graphviz'
|
8
9
|
metadata = ENV['SERVICE_METADATA'] || metadata_fixture('branching')
|
9
10
|
service = MetadataPresenter::Service.new(metadata)
|
10
11
|
|
@@ -16,8 +17,6 @@ namespace :metadata do
|
|
16
17
|
end
|
17
18
|
end
|
18
19
|
|
19
|
-
require 'ruby-graphviz'
|
20
|
-
|
21
20
|
module MetadataPresenter
|
22
21
|
class Graph
|
23
22
|
attr_reader :service, :filename, :nodes
|
@@ -46,17 +45,17 @@ module MetadataPresenter
|
|
46
45
|
|
47
46
|
def draw_nodes
|
48
47
|
flow.each do |id, _value|
|
49
|
-
flow_object = service.
|
48
|
+
flow_object = service.flow_object(id)
|
50
49
|
|
51
50
|
if flow_object.branch?
|
52
|
-
full_description = flow_object.conditions.map do |condition|
|
53
|
-
condition.criterias.map
|
51
|
+
full_description = flow_object.conditions.map.each_with_index do |condition, _index|
|
52
|
+
condition.criterias.map { |criteria|
|
54
53
|
criteria.service = service
|
55
54
|
|
56
|
-
"
|
57
|
-
|
55
|
+
"#{criteria.criteria_component.humanised_title} #{criteria.operator} #{criteria.field_label}"
|
56
|
+
}.join(" #{condition.condition_type} ")
|
58
57
|
end
|
59
|
-
nodes[id] = @graphviz.add_nodes(full_description.flatten.join('
|
58
|
+
nodes[id] = @graphviz.add_nodes(full_description.flatten.join(' / '))
|
60
59
|
else
|
61
60
|
current_page = find_page_by_uuid(id)
|
62
61
|
nodes[id] = @graphviz.add_nodes(current_page.url)
|
@@ -66,7 +65,7 @@ module MetadataPresenter
|
|
66
65
|
|
67
66
|
def draw_edges
|
68
67
|
flow.each do |id, _value|
|
69
|
-
flow_object = service.
|
68
|
+
flow_object = service.flow_object(id)
|
70
69
|
current_node = nodes[id]
|
71
70
|
node_next = nodes[flow_object.default_next]
|
72
71
|
|
@@ -84,7 +83,7 @@ module MetadataPresenter
|
|
84
83
|
end
|
85
84
|
|
86
85
|
def flow
|
87
|
-
|
86
|
+
service.flow
|
88
87
|
end
|
89
88
|
end
|
90
89
|
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: 1.
|
4
|
+
version: 1.7.3
|
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-
|
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
|
@@ -378,6 +378,7 @@ files:
|
|
378
378
|
- fixtures/branching.json
|
379
379
|
- fixtures/invalid_content_page.json
|
380
380
|
- fixtures/no_component_page.json
|
381
|
+
- fixtures/no_flow_service.json
|
381
382
|
- fixtures/non_finished_service.json
|
382
383
|
- fixtures/service.json
|
383
384
|
- fixtures/version.json
|