ecoportal-api-v2 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.rspec +3 -0
- data/.rubocop.yml +55 -0
- data/.travis.yml +5 -0
- data/.yardopts +10 -0
- data/CHANGELOG.md +171 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +22 -0
- data/Rakefile +27 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/ecoportal-api-v2.gemspec +34 -0
- data/lib/ecoportal/api-v2.rb +10 -0
- data/lib/ecoportal/api/common.rb +18 -0
- data/lib/ecoportal/api/common/content.rb +18 -0
- data/lib/ecoportal/api/common/content/array_model.rb +286 -0
- data/lib/ecoportal/api/common/content/class_helpers.rb +146 -0
- data/lib/ecoportal/api/common/content/client.rb +40 -0
- data/lib/ecoportal/api/common/content/collection_model.rb +279 -0
- data/lib/ecoportal/api/common/content/doc_helpers.rb +67 -0
- data/lib/ecoportal/api/common/content/double_model.rb +356 -0
- data/lib/ecoportal/api/common/content/hash_diff_patch.rb +183 -0
- data/lib/ecoportal/api/common/content/string_digest.rb +27 -0
- data/lib/ecoportal/api/common/content/wrapped_response.rb +42 -0
- data/lib/ecoportal/api/v2.rb +82 -0
- data/lib/ecoportal/api/v2/page.rb +42 -0
- data/lib/ecoportal/api/v2/page/component.rb +133 -0
- data/lib/ecoportal/api/v2/page/component/action.rb +28 -0
- data/lib/ecoportal/api/v2/page/component/action_field.rb +54 -0
- data/lib/ecoportal/api/v2/page/component/chart_field.rb +54 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/frequency.rb +29 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb +27 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/indicator.rb +26 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb +31 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/sankey.rb +27 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/serie.rb +26 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/series_config.rb +23 -0
- data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +32 -0
- data/lib/ecoportal/api/v2/page/component/checklist_field.rb +49 -0
- data/lib/ecoportal/api/v2/page/component/checklist_item.rb +25 -0
- data/lib/ecoportal/api/v2/page/component/date_field.rb +34 -0
- data/lib/ecoportal/api/v2/page/component/file.rb +16 -0
- data/lib/ecoportal/api/v2/page/component/files_field.rb +13 -0
- data/lib/ecoportal/api/v2/page/component/gauge_field.rb +36 -0
- data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +88 -0
- data/lib/ecoportal/api/v2/page/component/geo_field.rb +13 -0
- data/lib/ecoportal/api/v2/page/component/image.rb +16 -0
- data/lib/ecoportal/api/v2/page/component/images_field.rb +23 -0
- data/lib/ecoportal/api/v2/page/component/law_field.rb +12 -0
- data/lib/ecoportal/api/v2/page/component/number_field.rb +12 -0
- data/lib/ecoportal/api/v2/page/component/people_field.rb +25 -0
- data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +15 -0
- data/lib/ecoportal/api/v2/page/component/reference_field.rb +16 -0
- data/lib/ecoportal/api/v2/page/component/rich_text_field.rb +13 -0
- data/lib/ecoportal/api/v2/page/component/selection_field.rb +78 -0
- data/lib/ecoportal/api/v2/page/component/selection_option.rb +25 -0
- data/lib/ecoportal/api/v2/page/component/signature_field.rb +25 -0
- data/lib/ecoportal/api/v2/page/component/tag_field.rb +14 -0
- data/lib/ecoportal/api/v2/page/components.rb +42 -0
- data/lib/ecoportal/api/v2/page/section.rb +59 -0
- data/lib/ecoportal/api/v2/page/sections.rb +47 -0
- data/lib/ecoportal/api/v2/page/stage.rb +29 -0
- data/lib/ecoportal/api/v2/page/stages.rb +26 -0
- data/lib/ecoportal/api/v2/pages.rb +92 -0
- data/lib/ecoportal/api/v2/pages/page_stage.rb +16 -0
- data/lib/ecoportal/api/v2/pages/stages.rb +55 -0
- data/lib/ecoportal/api/v2/people.rb +31 -0
- data/lib/ecoportal/api/v2/registers.rb +89 -0
- data/lib/ecoportal/api/v2/registers/page_result.rb +21 -0
- data/lib/ecoportal/api/v2/registers/register.rb +37 -0
- data/lib/ecoportal/api/v2/registers/stage_result.rb +14 -0
- data/lib/ecoportal/api/v2/registers/stages_result.rb +13 -0
- data/lib/ecoportal/api/v2/registers/template.rb +12 -0
- data/lib/ecoportal/api/v2/version.rb +7 -0
- metadata +254 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
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
|
+
|
16
|
+
passkey :id
|
17
|
+
passthrough :patch_ver, :name
|
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
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ActionField < Page::Component
|
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
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
require 'ecoportal/api/v2/page/component/action'
|
@@ -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
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChecklistField < Page::Component
|
7
|
+
embeds_many :items, klass: "Ecoportal::API::V2::Page::Component::ChecklistItem", order_key: :weight
|
8
|
+
|
9
|
+
def add_item(label:, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
|
10
|
+
itm_doc = items.stops.items_class.new_doc
|
11
|
+
items.upsert!(itm_doc, pos: pos, before: before, after: after) do |item|
|
12
|
+
item.label = label
|
13
|
+
if prev = previous_item(item)
|
14
|
+
item.weight = prev.weight
|
15
|
+
end
|
16
|
+
yield(item) if block_given?
|
17
|
+
fix_item_weights!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def ordered_items
|
22
|
+
items.each_with_index.sort_by do |item, index|
|
23
|
+
(item.weight >= 9999) ? [index, index] : [item.weight, index]
|
24
|
+
end.map(&:first)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def fix_item_weights!
|
30
|
+
ordered_items.each_with_index do |item, index|
|
31
|
+
item.weight = index
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def previous_item(value)
|
36
|
+
itms = ordered_items
|
37
|
+
pos = itms.index(value) - 1
|
38
|
+
return if pos < 0
|
39
|
+
itms[pos]
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
require 'ecoportal/api/v2/page/component/checklist_item'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChecklistItem < Common::Content::DoubleModel
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def new_doc
|
10
|
+
{
|
11
|
+
"id" => new_uuid,
|
12
|
+
"weight" => 9999
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
passkey :id
|
18
|
+
passthrough :patch_ver, :label
|
19
|
+
passthrough :weight, :checked
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|