metadata_presenter 2.15.9 → 2.15.10

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: fd26567ffefc85523ea94a99b37c9ff4ab7c9c923a591af95e2f8c254522b346
4
- data.tar.gz: c949f8259d9a581317af29eff875330694e1dd9fc8decf507fafdd1230b126f5
3
+ metadata.gz: 53b941c0d91360e25ea0fbe443046805d760416cc4c345813fe44ade9dca178e
4
+ data.tar.gz: 4c7e831b1cad1f8d8587e30196cb99d980463addd0b7451f54511cfe7e688603
5
5
  SHA512:
6
- metadata.gz: deef6fca91c8cd3203bd4eb6c4326b9e340711753681c41e9f873be0b204b161dd4a2d8e721cfd7abfc368e9a6dd9bead9c1f2039708db6ba602299c7b18e75a
7
- data.tar.gz: c3bdc48b2cf30259ab65d13d43652bf1f60d66073f1c1106dffded0b09fba581cf2a113e645c8046425c5cd6da4ed4d3cb6bb0f04dd8c12341233dedd8944337
6
+ metadata.gz: a6188728e5ee91a652462c9abea6ff0900c2393549a8544f4c7ec5b72d7723d99ee69b2a6cb1bd0d9027756175966cc561bce28e3100d50a1fa93a349a3d6f7c
7
+ data.tar.gz: b861587b148d28738d7ffe62bf83aad31305b6962fba31f4bea910d8b0023cc61e2ea3ccece69c323f72deee065e7437530658328e98acef3569b0d663a4f539
@@ -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|
@@ -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
@@ -1,3 +1,3 @@
1
1
  module MetadataPresenter
2
- VERSION = '2.15.9'.freeze
2
+ VERSION = '2.15.10'.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.10
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-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_design_system_formbuilder