metadata_presenter 1.8.1 → 2.0.2

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.
@@ -34,23 +34,46 @@
34
34
  ]
35
35
  }
36
36
  },
37
+ "flow": {
38
+ "cf6dc32f-502c-4215-8c27-1151a45735bb": {
39
+ "_type": "flow.page",
40
+ "next": {
41
+ "default": "9e1ba77f-f1e5-42f4-b090-437aa9af7f73"
42
+ }
43
+ },
44
+ "9e1ba77f-f1e5-42f4-b090-437aa9af7f73": {
45
+ "_type": "flow.page",
46
+ "next": {
47
+ "default": "68fbb180-9a2a-48f6-9da6-545e28b8d35a"
48
+ }
49
+ },
50
+ "68fbb180-9a2a-48f6-9da6-545e28b8d35a": {
51
+ "_type": "flow.page",
52
+ "next": {
53
+ "default": "09e91fd9-7a46-4840-adbc-244d545cfef7"
54
+ }
55
+ },
56
+ "09e91fd9-7a46-4840-adbc-244d545cfef7": {
57
+ "_type": "flow.page",
58
+ "next": {
59
+ "default": ""
60
+ }
61
+ }
62
+ },
37
63
  "pages": [
38
64
  {
39
65
  "_id": "page.start",
40
66
  "_type": "page.start",
67
+ "_uuid": "cf6dc32f-502c-4215-8c27-1151a45735bb",
41
68
  "heading": "Service name goes here",
42
69
  "lede": "This is your start page first paragraph. You can only have one paragraph here.",
43
70
  "body": "Use this service to:\r\n\r\n* do something\r\n* update your name, address or other details\r\n* do something else\r\n\r\nRegistering takes around 5 minutes.",
44
- "steps": [
45
- "page.name",
46
- "page.email-address",
47
- "page.parent_name"
48
- ],
49
71
  "url": "/"
50
72
  },
51
73
  {
52
74
  "_id": "page.name",
53
75
  "_type": "page.singlequestion",
76
+ "_uuid": "9e1ba77f-f1e5-42f4-b090-437aa9af7f73",
54
77
  "components": [
55
78
  {
56
79
  "_id": "page.name--text.auto_name__1",
@@ -70,6 +93,7 @@
70
93
  {
71
94
  "_id": "page.email-address",
72
95
  "_type": "page.singlequestion",
96
+ "_uuid": "68fbb180-9a2a-48f6-9da6-545e28b8d35a",
73
97
  "heading": "Email address",
74
98
  "components": [
75
99
  {
@@ -101,6 +125,7 @@
101
125
  {
102
126
  "_id": "page.parent_name",
103
127
  "_type": "page.singlequestion",
128
+ "_uuid": "09e91fd9-7a46-4840-adbc-244d545cfef7",
104
129
  "components": [
105
130
  {
106
131
  "_id": "page.parent-name--text.auto_name__3",
@@ -1,6 +1,14 @@
1
1
  {
2
2
  "_id": "service.base",
3
3
  "_type": "service.base",
4
+ "flow": {
5
+ "86ed04ac-1727-4172-8dd2-608009f1a656": {
6
+ "_type": "flow.page",
7
+ "next": {
8
+ "default": ""
9
+ }
10
+ }
11
+ },
4
12
  "pages": [
5
13
  {
6
14
  "_id": "page.start",
@@ -9,7 +17,6 @@
9
17
  "lede": "",
10
18
  "_type": "page.start",
11
19
  "_uuid": "86ed04ac-1727-4172-8dd2-608009f1a656",
12
- "steps": [],
13
20
  "heading": "Service name goes here",
14
21
  "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."
15
22
  }
@@ -1,6 +1,92 @@
1
1
  {
2
2
  "_id": "service.base",
3
3
  "_type": "service.base",
4
+ "flow": {
5
+ "cf6dc32f-502c-4215-8c27-1151a45735bb": {
6
+ "_type": "flow.page",
7
+ "next": {
8
+ "default": "9e1ba77f-f1e5-42f4-b090-437aa9af7f73"
9
+ }
10
+ },
11
+ "9e1ba77f-f1e5-42f4-b090-437aa9af7f73": {
12
+ "_type": "flow.page",
13
+ "next": {
14
+ "default": "df1ba645-f748-46d0-ad75-f34112653e37"
15
+ }
16
+ },
17
+ "df1ba645-f748-46d0-ad75-f34112653e37": {
18
+ "_type": "flow.page",
19
+ "next": {
20
+ "default": "4b8c6bf3-878a-4446-9198-48351b3e2185"
21
+ }
22
+ },
23
+ "4b8c6bf3-878a-4446-9198-48351b3e2185": {
24
+ "_type": "flow.page",
25
+ "next": {
26
+ "default": "54ccc6cd-60c0-4749-947b-a97af1bc0aa2"
27
+ }
28
+ },
29
+ "54ccc6cd-60c0-4749-947b-a97af1bc0aa2": {
30
+ "_type": "flow.page",
31
+ "next": {
32
+ "default": "b8335af2-6642-4e2f-8192-0dd12279eec7"
33
+ }
34
+ },
35
+ "b8335af2-6642-4e2f-8192-0dd12279eec7": {
36
+ "_type": "flow.page",
37
+ "next": {
38
+ "default": "68fbb180-9a2a-48f6-9da6-545e28b8d35a"
39
+ }
40
+ },
41
+ "68fbb180-9a2a-48f6-9da6-545e28b8d35a": {
42
+ "_type": "flow.page",
43
+ "next": {
44
+ "default": "7806cd64-0c05-450e-ba6f-2325c8b22d46"
45
+ }
46
+ },
47
+ "7806cd64-0c05-450e-ba6f-2325c8b22d46": {
48
+ "_type": "flow.page",
49
+ "next": {
50
+ "default": "0c022e95-0748-4dda-8ba5-12fd1d2f596b"
51
+ }
52
+ },
53
+ "0c022e95-0748-4dda-8ba5-12fd1d2f596b": {
54
+ "_type": "flow.page",
55
+ "next": {
56
+ "default": "e8708909-922e-4eaf-87a5-096f7a713fcb"
57
+ }
58
+ },
59
+ "e8708909-922e-4eaf-87a5-096f7a713fcb": {
60
+ "_type": "flow.page",
61
+ "next": {
62
+ "default": "80420693-d6f2-4fce-a860-777ca774a6f5"
63
+ }
64
+ },
65
+ "80420693-d6f2-4fce-a860-777ca774a6f5": {
66
+ "_type": "flow.page",
67
+ "next": {
68
+ "default": "2ef7d11e-0307-49e9-9fe2-345dc528dd66"
69
+ }
70
+ },
71
+ "2ef7d11e-0307-49e9-9fe2-345dc528dd66": {
72
+ "_type": "flow.page",
73
+ "next": {
74
+ "default": "e337070b-f636-49a3-a65c-f506675265f0"
75
+ }
76
+ },
77
+ "e337070b-f636-49a3-a65c-f506675265f0": {
78
+ "_type": "flow.page",
79
+ "next": {
80
+ "default": "778e364b-9a7f-4829-8eb2-510e08f156a3"
81
+ }
82
+ },
83
+ "778e364b-9a7f-4829-8eb2-510e08f156a3": {
84
+ "_type": "flow.page",
85
+ "next": {
86
+ "default": ""
87
+ }
88
+ }
89
+ },
4
90
  "pages": [
5
91
  {
6
92
  "_id": "page.start",
@@ -9,21 +95,6 @@
9
95
  "lede": "",
10
96
  "_type": "page.start",
11
97
  "_uuid": "cf6dc32f-502c-4215-8c27-1151a45735bb",
12
- "steps": [
13
- "page.name",
14
- "page.email-address",
15
- "page.parent-name",
16
- "page.your-age",
17
- "page.family-hobbies",
18
- "page.do-you-like-star-wars",
19
- "page.holiday",
20
- "page.burgers",
21
- "page.star-wars-knowledge",
22
- "page.how-many-lights",
23
- "page.dog-picture",
24
- "page.check-answers",
25
- "page.confirmation"
26
- ],
27
98
  "heading": "Service name goes here",
28
99
  "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."
29
100
  },
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '1.8.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
@@ -48,12 +48,12 @@ module MetadataPresenter
48
48
  flow_object = service.flow_object(id)
49
49
 
50
50
  if flow_object.branch?
51
- full_description = flow_object.conditions.map.each_with_index do |condition, _index|
52
- condition.criterias.map { |criteria|
53
- criteria.service = service
51
+ full_description = flow_object.conditionals.map.each_with_index do |conditional, _index|
52
+ conditional.expressions.map { |expression|
53
+ expression.service = service
54
54
 
55
- "#{criteria.criteria_component.humanised_title} #{criteria.operator} #{criteria.field_label}"
56
- }.join(" #{condition.condition_type} ")
55
+ "#{expression.expression_component.humanised_title} #{expression.operator} #{expression.field_label}"
56
+ }.join(" #{conditional.type} ")
57
57
  end
58
58
  nodes[id] = @graphviz.add_nodes(full_description.flatten.join(' / '))
59
59
  else
@@ -72,9 +72,9 @@ module MetadataPresenter
72
72
  if flow_object.branch?
73
73
  @graphviz.add_edges(current_node, node_next, label: 'Conditions are not met', labelfontsize: 8) if node_next
74
74
 
75
- flow_object.group_by_page.each do |page_uuid, _conditions|
76
- conditions_node = nodes[page_uuid]
77
- @graphviz.add_edges(current_node, conditions_node, label: 'Conditions are met', labelfontsize: 8) if conditions_node
75
+ flow_object.group_by_page.each do |page_uuid, _conditionals|
76
+ conditionals_node = nodes[page_uuid]
77
+ @graphviz.add_edges(current_node, conditionals_node, label: 'Conditions are met', labelfontsize: 8) if conditionals_node
78
78
  end
79
79
  elsif node_next
80
80
  @graphviz.add_edges(current_node, node_next)
@@ -15,20 +15,20 @@
15
15
  "default": {
16
16
  "type": "string"
17
17
  },
18
- "conditions": {
19
- "$ref": "#/definitions/conditions"
18
+ "conditionals": {
19
+ "$ref": "#/definitions/conditionals"
20
20
  }
21
21
  }
22
22
  }
23
23
  },
24
24
  "additionalProperties": false,
25
25
  "definitions": {
26
- "conditions": {
26
+ "conditionals": {
27
27
  "type": "array",
28
28
  "items": {
29
29
  "type": "object",
30
30
  "properties": {
31
- "condition_type": {
31
+ "_type": {
32
32
  "type": "string",
33
33
  "enum": [
34
34
  "if",
@@ -39,13 +39,13 @@
39
39
  "next": {
40
40
  "type": "string"
41
41
  },
42
- "criterias": {
43
- "$ref": "#/definitions/criterias"
42
+ "expressions": {
43
+ "$ref": "#/definitions/expressions"
44
44
  }
45
45
  }
46
46
  }
47
47
  },
48
- "criterias": {
48
+ "expressions": {
49
49
  "type": "array",
50
50
  "items": {
51
51
  "type": "object",
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.8.1
4
+ version: 2.0.2
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-09 00:00:00.000000000 Z
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder
@@ -277,10 +277,10 @@ files:
277
277
  - app/helpers/metadata_presenter/default_text.rb
278
278
  - app/jobs/metadata_presenter/application_job.rb
279
279
  - app/models/metadata_presenter/component.rb
280
- - app/models/metadata_presenter/condition.rb
281
- - app/models/metadata_presenter/criteria.rb
280
+ - app/models/metadata_presenter/conditional.rb
282
281
  - app/models/metadata_presenter/date_field.rb
283
- - app/models/metadata_presenter/evaluate_conditions.rb
282
+ - app/models/metadata_presenter/evaluate_conditionals.rb
283
+ - app/models/metadata_presenter/expression.rb
284
284
  - app/models/metadata_presenter/file_uploader.rb
285
285
  - app/models/metadata_presenter/flow.rb
286
286
  - app/models/metadata_presenter/item.rb
@@ -359,8 +359,8 @@ files:
359
359
  - default_metadata/definition/checkbox.json
360
360
  - default_metadata/definition/radio.json
361
361
  - default_metadata/flow/branch.json
362
- - default_metadata/flow/condition.json
363
- - default_metadata/flow/criteria.json
362
+ - default_metadata/flow/conditional.json
363
+ - default_metadata/flow/expression.json
364
364
  - default_metadata/flow/page.json
365
365
  - default_metadata/page/checkanswers.json
366
366
  - default_metadata/page/confirmation.json
@@ -382,12 +382,9 @@ files:
382
382
  - fixtures/branching.json
383
383
  - fixtures/invalid_content_page.json
384
384
  - fixtures/no_component_page.json
385
- - fixtures/no_flow_service.json
386
385
  - fixtures/non_finished_service.json
387
386
  - fixtures/service.json
388
- - fixtures/service_with_flow.json
389
387
  - fixtures/version.json
390
- - fixtures/version_with_flow.json
391
388
  - lib/metadata_presenter.rb
392
389
  - lib/metadata_presenter/engine.rb
393
390
  - lib/metadata_presenter/test_helpers.rb
@@ -1,13 +0,0 @@
1
- module MetadataPresenter
2
- class Condition < MetadataPresenter::Metadata
3
- def ==(other)
4
- metadata.to_h.deep_symbolize_keys == other.metadata.to_h.deep_symbolize_keys
5
- end
6
-
7
- def criterias
8
- Array(metadata.criterias).map do |criteria|
9
- MetadataPresenter::Criteria.new(criteria)
10
- end
11
- end
12
- end
13
- end
@@ -1,25 +0,0 @@
1
- module MetadataPresenter
2
- class Criteria < MetadataPresenter::Metadata
3
- attr_accessor :service
4
-
5
- def ==(other)
6
- metadata == other.metadata
7
- end
8
-
9
- def criteria_page
10
- service.find_page_by_uuid(page)
11
- end
12
-
13
- def criteria_component
14
- criteria_page.find_component_by_uuid(component)
15
- end
16
-
17
- def criteria_field
18
- criteria_component.find_item_by_uuid(field)
19
- end
20
-
21
- def field_label
22
- criteria_field['label'] if criteria_field
23
- end
24
- end
25
- end
@@ -1,37 +0,0 @@
1
- module MetadataPresenter
2
- class EvaluateConditions
3
- include ActiveModel::Model
4
- attr_accessor :service, :flow, :user_data
5
-
6
- def page
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|
15
- criteria.service = service
16
-
17
- Operator.new(
18
- criteria.operator
19
- ).evaluate(
20
- criteria.field_label,
21
- user_data[criteria.criteria_component.id]
22
- )
23
- end
24
-
25
- if condition.condition_type == 'or' && evaluated_criterias.any?
26
- condition.next
27
- elsif evaluated_criterias.all?
28
- condition.next
29
- end
30
- end
31
-
32
- @results.flatten.compact.first
33
- end
34
-
35
- delegate :conditions, to: :flow
36
- end
37
- end
@@ -1,5 +0,0 @@
1
- {
2
- "condition_type": "",
3
- "next": "",
4
- "criterias": []
5
- }
@@ -1,190 +0,0 @@
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": "No Flow Service 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
- "standalone_pages": []
190
- }