metadata_presenter 2.15.9 → 2.15.12

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: fd26567ffefc85523ea94a99b37c9ff4ab7c9c923a591af95e2f8c254522b346
4
- data.tar.gz: c949f8259d9a581317af29eff875330694e1dd9fc8decf507fafdd1230b126f5
3
+ metadata.gz: fa0c41f4fa6c6480de3cf499e6c1ed023e2bf375eaa37e80fda2af43ed79e2a0
4
+ data.tar.gz: 6c656d1fdea731a25f81dfa4a83ecb4c140267d7e396245f6871fcc513b52738
5
5
  SHA512:
6
- metadata.gz: deef6fca91c8cd3203bd4eb6c4326b9e340711753681c41e9f873be0b204b161dd4a2d8e721cfd7abfc368e9a6dd9bead9c1f2039708db6ba602299c7b18e75a
7
- data.tar.gz: c3bdc48b2cf30259ab65d13d43652bf1f60d66073f1c1106dffded0b09fba581cf2a113e645c8046425c5cd6da4ed4d3cb6bb0f04dd8c12341233dedd8944337
6
+ metadata.gz: 68eccd32be7f6490f708193614752d7c41ffc74cf7992f772ac1d9b1a03a26d2b4866c8d0ed2a37d13ed9f43bd3e79628c2c058412e0f391cd94c56a35fa24a5
7
+ data.tar.gz: a698125db67640863c49e19b46d8ca99e458a06d9323f2a73252270df98bb7b47018ba26ec90ae9b7999b9a30dd2282063a389a68a73655074f7bd9996cc0adb
@@ -14,5 +14,9 @@ module MetadataPresenter
14
14
  end
15
15
  destination_uuids.flatten.push(branch.default_next)
16
16
  end
17
+
18
+ def has_or_conditionals?(branch)
19
+ branch.conditionals.any? { |c| c.type == 'or' }
20
+ end
17
21
  end
18
22
  end
@@ -39,7 +39,7 @@ module MetadataPresenter
39
39
  end
40
40
 
41
41
  def set_branch_spacers_column(branch_uuid, column)
42
- branch_spacers[branch_uuid].each do |_, position|
42
+ branch_spacers[branch_uuid].each do |position|
43
43
  position[:column] = column
44
44
  end
45
45
  end
@@ -50,7 +50,7 @@ module MetadataPresenter
50
50
  # to draw an arrow therefore we increment the row number from the branches
51
51
  # calculated starting row
52
52
  def set_branch_spacers_row(branch_uuid, starting_row)
53
- branch_spacers[branch_uuid].each.with_index(starting_row) do |(_, position), row|
53
+ branch_spacers[branch_uuid].each.with_index(starting_row) do |position, row|
54
54
  position[:row] = row
55
55
  end
56
56
  end
@@ -68,11 +68,15 @@ module MetadataPresenter
68
68
  # need an additional line for an arrow.
69
69
  def setup_branch_spacers
70
70
  service.branches.each.with_object({}) do |branch, hash|
71
- destinations = exiting_destinations_from_branch(branch)
72
- hash[branch.uuid] = destinations.index_with do |_uuid|
73
- { row: nil, column: nil }
74
- end
71
+ hash[branch.uuid] = initial_spacer(branch)
72
+ end
73
+ end
74
+
75
+ def initial_spacer(branch)
76
+ destinations = exiting_destinations_from_branch(branch).map do |uuid|
77
+ { uuid: uuid, row: nil, column: nil }
75
78
  end
79
+ has_or_conditionals?(branch) ? destinations.uniq : destinations
76
80
  end
77
81
  end
78
82
  end
@@ -241,9 +241,9 @@ module MetadataPresenter
241
241
  column.each do |flow_object|
242
242
  next unless flow_object.branch?
243
243
 
244
- coordinates.branch_spacers[flow_object.uuid].each do |destination_uuid, position|
245
- if replace_with_pointer?(next_column, position[:row], destination_uuid)
246
- @ordered[next_column][position[:row]] = MetadataPresenter::Pointer.new(uuid: destination_uuid)
244
+ coordinates.branch_spacers[flow_object.uuid].map do |destination|
245
+ if replace_with_pointer?(next_column, destination[:row], destination[:uuid])
246
+ @ordered[next_column][destination[:row]] = MetadataPresenter::Pointer.new(uuid: destination[:uuid])
247
247
  end
248
248
  end
249
249
  end
@@ -356,10 +356,13 @@ module MetadataPresenter
356
356
  # and arrow. When there are 'OR' conditions we need to insert additional
357
357
  # spacers into the necessary row in the column after the one the branch is
358
358
  # located in.
359
+ # This is done for the column directly after a branching point
359
360
  def insert_expression_spacers
360
361
  service.branches.each do |branch|
361
362
  next if coordinates.uuid_column(branch.uuid).nil?
362
363
 
364
+ next unless has_or_conditionals?(branch)
365
+
363
366
  previous_uuid = ''
364
367
  next_column = coordinates.uuid_column(branch.uuid) + 1
365
368
  exiting_destinations_from_branch(branch).each_with_index do |uuid, row|
@@ -100,6 +100,10 @@ module MetadataPresenter
100
100
  type.in?(END_OF_ROUTE_PAGES)
101
101
  end
102
102
 
103
+ def multiple_questions?
104
+ type == 'page.multiplequestions'
105
+ end
106
+
103
107
  private
104
108
 
105
109
  def heading?
@@ -42,7 +42,7 @@ module MetadataPresenter
42
42
  return if branches_in_column.empty?
43
43
 
44
44
  row_numbers = branches_in_column.map do |branch_uuid, _|
45
- coordinates.branch_spacers[branch_uuid].map { |_, position| position[:row] }
45
+ coordinates.branch_spacers[branch_uuid].map { |position| position[:row] }
46
46
  end
47
47
  row_numbers.flatten.max + 1
48
48
  end
@@ -54,7 +54,7 @@ module MetadataPresenter
54
54
  def branch_spacer_row
55
55
  return if spacers_for_current_object.empty?
56
56
 
57
- spacers_for_current_object.map { |position| position[:row] }.max
57
+ spacers_for_current_object.flatten.map { |position| position[:row] }.max
58
58
  end
59
59
 
60
60
  def first_row?
@@ -84,7 +84,7 @@ module MetadataPresenter
84
84
  end
85
85
 
86
86
  current_object_spacers = spacer_positions.map do |branch_uuid, _|
87
- coordinates.branch_spacers[branch_uuid][uuid]
87
+ coordinates.branch_spacers[branch_uuid].select { |branch_spacer| branch_spacer[:uuid] == uuid }
88
88
  end
89
89
  current_object_spacers.compact
90
90
  end
@@ -0,0 +1,11 @@
1
+ module MetadataPresenter
2
+ class ContainsOperator < BaseOperator
3
+ def evaluate?
4
+ @actual == @expected
5
+ end
6
+
7
+ def evaluate_collection?
8
+ Array(@expected).include?(@actual)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module MetadataPresenter
2
+ class DoesNotContainOperator < BaseOperator
3
+ def evaluate?
4
+ @actual != @expected
5
+ end
6
+
7
+ def evaluate_collection?
8
+ Array(@expected).exclude?(@actual)
9
+ end
10
+ end
11
+ end
@@ -1,3 +1,4 @@
1
1
  ActiveSupport::Inflector.inflections(:en) do |inflect|
2
2
  inflect.irregular 'is', 'is'
3
+ inflect.irregular 'contains', 'contains'
3
4
  end
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '2.15.9'.freeze
2
+ VERSION = '2.15.12'.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: 2.15.9
4
+ version: 2.15.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - MoJ Forms
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-10 00:00:00.000000000 Z
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder
@@ -303,6 +303,8 @@ files:
303
303
  - app/models/metadata_presenter/traversed_pages.rb
304
304
  - app/models/metadata_presenter/uploaded_file.rb
305
305
  - app/operators/metadata_presenter/base_operator.rb
306
+ - app/operators/metadata_presenter/contains_operator.rb
307
+ - app/operators/metadata_presenter/does_not_contain_operator.rb
306
308
  - app/operators/metadata_presenter/is_answered_operator.rb
307
309
  - app/operators/metadata_presenter/is_not_answered_operator.rb
308
310
  - app/operators/metadata_presenter/is_not_operator.rb