ecoportal-api-v2 0.8.7 → 0.8.11
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +82 -1
- data/lib/ecoportal/api/common/content/array_model.rb +8 -6
- data/lib/ecoportal/api/common/content/collection_model.rb +45 -20
- data/lib/ecoportal/api/common/content/double_model.rb +94 -5
- data/lib/ecoportal/api/common/content/hash_diff_patch.rb +44 -22
- data/lib/ecoportal/api/common/content/model_helpers.rb +36 -0
- data/lib/ecoportal/api/common/content.rb +1 -0
- data/lib/ecoportal/api/v2/page/component/action.rb +17 -8
- data/lib/ecoportal/api/v2/page/component/action_field.rb +37 -2
- data/lib/ecoportal/api/v2/page/component/chart_field/benchmark.rb +30 -0
- 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_field.rb +43 -5
- 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 +7 -5
- data/lib/ecoportal/api/v2/page/component/date_field.rb +71 -4
- data/lib/ecoportal/api/v2/page/component/file.rb +14 -3
- data/lib/ecoportal/api/v2/page/component/files_field.rb +37 -1
- data/lib/ecoportal/api/v2/page/component/gauge_field.rb +2 -2
- data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +5 -5
- 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/image.rb +2 -1
- data/lib/ecoportal/api/v2/page/component/images_field.rb +57 -1
- data/lib/ecoportal/api/v2/page/component/number_field.rb +1 -0
- data/lib/ecoportal/api/v2/page/component/people_field.rb +115 -5
- data/lib/ecoportal/api/v2/page/component/people_viewable_field.rb +14 -0
- 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 +65 -7
- data/lib/ecoportal/api/v2/page/component/selection_option.rb +16 -5
- data/lib/ecoportal/api/v2/page/component/signature_field.rb +3 -2
- data/lib/ecoportal/api/v2/page/component/tag_field.rb +31 -1
- data/lib/ecoportal/api/v2/page/component.rb +44 -10
- 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/permit.rb +15 -0
- data/lib/ecoportal/api/v2/page/section.rb +70 -9
- data/lib/ecoportal/api/v2/page/sections.rb +64 -6
- data/lib/ecoportal/api/v2/page/stage.rb +12 -4
- data/lib/ecoportal/api/v2/page/stages.rb +7 -7
- data/lib/ecoportal/api/v2/page.rb +19 -2
- data/lib/ecoportal/api/v2/pages/page_stage.rb +9 -3
- data/lib/ecoportal/api/v2/pages.rb +6 -2
- data/lib/ecoportal/api/v2/registers/search_results.rb +13 -0
- data/lib/ecoportal/api/v2/registers.rb +13 -0
- data/lib/ecoportal/api/v2_version.rb +1 -1
- metadata +10 -2
@@ -5,8 +5,40 @@ module Ecoportal
|
|
5
5
|
class Component
|
6
6
|
class PlainTextField < Page::Component
|
7
7
|
passthrough :value
|
8
|
-
|
9
|
-
|
8
|
+
passboolean :multiline
|
9
|
+
passthrough :max_length
|
10
|
+
passboolean :exact_index
|
11
|
+
|
12
|
+
# Quick config helper
|
13
|
+
# @param conf [Symbol, Array<Symbol>]
|
14
|
+
# - `:multiline` multi line mode
|
15
|
+
# - `:singleline` signle line mode
|
16
|
+
# - `:exact_index` to make the `value` indexed as a **whole** (as opposite to its parts or n-grams)
|
17
|
+
# - `:max_length` specify the maximum length of the `value`
|
18
|
+
def configure(*conf)
|
19
|
+
conf.each_with_object([]) do |cnf, unused|
|
20
|
+
case cnf
|
21
|
+
when :multiline
|
22
|
+
self.multiline = true
|
23
|
+
when :singleline
|
24
|
+
self.multiline = false
|
25
|
+
when :exact_index
|
26
|
+
self.exact_index = true
|
27
|
+
when Hash
|
28
|
+
supported = [:multiline, :max_length]
|
29
|
+
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
30
|
+
unused.push(rest)
|
31
|
+
end
|
32
|
+
if cnf.key?(:multiline) then self.multiline = !!cnf[:multiline] end
|
33
|
+
if cnf.key?(:max_length) then self.max_length = cnf[:max_length] end
|
34
|
+
else
|
35
|
+
unused.push(cnf)
|
36
|
+
end
|
37
|
+
end.yield_self do |unused|
|
38
|
+
super(*unused)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
10
42
|
end
|
11
43
|
end
|
12
44
|
end
|
@@ -5,9 +5,38 @@ module Ecoportal
|
|
5
5
|
class Component
|
6
6
|
class ReferenceField < Page::Component
|
7
7
|
passthrough :register_id
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
passboolean :hide_create, :hide_attach
|
9
|
+
passboolean :hide_metadata, :hide_dashboards
|
10
|
+
passboolean :display_fields, :display_fields_in_lookup
|
11
|
+
|
12
|
+
# Quick config helper
|
13
|
+
# @param conf [Symbol, Array<Symbol>]
|
14
|
+
# - `:show_fields` specify if the public register fields should be shown (requires `register_id`)
|
15
|
+
# - `:create` specify if the `NEW` button should appear
|
16
|
+
# - `:attach` specify if the `ATTACH` button should appear
|
17
|
+
# - `:metadata` specify if `metadata` should be shown (i.e. status)
|
18
|
+
def configure(*conf)
|
19
|
+
conf.each_with_object([]) do |cnf, unused|
|
20
|
+
case cnf
|
21
|
+
when :show_fields
|
22
|
+
self.display_fields = true
|
23
|
+
self.display_fields_in_lookup = true
|
24
|
+
when Hash
|
25
|
+
supported = [:create, :attach, :metadata]
|
26
|
+
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
27
|
+
unused.push(rest)
|
28
|
+
end
|
29
|
+
if cnf.key?(:create) then self.hide_create = !cnf[:create] end
|
30
|
+
if cnf.key?(:attach) then self.hide_attach = !cnf[:attach] end
|
31
|
+
if cnf.key?(:metadata) then self.hide_metadata = !cnf[:metadata] end
|
32
|
+
else
|
33
|
+
unused.push(cnf)
|
34
|
+
end
|
35
|
+
end.yield_self do |unused|
|
36
|
+
super(*unused)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
11
40
|
end
|
12
41
|
end
|
13
42
|
end
|
@@ -4,18 +4,20 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class SelectionField < Page::Component
|
7
|
-
|
8
|
-
passthrough :
|
7
|
+
passboolean :multiple, :flat, :other
|
8
|
+
passthrough :other_desc
|
9
9
|
passthrough :data_type
|
10
10
|
|
11
11
|
embeds_many :options, klass: "Ecoportal::API::V2::Page::Component::SelectionOption", order_key: :weight
|
12
12
|
|
13
|
-
def numeric!
|
14
|
-
|
13
|
+
def numeric!(&block)
|
14
|
+
ordered_options.each {|opt| opt.numeric!(&block)}
|
15
|
+
self.data_type = "num"
|
15
16
|
end
|
16
17
|
|
17
|
-
def text!
|
18
|
-
|
18
|
+
def text!(&block)
|
19
|
+
ordered_options.each {|opt| opt.text!(&block)}
|
20
|
+
self.data_type = "str"
|
19
21
|
end
|
20
22
|
|
21
23
|
def select(value)
|
@@ -42,7 +44,7 @@ module Ecoportal
|
|
42
44
|
end
|
43
45
|
end
|
44
46
|
|
45
|
-
def add_option(
|
47
|
+
def add_option(value:, name: nil, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
|
46
48
|
opt_doc = options.items_class.new_doc
|
47
49
|
options.upsert!(opt_doc, pos: pos, before: before, after: after) do |option|
|
48
50
|
option.name = name
|
@@ -61,8 +63,64 @@ module Ecoportal
|
|
61
63
|
end.map(&:first)
|
62
64
|
end
|
63
65
|
|
66
|
+
# Quick config helper
|
67
|
+
# @param conf [Symbol, Array<Symbol>]
|
68
|
+
# - `:flat` to display in flat mode
|
69
|
+
# - `:multiple` to allow multiple selection
|
70
|
+
# - `:single` to set to singular selection
|
71
|
+
# - `:other` to enable `other` button
|
72
|
+
# - `:options` to add options (`Hash<value, name>`)
|
73
|
+
# - `:type` to define the type
|
74
|
+
# - `:num`
|
75
|
+
# - `:str`
|
76
|
+
def configure(*conf)
|
77
|
+
conf.each_with_object([]) do |cnf, unused|
|
78
|
+
case cnf
|
79
|
+
when :flat
|
80
|
+
self.flat = true
|
81
|
+
when :multiple
|
82
|
+
self.multiple = true
|
83
|
+
when :single
|
84
|
+
self.multiple = false
|
85
|
+
when :other
|
86
|
+
self.other = true
|
87
|
+
when Hash
|
88
|
+
supported = [:flat, :options, :type]
|
89
|
+
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
90
|
+
unused.push(rest)
|
91
|
+
end
|
92
|
+
|
93
|
+
if cnf.key?(:flat) then self.flat = cnf[:flat] end
|
94
|
+
if cnf.key?(:options)
|
95
|
+
if opts = cnf[:options]
|
96
|
+
configure_options opts
|
97
|
+
end
|
98
|
+
end
|
99
|
+
if cnf.key?(:type)
|
100
|
+
if cnf[:type] == :str
|
101
|
+
self.text!
|
102
|
+
elsif cnf[:type] == :num
|
103
|
+
self.numeric!
|
104
|
+
else
|
105
|
+
# Unknown type
|
106
|
+
end
|
107
|
+
end
|
108
|
+
else
|
109
|
+
unused.push(cnf)
|
110
|
+
end
|
111
|
+
end.yield_self do |unused|
|
112
|
+
super(*unused)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
64
116
|
private
|
65
117
|
|
118
|
+
def configure_options(opts)
|
119
|
+
opts.each do |val, nm|
|
120
|
+
add_option(value: val, name: nm)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
66
124
|
def fix_option_weights!
|
67
125
|
ordered_options.each_with_index do |option, index|
|
68
126
|
option.weight = index
|
@@ -4,19 +4,30 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class SelectionOption < Common::Content::DoubleModel
|
7
|
-
|
7
|
+
|
8
8
|
class << self
|
9
9
|
def new_doc
|
10
10
|
{
|
11
|
-
"id"
|
12
|
-
"weight"
|
11
|
+
"id" => new_uuid,
|
12
|
+
"weight" => 9999
|
13
13
|
}
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
passkey :id
|
18
|
-
|
19
|
-
passthrough :
|
18
|
+
passforced :patch_ver, default: 1
|
19
|
+
passthrough :name, :value
|
20
|
+
passthrough :weight
|
21
|
+
passboolean :selected
|
22
|
+
|
23
|
+
def numeric!
|
24
|
+
self.value = block_given?? yield(value) : value.to_i
|
25
|
+
end
|
26
|
+
|
27
|
+
def text!
|
28
|
+
self.value = block_given?? yield(value) : value.to_s
|
29
|
+
end
|
30
|
+
|
20
31
|
end
|
21
32
|
end
|
22
33
|
end
|
@@ -13,8 +13,9 @@ module Ecoportal
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
passthrough :signed_by_id, :signed_by_name, :
|
17
|
-
|
16
|
+
passthrough :signed_by_id, :signed_by_name, read_only: true
|
17
|
+
passthrough :signature_url, read_only: true
|
18
|
+
passdate :signature_updated_at, read_only: true
|
18
19
|
passthrough :signature_content, :color
|
19
20
|
|
20
21
|
end
|
@@ -4,8 +4,38 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class TagField < Page::Component
|
7
|
-
|
7
|
+
passboolean :single_select, :use_defaults
|
8
8
|
passthrough :tag_tree_id, :button_text
|
9
|
+
|
10
|
+
# Quick config helper
|
11
|
+
# @param conf [Symbol, Array<Symbol>]
|
12
|
+
# - `:multiple` to allow multiple selection
|
13
|
+
# - `:single` to set to singular selection
|
14
|
+
# - `:default_tag` to prepopulate using users's `default_tag`
|
15
|
+
# - `:button_text` to define the button description
|
16
|
+
def configure(*conf)
|
17
|
+
conf.each_with_object([]) do |cnf, unused|
|
18
|
+
case cnf
|
19
|
+
when :single
|
20
|
+
self.single_select = true
|
21
|
+
when :multiple
|
22
|
+
self.single_select = false
|
23
|
+
when :default_tag
|
24
|
+
self.use_defaults = true
|
25
|
+
when Hash
|
26
|
+
supported = [:button_text]
|
27
|
+
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
28
|
+
unused.push(rest)
|
29
|
+
end
|
30
|
+
if cnf.key?(:button_text) then self.button_text = cnf[:button_text] end
|
31
|
+
else
|
32
|
+
unused.push(cnf)
|
33
|
+
end
|
34
|
+
end.yield_self do |unused|
|
35
|
+
super(*unused)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
9
39
|
end
|
10
40
|
end
|
11
41
|
end
|
@@ -26,13 +26,16 @@ module Ecoportal
|
|
26
26
|
|
27
27
|
class << self
|
28
28
|
def new_doc(type: nil)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
{
|
30
|
+
"id" => new_uuid
|
31
|
+
}.tap do |base_doc|
|
32
|
+
if type
|
33
|
+
base_doc.merge!({"type" => type})
|
34
|
+
if klass = get_class(base_doc)
|
35
|
+
base_doc.merge!(klass.new_doc || {})
|
36
|
+
end
|
37
|
+
end
|
33
38
|
end
|
34
|
-
return base_doc if base_doc&.key?("id")
|
35
|
-
(base_doc || {}).merge("id" => new_uuid)
|
36
39
|
end
|
37
40
|
|
38
41
|
def get_class(doc)
|
@@ -59,7 +62,6 @@ module Ecoportal
|
|
59
62
|
when "checklist"
|
60
63
|
checklist_field_class
|
61
64
|
when "page_action","checklist_task"
|
62
|
-
#doc["type"] = "checklist_task"
|
63
65
|
action_field_class
|
64
66
|
when "file"
|
65
67
|
files_field_class
|
@@ -83,10 +85,12 @@ module Ecoportal
|
|
83
85
|
end
|
84
86
|
|
85
87
|
passkey :id
|
86
|
-
|
88
|
+
passforced :patch_ver, default: 1
|
89
|
+
passboolean :undeletable
|
87
90
|
passthrough :type, :label, :tooltip, :global_binding
|
88
|
-
|
89
|
-
passthrough :
|
91
|
+
passboolean :hidden, :deindex, :required
|
92
|
+
passthrough :accent
|
93
|
+
passboolean :hide_view, :hidden_on_reports, :hidden_on_mobile
|
90
94
|
passarray :refs
|
91
95
|
|
92
96
|
def ref_backend
|
@@ -107,6 +111,36 @@ module Ecoportal
|
|
107
111
|
self.class.indexable_label(label)
|
108
112
|
end
|
109
113
|
|
114
|
+
# Quick config helper
|
115
|
+
# @param conf [Symbol, Array<Symbol>]
|
116
|
+
# - `:required`
|
117
|
+
# - `:hide_view` to hide in view mode
|
118
|
+
# - `:hide_mobile` to hide in mobile app
|
119
|
+
# - `:hide_reports` to hide in reports
|
120
|
+
# - `:global` to define a global binding
|
121
|
+
def configure(*conf)
|
122
|
+
conf.each_with_object([]) do |cnf, unused|
|
123
|
+
case cnf
|
124
|
+
when :required
|
125
|
+
self.required = true
|
126
|
+
when :hide_view
|
127
|
+
self.hide_view = true
|
128
|
+
when :hide_mobile
|
129
|
+
self.hidden_on_mobile = true
|
130
|
+
when :hide_reports
|
131
|
+
self.hidden_on_reports = true
|
132
|
+
when Hash
|
133
|
+
if cnf.key?(:global)
|
134
|
+
self.global_binding = cnf[:global]
|
135
|
+
end
|
136
|
+
else
|
137
|
+
unused.push(cnf)
|
138
|
+
end
|
139
|
+
end.tap do |unused|
|
140
|
+
raise "Unsupported configuration options '#{unused}' for #{self.class}" unless unused.empty?
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
110
144
|
end
|
111
145
|
end
|
112
146
|
end
|
@@ -13,6 +13,12 @@ module Ecoportal
|
|
13
13
|
|
14
14
|
order_matters = true
|
15
15
|
|
16
|
+
def get_by_id(id)
|
17
|
+
self.find do |comp|
|
18
|
+
comp.id == id
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
16
22
|
def get_by_type(type)
|
17
23
|
self.select do |comp|
|
18
24
|
comp.type.downcase == type.to_s.strip.downcase
|
@@ -21,10 +27,9 @@ module Ecoportal
|
|
21
27
|
|
22
28
|
def get_by_name(name, type: nil)
|
23
29
|
pool = type ? get_by_type(type) : self
|
24
|
-
|
25
30
|
pool.select do |comp|
|
26
|
-
comp.label
|
27
|
-
end
|
31
|
+
same_string?(comp.label, name)
|
32
|
+
end
|
28
33
|
end
|
29
34
|
|
30
35
|
def add(label:, type:)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class PermissionFlags < Common::Content::DoubleModel
|
6
|
+
class << self
|
7
|
+
def new_doc
|
8
|
+
{
|
9
|
+
"can_restructure" => false,
|
10
|
+
"can_configure" => false,
|
11
|
+
"can_permission" => false,
|
12
|
+
"can_create_actions" => false,
|
13
|
+
"can_administrate_actions" => false,
|
14
|
+
"subscribed" => false,
|
15
|
+
"subscribed_to_tasks" => false
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
passboolean :can_restructure, :can_configure
|
21
|
+
passboolean :can_permission, :can_create_actions, :can_administrate_actions
|
22
|
+
passboolean :subscribed, :subscribed_to_tasks
|
23
|
+
|
24
|
+
def reset!
|
25
|
+
doc.merge!(self.class.new_doc)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Quick config helper
|
29
|
+
# @param conf [Symbol, Array<Symbol>]
|
30
|
+
# - `:restructure`
|
31
|
+
# - `:configure`
|
32
|
+
# - `:can_permission`
|
33
|
+
# - `:create_actions`
|
34
|
+
# - `:admin_actions`
|
35
|
+
# - `:subscribed`
|
36
|
+
# - `:subscribed_to_tasks`
|
37
|
+
def configure(*conf)
|
38
|
+
conf.each_with_object([]) do |cnf, unused|
|
39
|
+
case cnf
|
40
|
+
when :restructure
|
41
|
+
self.can_restructure = true
|
42
|
+
when :configure
|
43
|
+
self.can_configure = true
|
44
|
+
when :can_permission
|
45
|
+
self.can_permission = true
|
46
|
+
when :create_actions
|
47
|
+
self.can_create_actions = true
|
48
|
+
when :admin_actions
|
49
|
+
self.can_administrate_actions = true
|
50
|
+
when :subscribed
|
51
|
+
self.subscribed = true
|
52
|
+
when :subscribed_to_tasks
|
53
|
+
self.subscribed_to_tasks = true
|
54
|
+
else
|
55
|
+
unused.push(cnf)
|
56
|
+
end
|
57
|
+
end.yield_self do |unused|
|
58
|
+
raise "Unknown configuaration options #{unused}" unless unused.empty?
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|