ecoportal-api-v2 2.0.16 → 3.1.1

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.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +24 -1
  3. data/ecoportal-api-v2.gemspec +1 -1
  4. data/lib/ecoportal/api/common/concerns.rb +2 -2
  5. data/lib/ecoportal/api/common/content/class_helpers.rb +42 -7
  6. data/lib/ecoportal/api/common/content/client.rb +2 -1
  7. data/lib/ecoportal/api/common/content/collection_model/doc/rooted_key.rb +8 -8
  8. data/lib/ecoportal/api/common/content/collection_model/doc.rb +2 -2
  9. data/lib/ecoportal/api/common/content/collection_model/doc_mutation.rb +3 -3
  10. data/lib/ecoportal/api/common/content/collection_model/model.rb +6 -6
  11. data/lib/ecoportal/api/common/content/collection_model/modifiers.rb +3 -3
  12. data/lib/ecoportal/api/common/content/collection_model/mutation.rb +3 -3
  13. data/lib/ecoportal/api/common/content/collection_model.rb +5 -5
  14. data/lib/ecoportal/api/common/content/double_model/attributable/nesting/cascaded_callback.rb +203 -98
  15. data/lib/ecoportal/api/common/content/double_model/attributable/nesting/embeddable.rb +49 -59
  16. data/lib/ecoportal/api/common/content/double_model/attributable/nesting/keyable.rb +102 -114
  17. data/lib/ecoportal/api/common/content/double_model/attributable/nesting.rb +5 -3
  18. data/lib/ecoportal/api/common/content/double_model/attributable.rb +5 -5
  19. data/lib/ecoportal/api/common/content/double_model/diffable/diff_service.rb +33 -0
  20. data/lib/ecoportal/api/common/content/double_model/{diffable_model.rb → diffable.rb} +12 -5
  21. data/lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb +9 -4
  22. data/lib/ecoportal/api/common/content/double_model/double_doc/replaceable_doc.rb +10 -2
  23. data/lib/ecoportal/api/common/content/double_model/double_doc/reset_consolidate.rb +1 -1
  24. data/lib/ecoportal/api/common/content/double_model/double_doc/rooted_key.rb +10 -3
  25. data/lib/ecoportal/api/common/content/double_model/double_doc.rb +5 -5
  26. data/lib/ecoportal/api/common/content/double_model/hash_helpers.rb +23 -4
  27. data/lib/ecoportal/api/common/content/double_model/modifiers.rb +2 -2
  28. data/lib/ecoportal/api/common/content/double_model.rb +9 -9
  29. data/lib/ecoportal/api/common/content/hash_diff_patch.rb +21 -7
  30. data/lib/ecoportal/api/common/content/model_helpers.rb +1 -1
  31. data/lib/ecoportal/api/common/content.rb +11 -11
  32. data/lib/ecoportal/api/common.v2.rb +2 -2
  33. data/lib/ecoportal/api/v2/page/component/action.rb +13 -11
  34. data/lib/ecoportal/api/v2/page/component/action_field.rb +14 -12
  35. data/lib/ecoportal/api/v2/page/component/actions_field.rb +2 -1
  36. data/lib/ecoportal/api/v2/page/component/chart_field/config.rb +1 -2
  37. data/lib/ecoportal/api/v2/page/component/chart_field.rb +48 -44
  38. data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +0 -1
  39. data/lib/ecoportal/api/v2/page/component/checklist_field.rb +9 -6
  40. data/lib/ecoportal/api/v2/page/component/checklist_item.rb +2 -3
  41. data/lib/ecoportal/api/v2/page/component/contractor_entities_field.rb +18 -17
  42. data/lib/ecoportal/api/v2/page/component/date_field.rb +19 -18
  43. data/lib/ecoportal/api/v2/page/component/file.rb +3 -3
  44. data/lib/ecoportal/api/v2/page/component/files_field.rb +9 -6
  45. data/lib/ecoportal/api/v2/page/component/gauge_field.rb +3 -2
  46. data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +26 -26
  47. data/lib/ecoportal/api/v2/page/component/geo_field.rb +2 -2
  48. data/lib/ecoportal/api/v2/page/component/image.rb +6 -5
  49. data/lib/ecoportal/api/v2/page/component/images_field.rb +21 -20
  50. data/lib/ecoportal/api/v2/page/component/law.rb +3 -4
  51. data/lib/ecoportal/api/v2/page/component/law_field.rb +2 -2
  52. data/lib/ecoportal/api/v2/page/component/number_field.rb +1 -1
  53. data/lib/ecoportal/api/v2/page/component/people_field.rb +19 -19
  54. data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +6 -7
  55. data/lib/ecoportal/api/v2/page/component/reference_field.rb +1 -1
  56. data/lib/ecoportal/api/v2/page/component/rich_text_field.rb +3 -3
  57. data/lib/ecoportal/api/v2/page/component/selection_field.rb +32 -35
  58. data/lib/ecoportal/api/v2/page/component/selection_options.rb +12 -7
  59. data/lib/ecoportal/api/v2/page/component/tag_field.rb +5 -4
  60. data/lib/ecoportal/api/v2/page/component.rb +21 -21
  61. data/lib/ecoportal/api/v2/page/force/bindings.rb +49 -39
  62. data/lib/ecoportal/api/v2/page/force.rb +9 -9
  63. data/lib/ecoportal/api/v2/page/forces.rb +1 -1
  64. data/lib/ecoportal/api/v2/page/permit.rb +3 -3
  65. data/lib/ecoportal/api/v2/page/sections.rb +19 -14
  66. data/lib/ecoportal/api/v2/page/stage.rb +27 -20
  67. data/lib/ecoportal/api/v2/page/stages.rb +1 -1
  68. data/lib/ecoportal/api/v2/page.rb +13 -12
  69. data/lib/ecoportal/api/v2/pages/page_stage.rb +2 -2
  70. data/lib/ecoportal/api/v2/pages.rb +2 -2
  71. data/lib/ecoportal/api/v2/registers/page_result.rb +3 -3
  72. data/lib/ecoportal/api/v2/registers/register.rb +4 -5
  73. data/lib/ecoportal/api/v2/registers/search_results.rb +1 -1
  74. data/lib/ecoportal/api/v2/registers/stages_result.rb +1 -1
  75. data/lib/ecoportal/api/v2/registers.rb +6 -6
  76. data/lib/ecoportal/api/v2/s3/files/batch_upload.rb +1 -0
  77. data/lib/ecoportal/api/v2/s3/files.rb +3 -3
  78. data/lib/ecoportal/api/v2.rb +4 -4
  79. data/lib/ecoportal/api/v2_version.rb +1 -1
  80. data/lib/ecoportal/api-v2.rb +4 -5
  81. metadata +6 -5
@@ -6,14 +6,14 @@ module Ecoportal
6
6
  # which differs of `attr_*` ruby native class methods because `pass*`
7
7
  # completelly **links** the methods **to a subjacent `Hash` model**
8
8
  class DoubleModel < Ecoportal::API::Common::BaseModel
9
- require 'ecoportal/api/common/content/double_model/base'
10
- require 'ecoportal/api/common/content/double_model/parented'
11
- require 'ecoportal/api/common/content/double_model/modifiers'
12
- require 'ecoportal/api/common/content/double_model/var_tracking'
13
- require 'ecoportal/api/common/content/double_model/hash_helpers'
14
- require 'ecoportal/api/common/content/double_model/double_doc'
15
- require 'ecoportal/api/common/content/double_model/attributable'
16
- require 'ecoportal/api/common/content/double_model/diffable_model'
9
+ require_relative 'double_model/base'
10
+ require_relative 'double_model/parented'
11
+ require_relative 'double_model/modifiers'
12
+ require_relative 'double_model/var_tracking'
13
+ require_relative 'double_model/hash_helpers'
14
+ require_relative 'double_model/double_doc'
15
+ require_relative 'double_model/attributable'
16
+ require_relative 'double_model/diffable'
17
17
 
18
18
  include Base
19
19
  include Parented
@@ -23,7 +23,7 @@ module Ecoportal
23
23
 
24
24
  include DoubleDoc
25
25
  include Attributable
26
- include DiffableModel
26
+ include Diffable
27
27
 
28
28
  class << self
29
29
  def new_uuid(length: 24)
@@ -4,17 +4,24 @@ module Ecoportal
4
4
  module Common
5
5
  module Content
6
6
  module HashDiffPatch
7
- extend DocHelpers
7
+ class << self
8
+ def included(base)
9
+ super
10
+
11
+ base.send :include, InstanceMethods
12
+ end
13
+ end
8
14
 
9
- ID_KEYS = %w[id].freeze
10
15
  META_KEYS = %w[id patch_ver].freeze
11
16
  NO_CHANGES = "%not-changed!%".freeze
12
17
 
13
- class << self
18
+ module InstanceMethods
19
+ include DocHelpers
20
+
14
21
  # The `patch data` is built as follows:
15
22
  # 1. detect changes that have occurred translate into one `operation` of `OP_TYPE`:
16
23
  # * `changed`: meaning that the object has changed (existed and has not been removed)
17
- # * `delete`: the object has been removed
24
+ # * `deleted`: the object has been removed
18
25
  # * `new`: the object is new
19
26
  # 2. at the level of the target object of the model, the object is opened for change
20
27
  # with `id` and `operation` as follows:
@@ -54,6 +61,12 @@ module Ecoportal
54
61
 
55
62
  private
56
63
 
64
+ def meta_keys
65
+ return self::META_KEYS if respond_to?(:const_get)
66
+
67
+ self.class::META_KEYS
68
+ end
69
+
57
70
  def equal_values?(a, b)
58
71
  if a.is_a?(String) || b.is_a?(String)
59
72
  a_empty = a.to_s.strip.empty?
@@ -76,7 +89,7 @@ module Ecoportal
76
89
  end
77
90
 
78
91
  a.each do |key, a_value|
79
- next if META_KEYS.include?(key)
92
+ next if meta_keys.include?(key)
80
93
 
81
94
  b_value = nil
82
95
 
@@ -90,8 +103,7 @@ module Ecoportal
90
103
  data_hash.delete(key) if data_hash[key] == NO_CHANGES
91
104
  end
92
105
 
93
- #if (data_hash.keys - ID_KEYS).empty?
94
- return NO_CHANGES if (data_hash.keys - META_KEYS).empty?
106
+ return NO_CHANGES if (data_hash.keys - meta_keys).empty?
95
107
 
96
108
  if b&.key?('patch_ver')
97
109
  data_hash['patch_ver'] = b['patch_ver']
@@ -217,6 +229,8 @@ module Ecoportal
217
229
  bool
218
230
  end
219
231
  end
232
+
233
+ extend InstanceMethods
220
234
  end
221
235
  end
222
236
  end
@@ -31,7 +31,7 @@ module Ecoportal
31
31
  end
32
32
  end
33
33
 
34
- def hash_except(hash, *keys)
34
+ def hash_except!(hash, *keys)
35
35
  keys.each {|key| hash.delete(key)}
36
36
  hash
37
37
  end
@@ -7,14 +7,14 @@ module Ecoportal
7
7
  end
8
8
  end
9
9
 
10
- require 'ecoportal/api/common/content/includer'
11
- require 'ecoportal/api/common/content/class_helpers'
12
- require 'ecoportal/api/common/content/string_digest'
13
- require 'ecoportal/api/common/content/model_helpers'
14
- require 'ecoportal/api/common/content/double_model'
15
- require 'ecoportal/api/common/content/array_model'
16
- require 'ecoportal/api/common/content/collection_model'
17
- require 'ecoportal/api/common/content/doc_helpers'
18
- require 'ecoportal/api/common/content/hash_diff_patch'
19
- require 'ecoportal/api/common/content/client'
20
- require 'ecoportal/api/common/content/wrapped_response'
10
+ require_relative 'content/includer'
11
+ require_relative 'content/class_helpers'
12
+ require_relative 'content/string_digest'
13
+ require_relative 'content/model_helpers'
14
+ require_relative 'content/doc_helpers'
15
+ require_relative 'content/hash_diff_patch'
16
+ require_relative 'content/double_model'
17
+ require_relative 'content/array_model'
18
+ require_relative 'content/collection_model'
19
+ require_relative 'content/client'
20
+ require_relative 'content/wrapped_response'
@@ -9,5 +9,5 @@ module Ecoportal
9
9
  end
10
10
  end
11
11
 
12
- require 'ecoportal/api/common/concerns'
13
- require 'ecoportal/api/common/content'
12
+ require_relative 'common/concerns'
13
+ require_relative 'common/content'
@@ -7,8 +7,8 @@ module Ecoportal
7
7
  class << self
8
8
  def new_doc
9
9
  {
10
- "id" => new_uuid,
11
- "weight" => 99
10
+ 'id' => new_uuid,
11
+ 'weight' => 99
12
12
  }
13
13
  end
14
14
  end
@@ -30,16 +30,18 @@ module Ecoportal
30
30
  passarray :file_container_ids
31
31
 
32
32
  def to_s
33
- stat = case
34
- when overdue
35
- "Overdue"
36
- when complete
37
- "Complete"
33
+ stat =
34
+ if overdue
35
+ 'Overdue'
36
+ elsif complete
37
+ 'Complete'
38
38
  else
39
- "Pending"
40
- end
41
- assignee = assigned_person_member["name"] || assigned_person_member["email"]
42
- "#{name}, #{created_at.to_s}, #{stat}, #{assignee}"
39
+ 'Pending'
40
+ end
41
+
42
+ assignee = assigned_person_member['name'] || assigned_person_member['email']
43
+
44
+ "#{name}, #{created_at}, #{stat}, #{assignee}"
43
45
  end
44
46
  end
45
47
  end
@@ -9,22 +9,24 @@ module Ecoportal
9
9
  passboolean :permits_and_rules_integration, :add_subscribed, :add_subscribed_to_tasks
10
10
  passarray :permitted_person_schema_ids, order_matters: false
11
11
 
12
- embeds_many :actions, klass: "Ecoportal::API::V2::Page::Component::Action", order_key: :weight
12
+ embeds_many :actions, klass: 'Ecoportal::API::V2::Page::Component::Action', order_key: :weight
13
13
 
14
14
  def empty?
15
15
  actions.empty?
16
16
  end
17
-
17
+
18
18
  # Adds a task with `name` short description
19
19
  # @return [Ecoportal::API::V2::Page::Component::Action]
20
- def add_task (name)
20
+ def add_task(name)
21
21
  task_doc = actions.items_class.new_doc
22
22
  actions.upsert!(task_doc) do |task|
23
23
  task.name = name
24
- if prev = previous_task(task)
24
+ if (prev = previous_task(task))
25
25
  task.weight = prev.weight
26
26
  end
27
+
27
28
  yield(task) if block_given?
29
+
28
30
  fix_task_weights!
29
31
  end
30
32
  end
@@ -50,14 +52,15 @@ module Ecoportal
50
52
  case cnf
51
53
  when Hash
52
54
  supported = [:requires]
53
- unless (rest = hash_except(cnf.dup, *supported)).empty?
55
+ unless (rest = hash_except!(cnf.dup, *supported)).empty?
54
56
  unused.push(rest)
55
57
  end
56
- if cnf.key?(:requires) then configure_required(cnf[:requires]) end
58
+
59
+ configure_required(cnf[:requires]) if cnf.key?(:requires)
57
60
  else
58
61
  unused.push(cnf)
59
62
  end
60
- end.yield_self do |unused|
63
+ end.then do |unused|
61
64
  super(*unused)
62
65
  end
63
66
  end
@@ -68,11 +71,9 @@ module Ecoportal
68
71
  self.required = true
69
72
  case req
70
73
  when :all, NilClass
71
- self.required_number_of_completed_actions = "all"
74
+ self.required_number_of_completed_actions = 'all'
72
75
  when Numeric
73
76
  self.required_number_of_completed_actions = req
74
- else
75
- # Unsupported
76
77
  end
77
78
  end
78
79
 
@@ -84,8 +85,9 @@ module Ecoportal
84
85
 
85
86
  def previous_task(value)
86
87
  tasks = ordered_tasks
87
- pos = tasks.index(value) - 1
88
- return if pos < 0
88
+ pos = tasks.index(value) - 1
89
+ return if pos.negative?
90
+
89
91
  tasks[pos]
90
92
  end
91
93
  end
@@ -21,8 +21,9 @@ module Ecoportal
21
21
 
22
22
  # Adds a task with `name` short description
23
23
  # @return [Ecoportal::API::V2::Page::Component::Action]
24
- def attach_action (*ids, force: false)
24
+ def attach_action(*ids, force: false)
25
25
  raise "Can't attach actions" unless enable_attaching_actions && force
26
+
26
27
  action_ids << ids
27
28
  end
28
29
 
@@ -5,10 +5,9 @@ module Ecoportal
5
5
  class Component
6
6
  class ChartField
7
7
  class Config < Ecoportal::API::Common::Content::DoubleModel
8
-
9
8
  class << self
10
9
  def new_doc
11
- {"id" => new_uuid}
10
+ {'id' => new_uuid}
12
11
  end
13
12
  end
14
13
 
@@ -14,41 +14,46 @@ module Ecoportal
14
14
  passthrough :user_id, :user_lookup
15
15
  passboolean :lock_chart_user
16
16
 
17
- embeds_one :series_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::SeriesConfig"
18
- embeds_one :frequency_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Frequency"
19
- embeds_one :heatmap_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Heatmap"
20
- embeds_one :sankey_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Sankey"
21
- embeds_one :indicator_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Indicator"
22
- embeds_one :faceted_series_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Multiseries"
23
- embeds_one :benchmark_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Benchmark"
17
+ embeds_one :series_config, klass: 'Ecoportal::API::V2::Page::Component::ChartField::SeriesConfig'
18
+ embeds_one :frequency_config, klass: 'Ecoportal::API::V2::Page::Component::ChartField::Frequency'
19
+ embeds_one :heatmap_config, klass: 'Ecoportal::API::V2::Page::Component::ChartField::Heatmap'
20
+ embeds_one :sankey_config, klass: 'Ecoportal::API::V2::Page::Component::ChartField::Sankey'
21
+ embeds_one :indicator_config, klass: 'Ecoportal::API::V2::Page::Component::ChartField::Indicator'
22
+ embeds_one :faceted_series_config, klass: 'Ecoportal::API::V2::Page::Component::ChartField::Multiseries'
23
+ embeds_one :benchmark_config, klass: 'Ecoportal::API::V2::Page::Component::ChartField::Benchmark'
24
24
 
25
- embeds_many :series, klass: "Ecoportal::API::V2::Page::Component::ChartField::Serie"
25
+ embeds_many :series, klass: 'Ecoportal::API::V2::Page::Component::ChartField::Serie'
26
26
 
27
- MODES = ["frequency", "series", "heatmap", "sankey", "indicator", "faceted_series", "benchmark"]
27
+ MODES = %w[
28
+ frequency heatmap sankey
29
+ series faceted_series
30
+ indicator benchmark
31
+ ].freeze
28
32
 
29
33
  def mode=(value)
30
34
  raise "Unsuported mode #{value}. Should be one of #{MODES}" unless MODES.include?(value)
31
35
  config_doc(nil)
32
- doc["mode"] = value
36
+ doc['mode'] = value
33
37
  config_doc(config.class.new_doc)
34
- self.mode
38
+
39
+ mode
35
40
  end
36
41
 
37
42
  def config
38
- case self.mode
39
- when "frequency"
43
+ case mode
44
+ when 'frequency'
40
45
  frequency_config
41
- when "series"
46
+ when 'series'
42
47
  series_config
43
- when "heatmap"
48
+ when 'heatmap'
44
49
  heatmap_config
45
- when "sankey"
50
+ when 'sankey'
46
51
  sankey_config
47
- when "indicator"
52
+ when 'indicator'
48
53
  indicator_config
49
- when "faceted_series"
54
+ when 'faceted_series'
50
55
  faceted_series_config
51
- when "benchmark"
56
+ when 'benchmark'
52
57
  benchmark_config
53
58
  end
54
59
  end
@@ -56,24 +61,23 @@ module Ecoportal
56
61
  private
57
62
 
58
63
  def config_doc(value)
59
- case self.mode
60
- when "frequency"
61
- doc["frequency_config"] = value
62
- when "series"
63
- doc["series_config"] = value
64
- when "heatmap"
65
- doc["heatmap_config"] = value
66
- when "sankey"
67
- doc["sankey_config"] = value
68
- when "indicator"
69
- doc["indicator_config"] = value
70
- when "faceted_series"
71
- doc["faceted_series_config"] = value
72
- when "benchmark"
73
- doc["benchmark_config"] = value
64
+ case mode
65
+ when 'frequency'
66
+ doc['frequency_config'] = value
67
+ when 'series'
68
+ doc['series_config'] = value
69
+ when 'heatmap'
70
+ doc['heatmap_config'] = value
71
+ when 'sankey'
72
+ doc['sankey_config'] = value
73
+ when 'indicator'
74
+ doc['indicator_config'] = value
75
+ when 'faceted_series'
76
+ doc['faceted_series_config'] = value
77
+ when 'benchmark'
78
+ doc['benchmark_config'] = value
74
79
  end
75
80
  end
76
-
77
81
  end
78
82
  end
79
83
  end
@@ -81,12 +85,12 @@ module Ecoportal
81
85
  end
82
86
  end
83
87
 
84
- require 'ecoportal/api/v2/page/component/chart_field/config'
85
- require 'ecoportal/api/v2/page/component/chart_field/frequency'
86
- require 'ecoportal/api/v2/page/component/chart_field/series_config'
87
- require 'ecoportal/api/v2/page/component/chart_field/serie'
88
- require 'ecoportal/api/v2/page/component/chart_field/heatmap'
89
- require 'ecoportal/api/v2/page/component/chart_field/sankey'
90
- require 'ecoportal/api/v2/page/component/chart_field/indicator'
91
- require 'ecoportal/api/v2/page/component/chart_field/multiseries'
92
- require 'ecoportal/api/v2/page/component/chart_field/benchmark'
88
+ require_relative 'chart_field/config'
89
+ require_relative 'chart_field/frequency'
90
+ require_relative 'chart_field/series_config'
91
+ require_relative 'chart_field/serie'
92
+ require_relative 'chart_field/heatmap'
93
+ require_relative 'chart_field/sankey'
94
+ require_relative 'chart_field/indicator'
95
+ require_relative 'chart_field/multiseries'
96
+ require_relative 'chart_field/benchmark'
@@ -25,7 +25,6 @@ module Ecoportal
25
25
  passarray :color_map, order_matters: false
26
26
 
27
27
  passthrough :chart_user
28
-
29
28
  end
30
29
  end
31
30
  end
@@ -4,20 +4,23 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ChecklistField < Page::Component
7
- embeds_many :items, klass: "Ecoportal::API::V2::Page::Component::ChecklistItem", order_key: :weight
7
+ embeds_many :items, klass: 'Ecoportal::API::V2::Page::Component::ChecklistItem', order_key: :weight
8
8
 
9
9
  def empty?
10
10
  items.empty?
11
11
  end
12
-
12
+
13
13
  def add_item(label:, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
14
14
  itm_doc = items.items_class.new_doc
15
15
  items.upsert!(itm_doc, pos: pos, before: before, after: after) do |item|
16
- item.label = label
17
- if prev = previous_item(item)
16
+ item.label = label
17
+
18
+ if (prev = previous_item(item))
18
19
  item.weight = prev.weight
19
20
  end
21
+
20
22
  yield(item) if block_given?
23
+
21
24
  fix_item_weights!
22
25
  end
23
26
  end
@@ -43,10 +46,10 @@ module Ecoportal
43
46
  def previous_item(value)
44
47
  itms = ordered_items
45
48
  pos = itms.index(value) - 1
46
- return if pos < 0
49
+ return if pos.negative?
50
+
47
51
  itms[pos]
48
52
  end
49
-
50
53
  end
51
54
  end
52
55
  end
@@ -4,12 +4,11 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ChecklistItem < Ecoportal::API::Common::Content::DoubleModel
7
-
8
7
  class << self
9
8
  def new_doc
10
9
  {
11
- "id" => new_uuid,
12
- "weight" => 9999
10
+ 'id' => new_uuid,
11
+ 'weight' => 9999
13
12
  }
14
13
  end
15
14
  end
@@ -16,8 +16,8 @@ module Ecoportal
16
16
  passboolean :grant_permissions_enabled
17
17
  passthrough :apply_attached_contractors_permissions_to
18
18
  passthrough :admin_access, :regular_access
19
- embeds_one :attached_contractors_permissions_flags, klass: "Ecoportal::API::V2::Page::PermissionFlags"
20
- embeds_one :attached_contractors_admin_permissions_flags, klass: "Ecoportal::API::V2::Page::PermissionFlags"
19
+ embeds_one :attached_contractors_permissions_flags, klass: 'Ecoportal::API::V2::Page::PermissionFlags'
20
+ embeds_one :attached_contractors_admin_permissions_flags, klass: 'Ecoportal::API::V2::Page::PermissionFlags' # rubocop:disable Layout/LineLength
21
21
 
22
22
  def empty?
23
23
  contractor_entities_ids.empty?
@@ -55,7 +55,7 @@ module Ecoportal
55
55
  # - `:subscribed`
56
56
  # - `:subscribed_to_tasks`
57
57
  # - `requires: number` to fine the number of required people to be attached
58
- def configure(*conf)
58
+ def configure(*conf) # rubocop:disable Metrics/AbcSize
59
59
  conf.each_with_object([]) do |cnf, unused|
60
60
  case cnf
61
61
  when :me_button
@@ -63,14 +63,15 @@ module Ecoportal
63
63
  when :singular
64
64
  self.singular = true
65
65
  when Hash
66
- supported = [:singular, :permits]
67
- unless (rest = hash_except(cnf.dup, *supported)).empty?
66
+ supported = %i[singular permits]
67
+ unless (rest = hash_except!(cnf.dup, *supported)).empty?
68
68
  unused.push(rest)
69
69
  end
70
70
 
71
- if cnf.key?(:singular) then self.singular = !!cnf[:singular] end
71
+ self.singular = !!cnf[:singular] if cnf.key?(:singular) # rubocop:disable Style/DoubleNegation
72
+
72
73
  if cnf.key?(:permits)
73
- if permits = cnf[:permits]
74
+ if (permits = cnf[:permits])
74
75
  self.regular_access = true
75
76
  configure_permits(*[permits].flatten.compact)
76
77
  else
@@ -78,7 +79,7 @@ module Ecoportal
78
79
  end
79
80
  end
80
81
  if cnf.key?(:admin_permits)
81
- if permits = cnf[:permits]
82
+ if (permits = cnf[:permits])
82
83
  self.admin_access = true
83
84
  configure_permits(*[permits].flatten.compact)
84
85
  else
@@ -88,35 +89,35 @@ module Ecoportal
88
89
  else
89
90
  unused.push(cnf)
90
91
  end
91
- end.yield_self do |unused|
92
+ end.then do |unused|
92
93
  super(*unused)
93
94
  end
94
95
  end
95
96
 
96
97
  private
97
98
 
98
- def configure_permits(*conf, to: :regular)
99
+ def configure_permits(*conf, to: :regular) # rubocop:disable Naming/MethodParameterName
99
100
  conf.each_with_object([]) do |cnf, flags|
100
101
  permits_scope = :apply_attached_contractors_permissions_to=
101
102
  case cnf
102
103
  when :all
103
- send(permits_scope, "page")
104
+ send(permits_scope, 'page')
104
105
  when :stages
105
- send(permits_scope, "all_stages")
106
+ send(permits_scope, 'all_stages')
106
107
  when :page
107
- send(permits_scope, "page_only")
108
+ send(permits_scope, 'page_only')
108
109
  when :stage
109
- send(permits_scope, "current_stage")
110
+ send(permits_scope, 'current_stage')
110
111
  else
111
112
  flags.push(cnf)
112
113
  end
113
- end.yield_self do |flags|
114
+ end.then do |flags|
114
115
  target_flags = :attached_contractors_admin_permissions_flags if to == :admin
115
116
  target_flags ||= :attached_contractors_permissions_flags
116
- self.send(target_flags).configure *flags
117
+
118
+ send(target_flags).configure(*flags)
117
119
  end
118
120
  end
119
-
120
121
  end
121
122
  end
122
123
  end