metadata_presenter 1.6.1 → 1.7.0

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: 03253a540a4143ec0d42a0cac9b78f9eba498a3e293abdcb3638cba9bdf35050
4
- data.tar.gz: a54cc6a26c040cd918562d283a124dc938ecf676484bc63e2e9aa6bb3d7032c7
3
+ metadata.gz: '0817e0fd8648eed9b10a3b5244e6933f8492805f76843db92ae17f3fab3adf36'
4
+ data.tar.gz: a31749c039cd29a2c836959a47fb2801bb10418520f022edd6783cc78913a6c6
5
5
  SHA512:
6
- metadata.gz: 6192e319eb945dcf609b359d9130b9e53f5bcaf0a4d4756eedd97347a939afcd000c7a9f80b79c678301a42aeafa5f36df158c867d75c774aef44f2420e854f3
7
- data.tar.gz: 7e8b14eb5fc34db77fc544baaac72ad2fe18a0c47691b8972fcc449707d3bf1dbf8e83e71f52cba8965ca1545c01f9cf612c94797d2286c217013812c9cdf752
6
+ metadata.gz: ad688abaf732349b401eabf92390c23db5760062d5b23bf36aca96431cfa3dfbbb2e7409ca2daf405828f4f65123225f1b3889ef014c20c121c333c6c23bf7ed
7
+ data.tar.gz: 31bd7f7e65d82476b75d6b6dc6d608b1ba30dab6e3b5b5c23b7ec539d08682ab0ed3a5ca278b5067f3550d6fd867551d3b8fb91fb2eaceda9f04787d2df86f4f
@@ -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
@@ -169,7 +169,7 @@
169
169
  "618b7537-b42b-4551-ae7d-053afa4d9ca9": {
170
170
  "_type": "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",
@@ -201,10 +201,72 @@
201
201
  "bc666714-c0a2-4674-afe5-faff2e20d847": {
202
202
  "_type": "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",
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": "e337070b-f636-49a3-a65c-f506675265f0",
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": "e337070b-f636-49a3-a65c-f506675265f0"
267
+ }
268
+ },
269
+ "f6c51f88-7be8-4cb7-bbfc-6c905727a051": {
208
270
  "_type": "page",
209
271
  "next": {
210
272
  "default": "e337070b-f636-49a3-a65c-f506675265f0"
@@ -773,6 +835,108 @@
773
835
  ],
774
836
  "section_heading": ""
775
837
  },
838
+ {
839
+ "_id": "page.marvel-series",
840
+ "url": "marvel-series",
841
+ "_type": "page.singlequestion",
842
+ "_uuid": "dc7454f9-4186-48d7-b055-684d57bbcdc7",
843
+ "components": [
844
+ {
845
+ "_id": "marvel-series_radios_1",
846
+ "hint": "",
847
+ "name": "marvel-series_radios_1",
848
+ "_type": "radios",
849
+ "_uuid": "5ca01e56-94de-4c33-b5fc-74697e5b95cc",
850
+ "items": [
851
+ {
852
+ "_id": "marvel-series_radios_1_item_1",
853
+ "hint": "",
854
+ "_type": "radio",
855
+ "_uuid": "0c4192eb-1441-4f10-b00a-0f03b756269e",
856
+ "label": "WandaVision"
857
+ },
858
+ {
859
+ "_id": "marvel-series_radios_1_item_2",
860
+ "hint": "",
861
+ "_type": "radio",
862
+ "_uuid": "bd14bf31-427e-4267-9926-a18c167fe604",
863
+ "label": "The Falcon and the Winter Soldier"
864
+ },
865
+ {
866
+ "_id": "marvel-series_radios_1_item_2",
867
+ "hint": "",
868
+ "_type": "radio",
869
+ "_uuid": "eb720ef7-bcaf-4c73-8972-6fc80dca6245",
870
+ "label": "Loki"
871
+ },
872
+ {
873
+ "_id": "marvel-series_radios_1_item_3",
874
+ "hint": "",
875
+ "_type": "radio",
876
+ "_uuid": "d762e328-18dc-4861-bca8-d104609b8299",
877
+ "label": "Hawkeye"
878
+ }
879
+ ],
880
+ "errors": {},
881
+ "legend": "What is the best marvel series?",
882
+ "validation": {
883
+ "required": true
884
+ }
885
+ }
886
+ ]
887
+ },
888
+ {
889
+ "_id": "page.marvel-quotes",
890
+ "url": "marvel-quotes",
891
+ "body": "Marvel quotes",
892
+ "lede": "",
893
+ "_type": "page.content",
894
+ "_uuid": "2cc66e51-2c14-4023-86bf-ded49887cdb2",
895
+ "heading": "Loki",
896
+ "components": [
897
+ {
898
+ "_id": "marvel-quotes_content_1",
899
+ "name": "marvel-quotes_content_1",
900
+ "_type": "content",
901
+ "_uuid": "5cede2fa-5001-4d6a-965c-30addc3c4496",
902
+ "content": "I am Loki of Asgard, and I am burdened with glorious purpose."
903
+ },
904
+ {
905
+ "_id": "marvel-quotes_content_2",
906
+ "name": "marvel-quotes_content_2",
907
+ "_type": "content",
908
+ "_uuid": "816b6afd-4649-455a-b10d-62cb5acb4584",
909
+ "content": "So Who Are You Fighting Now ... Gandalf?"
910
+ }
911
+ ],
912
+ "section_heading": ""
913
+ },
914
+ {
915
+ "_id": "page.other-quotes",
916
+ "url": "other-quotes",
917
+ "body": "Other quotes",
918
+ "lede": "",
919
+ "_type": "page.content",
920
+ "_uuid": "f6c51f88-7be8-4cb7-bbfc-6c905727a051",
921
+ "heading": "Other quotes",
922
+ "components": [
923
+ {
924
+ "_id": "other-quotes_content_1",
925
+ "name": "other-quotes_content_1",
926
+ "_type": "content",
927
+ "_uuid": "2535a867-deab-457b-91aa-c006e3c73d63",
928
+ "content": "- How we doing? - Same as always... - That bad, huh?"
929
+ },
930
+ {
931
+ "_id": "other-quotes_content_2",
932
+ "name": "other-quotes_content_2",
933
+ "_type": "content",
934
+ "_uuid": "816b6afd-4649-455a-b10d-62cb5acb4584",
935
+ "content": "Are you using your night vision, Vision?"
936
+ }
937
+ ],
938
+ "section_heading": ""
939
+ },
776
940
  {
777
941
  "_id": "page.check-answers",
778
942
  "url": "check-answers",
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '1.6.1'.freeze
2
+ VERSION = '1.7.0'.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: 1.6.1
4
+ version: 1.7.0
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-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder