ecoportal-api-oozes 0.7.0 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +103 -1
  3. data/README.md +2 -0
  4. data/ecoportal-api-oozes.gemspec +13 -6
  5. data/lib/ecoportal/api/common/content/class_helpers.rb +35 -0
  6. data/lib/ecoportal/api/common/content/collection_model.rb +25 -3
  7. data/lib/ecoportal/api/common/content/double_model.rb +27 -12
  8. data/lib/ecoportal/api/common/content/hash_diff_patch.rb +8 -2
  9. data/lib/ecoportal/api/common/content/wrapped_response.rb +1 -1
  10. data/lib/ecoportal/api/v2.rb +38 -3
  11. data/lib/ecoportal/api/v2/page.rb +3 -3
  12. data/lib/ecoportal/api/v2/page/component.rb +24 -7
  13. data/lib/ecoportal/api/v2/page/component/action.rb +14 -3
  14. data/lib/ecoportal/api/v2/page/component/action_field.rb +40 -2
  15. data/lib/ecoportal/api/v2/page/component/chart_field.rb +54 -0
  16. data/lib/ecoportal/api/v2/page/component/chart_field/frequency.rb +29 -0
  17. data/lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb +27 -0
  18. data/lib/ecoportal/api/v2/page/component/chart_field/indicator.rb +26 -0
  19. data/lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb +31 -0
  20. data/lib/ecoportal/api/v2/page/component/chart_field/sankey.rb +27 -0
  21. data/lib/ecoportal/api/v2/page/component/chart_field/serie.rb +26 -0
  22. data/lib/ecoportal/api/v2/page/component/chart_field/series_config.rb +23 -0
  23. data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +32 -0
  24. data/lib/ecoportal/api/v2/page/component/checklist_field.rb +35 -2
  25. data/lib/ecoportal/api/v2/page/component/checklist_item.rb +10 -0
  26. data/lib/ecoportal/api/v2/page/component/date_field.rb +21 -0
  27. data/lib/ecoportal/api/v2/page/component/files_field.rb +1 -2
  28. data/lib/ecoportal/api/v2/page/component/gauge_field.rb +24 -1
  29. data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +88 -0
  30. data/lib/ecoportal/api/v2/page/component/images_field.rb +11 -2
  31. data/lib/ecoportal/api/v2/page/component/people_field.rb +8 -1
  32. data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +2 -0
  33. data/lib/ecoportal/api/v2/page/component/reference_field.rb +4 -0
  34. data/lib/ecoportal/api/v2/page/component/selection_field.rb +4 -5
  35. data/lib/ecoportal/api/v2/page/component/selection_option.rb +1 -0
  36. data/lib/ecoportal/api/v2/page/component/signature_field.rb +12 -1
  37. data/lib/ecoportal/api/v2/page/component/tag_field.rb +2 -0
  38. data/lib/ecoportal/api/v2/page/components.rb +2 -2
  39. data/lib/ecoportal/api/v2/page/section.rb +1 -0
  40. data/lib/ecoportal/api/v2/page/sections.rb +1 -1
  41. data/lib/ecoportal/api/v2/page/stages.rb +6 -0
  42. data/lib/ecoportal/api/v2/pages.rb +17 -15
  43. data/lib/ecoportal/api/v2/pages/page_stage.rb +6 -1
  44. data/lib/ecoportal/api/v2/pages/stages.rb +4 -1
  45. data/lib/ecoportal/api/v2/people.rb +31 -0
  46. data/lib/ecoportal/api/v2/registers.rb +60 -6
  47. data/lib/ecoportal/api/v2/registers/page_result.rb +21 -0
  48. data/lib/ecoportal/api/v2/registers/register.rb +37 -0
  49. data/lib/ecoportal/api/v2/registers/stage_result.rb +14 -0
  50. data/lib/ecoportal/api/v2/registers/stages_result.rb +13 -0
  51. data/lib/ecoportal/api/v2/registers/template.rb +12 -0
  52. data/lib/ecoportal/api/v2/version.rb +1 -1
  53. metadata +70 -36
  54. data/lib/ecoportal/api/v2/register.rb +0 -36
  55. data/lib/ecoportal/api/v2/template.rb +0 -10
@@ -15,9 +15,9 @@ module Ecoportal
15
15
  class_resolver :sections_class, "Ecoportal::API::V2::Page::Sections"
16
16
  class_resolver :stages_class, "Ecoportal::API::V2::Page::Stages"
17
17
 
18
- embeds_one :components, multiple: true, klass: :components_class
19
- embeds_one :sections, multiple: true, klass: :sections_class
20
- embeds_one :stages, multiple: true, klass: :stages_class
18
+ embeds_many :components, enum_class: :components_class
19
+ embeds_many :sections, enum_class: :sections_class
20
+ embeds_many :stages, enum_class: :stages_class
21
21
 
22
22
  def as_update
23
23
  super.tap do |hash|
@@ -21,13 +21,18 @@ module Ecoportal
21
21
  class_resolver :signature_field_class, "Ecoportal::API::V2::Page::Component::SignatureField"
22
22
  class_resolver :reference_field_class, "Ecoportal::API::V2::Page::Component::ReferenceField"
23
23
  class_resolver :law_field_class, "Ecoportal::API::V2::Page::Component::LawField"
24
+ class_resolver :chart_field_class, "Ecoportal::API::V2::Page::Component::ChartField"
25
+ class_resolver :chart_fr_field_class, "Ecoportal::API::V2::Page::Component::ChartFrField"
24
26
 
25
27
  class << self
26
- def new_doc(type:)
27
- {
28
- "id" => new_uuid,
29
- "type" => type
30
- }
28
+ def new_doc(type: nil)
29
+ if type
30
+ type_doc = {"type" => type}
31
+ base_doc = get_class(type_doc)&.new_doc || {}
32
+ base_doc.merge!(type_doc)
33
+ end
34
+ return base_doc if base_doc&.key?("id")
35
+ (base_doc || {}).merge("id" => new_uuid)
31
36
  end
32
37
 
33
38
  def get_class(doc)
@@ -53,7 +58,8 @@ module Ecoportal
53
58
  people_field_class
54
59
  when "checklist"
55
60
  checklist_field_class
56
- when "page_action"
61
+ when "page_action","checklist_task"
62
+ #doc["type"] = "checklist_task"
57
63
  action_field_class
58
64
  when "file"
59
65
  files_field_class
@@ -65,6 +71,10 @@ module Ecoportal
65
71
  reference_field_class
66
72
  when "law"
67
73
  law_field_class
74
+ when "chart"
75
+ chart_field_class
76
+ when "frequency_rate_chart"
77
+ chart_fr_field_class
68
78
  else
69
79
  self
70
80
  end
@@ -75,8 +85,13 @@ module Ecoportal
75
85
  passkey :id
76
86
  passthrough :patch_ver, :undeletable
77
87
  passthrough :type, :label, :tooltip, :global_binding
78
- passthrough :hidden, :accent, :deindex
88
+ passthrough :hidden, :accent, :deindex, :required
79
89
  passthrough :hide_view, :hidden_on_reports, :hidden_on_mobile
90
+ passarray :refs
91
+
92
+ def ref_backend
93
+ refs.first
94
+ end
80
95
 
81
96
  def ref
82
97
  if digest = self.class.hash_label(label)
@@ -114,3 +129,5 @@ require 'ecoportal/api/v2/page/component/images_field'
114
129
  require 'ecoportal/api/v2/page/component/signature_field'
115
130
  require 'ecoportal/api/v2/page/component/reference_field'
116
131
  require 'ecoportal/api/v2/page/component/law_field'
132
+ require 'ecoportal/api/v2/page/component/chart_field'
133
+ require 'ecoportal/api/v2/page/component/chart_fr_field'
@@ -4,11 +4,22 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class Action < Common::Content::DoubleModel
7
+ class << self
8
+ def new_doc
9
+ {
10
+ "id" => new_uuid,
11
+ "weight" => 9999
12
+ }
13
+ end
14
+ end
15
+
7
16
  passkey :id
8
17
  passthrough :patch_ver, :name
9
- passthrough :weight, :complete, :overdue, :other_information
10
- passdate :due_date, :created_at #, :completed_at
11
- passthrough :created_by, :assigned_person_member_id
18
+ passthrough :weight, :complete, :other_information
19
+ passdate :due_date
20
+ pass_reader :overdue
21
+ passdate :created_at, read_only: true #, :completed_at
22
+ pass_reader :created_by, :assigned_person_member_id
12
23
  end
13
24
  end
14
25
  end
@@ -4,8 +4,46 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ActionField < Page::Component
7
- #class_resolver :action_class, "Ecoportal::API::V2::Page::Component::Action"
8
- embeds_multiple :actions, klass: "Ecoportal::API::V2::Page::Component::Action", order_key: :weight
7
+ passthrough :create_actions
8
+ passthrough :required_number_of_completed_actions
9
+ passthrough :permits_and_rules_integration, :add_subscribed, :add_subscribed_to_tasks
10
+
11
+ embeds_many :actions, klass: "Ecoportal::API::V2::Page::Component::Action", order_key: :weight
12
+
13
+ # Adds a task with `name` short description
14
+ # @return [Ecoportal::API::V2::Page::Component::Action]
15
+ def add_task (name)
16
+ task_doc = actions.items_class.new_doc
17
+ actions.upsert!(task_doc) do |task|
18
+ task.name = name
19
+ if prev = previous_task(task)
20
+ task.weight = prev.weight
21
+ end
22
+ yield(task) if block_given?
23
+ fix_task_weights!
24
+ end
25
+ end
26
+
27
+ def ordered_tasks
28
+ actions.each_with_index.sort_by do |task, index|
29
+ (task.weight >= 9999) ? [index, index] : [task.weight, index]
30
+ end.map(&:first)
31
+ end
32
+
33
+ private
34
+
35
+ def fix_task_weights!
36
+ ordered_tasks.each_with_index do |task, index|
37
+ task.weight = index
38
+ end
39
+ end
40
+
41
+ def previous_task(value)
42
+ tasks = ordered_tasks
43
+ pos = tasks.index(value) - 1
44
+ return if pos < 0
45
+ tasks[pos]
46
+ end
9
47
  end
10
48
  end
11
49
  end
@@ -0,0 +1,54 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField < Page::Component
7
+ passthrough :mode
8
+ passthrough :relative, :relstart, :relbound
9
+ passthrough :bounded, :ubound, :lbound
10
+ passthrough :filter_date_input
11
+ passthrough :user_id, :lock_chart_user
12
+
13
+ embeds_one :series_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::SeriesConfig"
14
+ embeds_one :frequency_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Frequency"
15
+ embeds_one :heatmap_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Heatmap"
16
+ embeds_one :sankey_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Sankey"
17
+ embeds_one :indicator_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Indicator"
18
+ embeds_one :faceted_series_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Multiseries"
19
+
20
+ embeds_many :series, klass: "Ecoportal::API::V2::Page::Component::ChartField::Serie"
21
+
22
+ MODES = ["frequency", "series", "heatmap", "sankey", "indicator", "faceted_series"]
23
+
24
+ def config
25
+ case mode
26
+ when "frequency"
27
+ frequency_config
28
+ when "series"
29
+ series_config
30
+ when "heatmap"
31
+ heatmap_config
32
+ when "sankey"
33
+ sankey_config
34
+ when "indicator"
35
+ indicator_config
36
+ when "faceted_series"
37
+ faceted_series_config
38
+ end
39
+ end
40
+
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ require 'ecoportal/api/v2/page/component/chart_field/frequency'
49
+ require 'ecoportal/api/v2/page/component/chart_field/series_config'
50
+ require 'ecoportal/api/v2/page/component/chart_field/serie'
51
+ require 'ecoportal/api/v2/page/component/chart_field/heatmap'
52
+ require 'ecoportal/api/v2/page/component/chart_field/sankey'
53
+ require 'ecoportal/api/v2/page/component/chart_field/indicator'
54
+ require 'ecoportal/api/v2/page/component/chart_field/multiseries'
@@ -0,0 +1,29 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField
7
+ class Frequency < Common::Content::DoubleModel
8
+ passkey :id
9
+ passthrough :patch_ver
10
+ passthrough :register_id, :source_type
11
+
12
+ passthrough :mode, :input
13
+ passarray :tags, order_matters: false
14
+ passthrough :secondary
15
+
16
+ passthrough :output, :bar_mode
17
+ passthrough :series_size, :skip_zeroes
18
+
19
+ passarray :filters, :people_filters, :task_filters, order_matters: false
20
+
21
+ passthrough :color
22
+ passarray :color_map, order_matters: false
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField
7
+ class Heatmap < Common::Content::DoubleModel
8
+ passkey :id
9
+ passthrough :patch_ver
10
+ passthrough :register_id, :source_type
11
+
12
+ passthrough :xinput, :xmode
13
+ passthrough :yinput, :ymode
14
+ passarray :xtags, :ytags
15
+
16
+ passthrough :bucket_type
17
+
18
+ passarray :filters, :people_filters, :task_filters, order_matters: false
19
+
20
+ passthrough :color
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField
7
+ class Indicator < Common::Content::DoubleModel
8
+ passkey :id
9
+ passthrough :patch_ver
10
+ passthrough :register_id, :source_type
11
+
12
+ passthrough :date_input, :secondary
13
+ passthrough :duration, :math_mode, :currency
14
+
15
+ passthrough :display_previous, :change_format, :invert_colors
16
+
17
+ passarray :filters, :people_filters, :task_filters, order_matters: false
18
+
19
+ passthrough :color
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField
7
+ class Multiseries < Common::Content::DoubleModel
8
+ passkey :id
9
+ passthrough :patch_ver
10
+ passthrough :register_id, :source_type
11
+
12
+ passthrough :xinput, :xlabel
13
+ passthrough :interval, :calc_mode
14
+
15
+ passthrough :yinput, :ylabel
16
+ passthrough :facet_by_discrete, :discrete_facet
17
+ passthrough :facet_by_tags
18
+ passarray :facet_tags
19
+
20
+ passarray :filters, :people_filters, :task_filters, order_matters: false
21
+
22
+ passthrough :display_mode, :display_type
23
+ passthrough :color
24
+ passarray :color_map
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,27 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField
7
+ class Sankey < Common::Content::DoubleModel
8
+ passkey :id
9
+ passthrough :patch_ver
10
+ passthrough :register_id, :source_type
11
+
12
+ passthrough :xinput, :xmode
13
+ passthrough :yinput, :ymode
14
+ passthrough :zinput, :zmode
15
+ passarray :xtags, :ytags, :ztags
16
+
17
+ passarray :filters, :people_filters, :task_filters, order_matters: false
18
+
19
+ passthrough :color
20
+ passarray :color_map, order_matters: false
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField
7
+ class Serie < Common::Content::DoubleModel
8
+ passkey :id
9
+ passthrough :patch_ver
10
+ passthrough :register_id
11
+
12
+ passthrough :input, :type
13
+ passarray :y_axes
14
+
15
+ passthrough :visual, :stacked
16
+
17
+ passarray :filters, :people_filters, :task_filters, order_matters: false
18
+
19
+ passthrough :color
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartField
7
+ class SeriesConfig < Common::Content::DoubleModel
8
+ passkey :id
9
+ passthrough :patch_ver
10
+
11
+ passthrough :xlabel, :xtype
12
+ passthrough :interval, :calc_mode, :comparative_year
13
+ passthrough :ylabel
14
+
15
+ passthrough :filled_up_with_zeros, :zero_y, :bounds_rigid
16
+ passthrough :stack_all
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,32 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class ChartFrField < Page::Component
7
+ passthrough :register_id, :date_input
8
+ passthrough :filter
9
+
10
+ passthrough :facet_by_tags, :facet_by_select
11
+ passthrough :select_input, :select_mapping
12
+ passarray :facet_tags
13
+
14
+ passthrough :relative, :relstart, :relbound
15
+ passthrough :bounded, :ubound, :lbound
16
+
17
+ passthrough :display_mode, :display_type
18
+ passarray :guidelines
19
+ passthrough :cumulative, :cumulative_mode, :cumulative_start
20
+ passthrough :multiplier, :granularity
21
+
22
+ passthrough :color
23
+ passarray :color_map, order_matters: false
24
+
25
+ passthrough :chart_user
26
+
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end