ecoportal-api-v2 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +38 -3
- data/lib/ecoportal/api/common/content.rb +1 -0
- data/lib/ecoportal/api/common/content/array_model.rb +8 -6
- data/lib/ecoportal/api/common/content/collection_model.rb +10 -4
- data/lib/ecoportal/api/common/content/double_model.rb +11 -0
- data/lib/ecoportal/api/common/content/hash_diff_patch.rb +31 -19
- data/lib/ecoportal/api/common/content/model_helpers.rb +36 -0
- data/lib/ecoportal/api/v2/page.rb +1 -0
- data/lib/ecoportal/api/v2/page/component.rb +33 -3
- data/lib/ecoportal/api/v2/page/component/action.rb +13 -5
- data/lib/ecoportal/api/v2/page/component/action_field.rb +37 -2
- data/lib/ecoportal/api/v2/page/component/chart_field.rb +39 -5
- data/lib/ecoportal/api/v2/page/component/chart_field/benchmark.rb +9 -7
- data/lib/ecoportal/api/v2/page/component/chart_field/config.rb +23 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/frequency.rb +3 -4
- data/lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb +1 -3
- data/lib/ecoportal/api/v2/page/component/chart_field/indicator.rb +4 -5
- data/lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb +3 -5
- data/lib/ecoportal/api/v2/page/component/chart_field/sankey.rb +1 -3
- data/lib/ecoportal/api/v2/page/component/chart_field/serie.rb +3 -4
- data/lib/ecoportal/api/v2/page/component/chart_field/series_config.rb +5 -7
- data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +7 -5
- data/lib/ecoportal/api/v2/page/component/checklist_field.rb +1 -1
- data/lib/ecoportal/api/v2/page/component/checklist_item.rb +3 -2
- data/lib/ecoportal/api/v2/page/component/date_field.rb +71 -4
- data/lib/ecoportal/api/v2/page/component/file.rb +3 -2
- data/lib/ecoportal/api/v2/page/component/gauge_field.rb +2 -2
- data/lib/ecoportal/api/v2/page/component/geo_coordinates.rb +13 -0
- data/lib/ecoportal/api/v2/page/component/geo_field.rb +4 -1
- data/lib/ecoportal/api/v2/page/component/images_field.rb +57 -1
- data/lib/ecoportal/api/v2/page/component/people_field.rb +102 -4
- data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +34 -2
- data/lib/ecoportal/api/v2/page/component/reference_field.rb +32 -3
- data/lib/ecoportal/api/v2/page/component/selection_field.rb +59 -3
- data/lib/ecoportal/api/v2/page/component/selection_option.rb +2 -1
- data/lib/ecoportal/api/v2/page/component/tag_field.rb +31 -1
- data/lib/ecoportal/api/v2/page/components.rb +8 -3
- data/lib/ecoportal/api/v2/page/permission_flags.rb +67 -0
- data/lib/ecoportal/api/v2/page/section.rb +65 -5
- data/lib/ecoportal/api/v2/page/sections.rb +64 -6
- data/lib/ecoportal/api/v2/page/stage.rb +10 -6
- data/lib/ecoportal/api/v2/page/stages.rb +2 -2
- data/lib/ecoportal/api/v2/pages/page_stage.rb +0 -1
- data/lib/ecoportal/api/v2_version.rb +1 -1
- metadata +6 -2
@@ -4,16 +4,18 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class Benchmark <
|
8
|
-
|
9
|
-
passthrough :patch_ver
|
7
|
+
class Benchmark < ChartField::Config
|
8
|
+
passthrough :register_id, :source_type
|
10
9
|
|
11
|
-
passthrough :register_id
|
12
|
-
passthrough :source_type
|
13
10
|
passthrough :benchmark_field, :benchmark_label
|
14
|
-
|
11
|
+
|
12
|
+
passboolean :across
|
13
|
+
passthrough :across_field
|
14
|
+
|
15
|
+
passboolean :grouped
|
16
|
+
passthrough :group_field
|
17
|
+
|
15
18
|
passthrough :against_field, :against_label
|
16
|
-
passthrough :grouped, :group_field
|
17
19
|
|
18
20
|
passthrough :calculation_mode
|
19
21
|
passthrough :min, :max
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class Config < Common::Content::DoubleModel
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def new_doc
|
11
|
+
{"id" => new_uuid}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
passkey :id
|
16
|
+
passthrough :patch_ver
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -4,9 +4,7 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class Frequency <
|
8
|
-
passkey :id
|
9
|
-
passthrough :patch_ver
|
7
|
+
class Frequency < ChartField::Config
|
10
8
|
passthrough :register_id, :source_type
|
11
9
|
|
12
10
|
passthrough :mode, :input
|
@@ -14,7 +12,8 @@ module Ecoportal
|
|
14
12
|
passthrough :secondary
|
15
13
|
|
16
14
|
passthrough :output, :bar_mode
|
17
|
-
passthrough :series_size
|
15
|
+
passthrough :series_size
|
16
|
+
passboolean :skip_zeroes
|
18
17
|
|
19
18
|
passarray :filters, :people_filters, :task_filters, order_matters: false
|
20
19
|
|
@@ -4,9 +4,7 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class Heatmap <
|
8
|
-
passkey :id
|
9
|
-
passthrough :patch_ver
|
7
|
+
class Heatmap < ChartField::Config
|
10
8
|
passthrough :register_id, :source_type
|
11
9
|
|
12
10
|
passthrough :xinput, :xmode
|
@@ -4,15 +4,14 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class Indicator <
|
8
|
-
passkey :id
|
9
|
-
passthrough :patch_ver
|
7
|
+
class Indicator < ChartField::Config
|
10
8
|
passthrough :register_id, :source_type
|
11
9
|
|
12
10
|
passthrough :date_input, :secondary
|
13
|
-
passthrough :duration, :math_mode
|
11
|
+
passthrough :duration, :math_mode
|
14
12
|
|
15
|
-
|
13
|
+
passboolean :currency, :display_previous, :invert_colors
|
14
|
+
passthrough :change_format
|
16
15
|
|
17
16
|
passarray :filters, :people_filters, :task_filters, order_matters: false
|
18
17
|
|
@@ -4,17 +4,15 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class Multiseries <
|
8
|
-
passkey :id
|
9
|
-
passthrough :patch_ver
|
7
|
+
class Multiseries < ChartField::Config
|
10
8
|
passthrough :register_id, :source_type
|
11
9
|
|
12
10
|
passthrough :xinput, :xlabel
|
13
11
|
passthrough :interval, :calc_mode
|
14
12
|
|
15
13
|
passthrough :yinput, :ylabel
|
16
|
-
|
17
|
-
passthrough :
|
14
|
+
passboolean :facet_by_discrete, :facet_by_tags
|
15
|
+
passthrough :discrete_facet
|
18
16
|
passarray :facet_tags
|
19
17
|
|
20
18
|
passarray :filters, :people_filters, :task_filters, order_matters: false
|
@@ -4,9 +4,7 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class Sankey <
|
8
|
-
passkey :id
|
9
|
-
passthrough :patch_ver
|
7
|
+
class Sankey < ChartField::Config
|
10
8
|
passthrough :register_id, :source_type
|
11
9
|
|
12
10
|
passthrough :xinput, :xmode
|
@@ -4,15 +4,14 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class Serie <
|
8
|
-
passkey :id
|
9
|
-
passthrough :patch_ver
|
7
|
+
class Serie < ChartField::Config
|
10
8
|
passthrough :register_id
|
11
9
|
|
12
10
|
passthrough :input, :type
|
13
11
|
passarray :y_axes
|
14
12
|
|
15
|
-
passthrough :visual
|
13
|
+
passthrough :visual
|
14
|
+
passboolean :stacked
|
16
15
|
|
17
16
|
passarray :filters, :people_filters, :task_filters, order_matters: false
|
18
17
|
|
@@ -4,16 +4,14 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChartField
|
7
|
-
class SeriesConfig <
|
8
|
-
passkey :id
|
9
|
-
passthrough :patch_ver
|
10
|
-
|
7
|
+
class SeriesConfig < ChartField::Config
|
11
8
|
passthrough :xlabel, :xtype
|
12
|
-
passthrough :interval, :calc_mode, :comparative_year
|
13
9
|
passthrough :ylabel
|
10
|
+
passthrough :interval, :calc_mode
|
11
|
+
passboolean :comparative_year
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
passboolean :filled_up_with_zeros, :zero_y, :bounds_rigid
|
14
|
+
passboolean :stack_all
|
17
15
|
end
|
18
16
|
end
|
19
17
|
end
|
@@ -7,16 +7,18 @@ module Ecoportal
|
|
7
7
|
passthrough :register_id, :date_input
|
8
8
|
passthrough :filter
|
9
9
|
|
10
|
-
|
11
|
-
passthrough :select_input, :select_mapping
|
10
|
+
passboolean :facet_by_tag, :facet_by_select
|
12
11
|
passarray :facet_tags
|
12
|
+
passthrough :select_input, :select_mapping
|
13
13
|
|
14
|
-
|
15
|
-
passthrough :
|
14
|
+
passboolean :relative, :bounded
|
15
|
+
passthrough :relstart, :relbound
|
16
|
+
passthrough :ubound, :lbound
|
16
17
|
|
17
18
|
passthrough :display_mode, :display_type
|
18
19
|
passarray :guidelines
|
19
|
-
|
20
|
+
passboolean :cumulative
|
21
|
+
passthrough :cumulative_mode, :cumulative_start
|
20
22
|
passthrough :multiplier, :granularity
|
21
23
|
|
22
24
|
passthrough :color
|
@@ -7,7 +7,7 @@ module Ecoportal
|
|
7
7
|
embeds_many :items, klass: "Ecoportal::API::V2::Page::Component::ChecklistItem", order_key: :weight
|
8
8
|
|
9
9
|
def add_item(label:, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
|
10
|
-
itm_doc = items.
|
10
|
+
itm_doc = items.items_class.new_doc
|
11
11
|
items.upsert!(itm_doc, pos: pos, before: before, after: after) do |item|
|
12
12
|
item.label = label
|
13
13
|
if prev = previous_item(item)
|
@@ -4,10 +4,13 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class DateField < Page::Component
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
passthrough :
|
7
|
+
passdate :value
|
8
|
+
passboolean :show_time, :today_button, :past_only
|
9
|
+
passboolean :create_event
|
10
|
+
passthrough :remind_me_in
|
11
|
+
passboolean :renews
|
12
|
+
passthrough :renews_every, :renews_unit
|
13
|
+
passdate :renews_until
|
11
14
|
|
12
15
|
ISO8601 = "%Y-%m-%dT%H:%M:00Z" # "%Y-%m-%dT%H:%M:00.00Z"
|
13
16
|
|
@@ -26,6 +29,70 @@ module Ecoportal
|
|
26
29
|
end
|
27
30
|
end
|
28
31
|
|
32
|
+
def create_event=(value)
|
33
|
+
self.past_only = false
|
34
|
+
doc["create_event"] = !!value
|
35
|
+
end
|
36
|
+
|
37
|
+
# Quick config helper
|
38
|
+
# @param conf [Symbol, Array<Symbol>]
|
39
|
+
# - `:time` to show time
|
40
|
+
# - `:now_button` to display `NOW` button
|
41
|
+
# - `:past` to only allow past dates
|
42
|
+
# - `:event` to enable event
|
43
|
+
# - `:reminder` to set the reminder (requires `:event`)
|
44
|
+
# - `:never`
|
45
|
+
# - `:one_day`
|
46
|
+
# - `:three_days`
|
47
|
+
# - `:one_week`
|
48
|
+
# - `:two_weeks`
|
49
|
+
# - `:one_month`
|
50
|
+
def configure(*conf)
|
51
|
+
conf.each_with_object([]) do |cnf, unused|
|
52
|
+
case cnf
|
53
|
+
when :time
|
54
|
+
self.show_time = true
|
55
|
+
when :now_button
|
56
|
+
self.today_button = true
|
57
|
+
when :past
|
58
|
+
self.past_only = true
|
59
|
+
when :event
|
60
|
+
self.create_event = true
|
61
|
+
when Hash
|
62
|
+
supported = [:reminder]
|
63
|
+
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
64
|
+
unused.push(rest)
|
65
|
+
end
|
66
|
+
if cnf.key?(:reminder) then configure_reminder(cnf[:reminder]) end
|
67
|
+
else
|
68
|
+
unused.push(cnf)
|
69
|
+
end
|
70
|
+
end.yield_self do |unused|
|
71
|
+
super(*unused)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def configure_reminder(value)
|
78
|
+
case value
|
79
|
+
when :never, NilClass
|
80
|
+
self.remind_me_in = "never"
|
81
|
+
when :one_day
|
82
|
+
self.remind_me_in = "1.day"
|
83
|
+
when :three_days
|
84
|
+
self.remind_me_in = "3.days"
|
85
|
+
when :one_week
|
86
|
+
self.remind_me_in = "1.week"
|
87
|
+
when :two_weeks
|
88
|
+
self.remind_me_in = "2.weeks"
|
89
|
+
when :one_month
|
90
|
+
self.remind_me_in = "1.month"
|
91
|
+
else
|
92
|
+
# Unsupported
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
29
96
|
end
|
30
97
|
end
|
31
98
|
end
|
@@ -6,8 +6,9 @@ module Ecoportal
|
|
6
6
|
class File < Common::Content::DoubleModel
|
7
7
|
passkey :id
|
8
8
|
passthrough :patch_ver, :position
|
9
|
-
passthrough :
|
10
|
-
|
9
|
+
passthrough :file_size, :token, read_only: true
|
10
|
+
passthrough :content_type, :file_container_id
|
11
|
+
passdate :file_update_at, read_only: true
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
@@ -5,13 +5,13 @@ module Ecoportal
|
|
5
5
|
class Component
|
6
6
|
class GaugeField < Page::Component
|
7
7
|
passthrough :value, :max
|
8
|
-
passthrough :active_color
|
8
|
+
passthrough :active_color, read_only: true
|
9
9
|
|
10
10
|
embeds_many :stops, klass: "Ecoportal::API::V2::Page::Component::GaugeStop", order_key: :threshold
|
11
11
|
|
12
12
|
# Adds a stop at `threshold` with `color`
|
13
13
|
# @return [Ecoportal::API::V2::Page::Component::GaugeStop]
|
14
|
-
def add_stop
|
14
|
+
def add_stop(threshold: 0.0, color: '#e256d1')
|
15
15
|
stop_doc = stops.items_class.new_doc
|
16
16
|
stops.upsert!(stop_doc) do |stop|
|
17
17
|
stop.threshold = threshold
|
@@ -4,10 +4,13 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class GeoField < Page::Component
|
7
|
-
passthrough :address
|
7
|
+
passthrough :address
|
8
|
+
embeds_one :coordinates, klass: "Ecoportal::API::V2::Page::Component::GeoCoordinates"
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
13
14
|
end
|
15
|
+
|
16
|
+
require 'ecoportal/api/v2/page/component/geo_coordinates'
|
@@ -13,11 +13,67 @@ module Ecoportal
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
passthrough :layout
|
16
|
+
passthrough :layout
|
17
|
+
passboolean :strech, :no_popup, :hide_options
|
17
18
|
embeds_many :images, klass: "Ecoportal::API::V2::Page::Image", order_key: :weight
|
19
|
+
|
20
|
+
# Quick config helper
|
21
|
+
# @param conf [Symbol, Array<Symbol>]
|
22
|
+
# - `:strech` to make the image fit the full size of the image field
|
23
|
+
# - `:popup` to set to enable disable poupup on `click`
|
24
|
+
# - `:layout_button` to offer layout options to user
|
25
|
+
# - `:layout` with the following available values
|
26
|
+
# - `:three_crop` to specify _3 across_ by cutting the image to equalize size
|
27
|
+
# - `:three` to specify _3 across_
|
28
|
+
# - `:two` to specify _2 across_
|
29
|
+
# - `:one` to specify _Full width (1 Across)_
|
30
|
+
def configure(*conf)
|
31
|
+
conf.each_with_object([]) do |cnf, unused|
|
32
|
+
case cnf
|
33
|
+
when :strech
|
34
|
+
self.strech = true
|
35
|
+
when :popup
|
36
|
+
self.no_popup = false
|
37
|
+
when :layout_button
|
38
|
+
self.hide_options = false
|
39
|
+
when Hash
|
40
|
+
supported = [:layout_button, :layout]
|
41
|
+
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
42
|
+
unused.push(rest)
|
43
|
+
end
|
44
|
+
|
45
|
+
if cnf.key?(:layout_button) then self.hide_options = !cnf[:layout_button] end
|
46
|
+
if cnf.key?(:layout) then configure_layour cnf[:layout] end
|
47
|
+
else
|
48
|
+
unused.push(cnf)
|
49
|
+
end
|
50
|
+
end.yield_self do |unused|
|
51
|
+
super(*unused)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def configure_layout(value)
|
58
|
+
case value
|
59
|
+
when :three
|
60
|
+
self.layout = "third"
|
61
|
+
when :two
|
62
|
+
self.layout = "half"
|
63
|
+
when :one
|
64
|
+
self.layout = "fill"
|
65
|
+
when :three_crop
|
66
|
+
self.layout = "third_crop"
|
67
|
+
else
|
68
|
+
# Unsupported
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
18
72
|
end
|
19
73
|
end
|
20
74
|
end
|
21
75
|
end
|
22
76
|
end
|
23
77
|
end
|
78
|
+
|
79
|
+
require 'ecoportal/api/v2/page/component/image'
|