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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +24 -1
- data/ecoportal-api-v2.gemspec +1 -1
- data/lib/ecoportal/api/common/concerns.rb +2 -2
- data/lib/ecoportal/api/common/content/class_helpers.rb +42 -7
- data/lib/ecoportal/api/common/content/client.rb +2 -1
- data/lib/ecoportal/api/common/content/collection_model/doc/rooted_key.rb +8 -8
- data/lib/ecoportal/api/common/content/collection_model/doc.rb +2 -2
- data/lib/ecoportal/api/common/content/collection_model/doc_mutation.rb +3 -3
- data/lib/ecoportal/api/common/content/collection_model/model.rb +6 -6
- data/lib/ecoportal/api/common/content/collection_model/modifiers.rb +3 -3
- data/lib/ecoportal/api/common/content/collection_model/mutation.rb +3 -3
- data/lib/ecoportal/api/common/content/collection_model.rb +5 -5
- data/lib/ecoportal/api/common/content/double_model/attributable/nesting/cascaded_callback.rb +203 -98
- data/lib/ecoportal/api/common/content/double_model/attributable/nesting/embeddable.rb +49 -59
- data/lib/ecoportal/api/common/content/double_model/attributable/nesting/keyable.rb +102 -114
- data/lib/ecoportal/api/common/content/double_model/attributable/nesting.rb +5 -3
- data/lib/ecoportal/api/common/content/double_model/attributable.rb +5 -5
- data/lib/ecoportal/api/common/content/double_model/diffable/diff_service.rb +33 -0
- data/lib/ecoportal/api/common/content/double_model/{diffable_model.rb → diffable.rb} +12 -5
- data/lib/ecoportal/api/common/content/double_model/double_doc/linkable_doc.rb +9 -4
- data/lib/ecoportal/api/common/content/double_model/double_doc/replaceable_doc.rb +10 -2
- data/lib/ecoportal/api/common/content/double_model/double_doc/reset_consolidate.rb +1 -1
- data/lib/ecoportal/api/common/content/double_model/double_doc/rooted_key.rb +10 -3
- data/lib/ecoportal/api/common/content/double_model/double_doc.rb +5 -5
- data/lib/ecoportal/api/common/content/double_model/hash_helpers.rb +23 -4
- data/lib/ecoportal/api/common/content/double_model/modifiers.rb +2 -2
- data/lib/ecoportal/api/common/content/double_model.rb +9 -9
- data/lib/ecoportal/api/common/content/hash_diff_patch.rb +21 -7
- data/lib/ecoportal/api/common/content/model_helpers.rb +1 -1
- data/lib/ecoportal/api/common/content.rb +11 -11
- data/lib/ecoportal/api/common.v2.rb +2 -2
- data/lib/ecoportal/api/v2/page/component/action.rb +13 -11
- data/lib/ecoportal/api/v2/page/component/action_field.rb +14 -12
- data/lib/ecoportal/api/v2/page/component/actions_field.rb +2 -1
- data/lib/ecoportal/api/v2/page/component/chart_field/config.rb +1 -2
- data/lib/ecoportal/api/v2/page/component/chart_field.rb +48 -44
- data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +0 -1
- data/lib/ecoportal/api/v2/page/component/checklist_field.rb +9 -6
- data/lib/ecoportal/api/v2/page/component/checklist_item.rb +2 -3
- data/lib/ecoportal/api/v2/page/component/contractor_entities_field.rb +18 -17
- data/lib/ecoportal/api/v2/page/component/date_field.rb +19 -18
- data/lib/ecoportal/api/v2/page/component/file.rb +3 -3
- data/lib/ecoportal/api/v2/page/component/files_field.rb +9 -6
- data/lib/ecoportal/api/v2/page/component/gauge_field.rb +3 -2
- data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +26 -26
- data/lib/ecoportal/api/v2/page/component/geo_field.rb +2 -2
- data/lib/ecoportal/api/v2/page/component/image.rb +6 -5
- data/lib/ecoportal/api/v2/page/component/images_field.rb +21 -20
- data/lib/ecoportal/api/v2/page/component/law.rb +3 -4
- data/lib/ecoportal/api/v2/page/component/law_field.rb +2 -2
- data/lib/ecoportal/api/v2/page/component/number_field.rb +1 -1
- data/lib/ecoportal/api/v2/page/component/people_field.rb +19 -19
- data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +6 -7
- data/lib/ecoportal/api/v2/page/component/reference_field.rb +1 -1
- data/lib/ecoportal/api/v2/page/component/rich_text_field.rb +3 -3
- data/lib/ecoportal/api/v2/page/component/selection_field.rb +32 -35
- data/lib/ecoportal/api/v2/page/component/selection_options.rb +12 -7
- data/lib/ecoportal/api/v2/page/component/tag_field.rb +5 -4
- data/lib/ecoportal/api/v2/page/component.rb +21 -21
- data/lib/ecoportal/api/v2/page/force/bindings.rb +49 -39
- data/lib/ecoportal/api/v2/page/force.rb +9 -9
- data/lib/ecoportal/api/v2/page/forces.rb +1 -1
- data/lib/ecoportal/api/v2/page/permit.rb +3 -3
- data/lib/ecoportal/api/v2/page/sections.rb +19 -14
- data/lib/ecoportal/api/v2/page/stage.rb +27 -20
- data/lib/ecoportal/api/v2/page/stages.rb +1 -1
- data/lib/ecoportal/api/v2/page.rb +13 -12
- data/lib/ecoportal/api/v2/pages/page_stage.rb +2 -2
- data/lib/ecoportal/api/v2/pages.rb +2 -2
- data/lib/ecoportal/api/v2/registers/page_result.rb +3 -3
- data/lib/ecoportal/api/v2/registers/register.rb +4 -5
- data/lib/ecoportal/api/v2/registers/search_results.rb +1 -1
- data/lib/ecoportal/api/v2/registers/stages_result.rb +1 -1
- data/lib/ecoportal/api/v2/registers.rb +6 -6
- data/lib/ecoportal/api/v2/s3/files/batch_upload.rb +1 -0
- data/lib/ecoportal/api/v2/s3/files.rb +3 -3
- data/lib/ecoportal/api/v2.rb +4 -4
- data/lib/ecoportal/api/v2_version.rb +1 -1
- data/lib/ecoportal/api-v2.rb +4 -5
- metadata +6 -5
@@ -12,34 +12,35 @@ module Ecoportal
|
|
12
12
|
passthrough :renews_every, :renews_unit
|
13
13
|
passdate :renews_until
|
14
14
|
|
15
|
-
ISO8601 =
|
15
|
+
ISO8601 = '%Y-%m-%dT%H:%M:00Z'.freeze # '%Y-%m-%dT%H:%M:00.00Z'
|
16
16
|
|
17
17
|
def empty?
|
18
18
|
!value
|
19
19
|
end
|
20
20
|
|
21
21
|
def value=(val)
|
22
|
-
doc[
|
22
|
+
doc['value'] = self.class.to_time(val).then do |datetime|
|
23
23
|
datetime = datetime.utc.strftime(ISO8601) if datetime
|
24
24
|
datetime
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
28
|
def value
|
29
|
-
if val = doc[
|
30
|
-
(Time.parse(val) rescue nil).
|
31
|
-
datetime
|
29
|
+
if (val = doc['value'])
|
30
|
+
(Time.parse(val) rescue nil).then do |datetime| # rubocop:disable Style/RescueModifier
|
31
|
+
datetime&.localtime
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def create_event=(value)
|
37
37
|
self.past_only = false
|
38
|
-
doc[
|
38
|
+
doc['create_event'] = !!value
|
39
39
|
end
|
40
40
|
|
41
41
|
def to_s
|
42
|
-
return
|
42
|
+
return unless value
|
43
|
+
|
43
44
|
to_local_time(value).strftime(ISO8601)
|
44
45
|
end
|
45
46
|
|
@@ -69,14 +70,15 @@ module Ecoportal
|
|
69
70
|
self.create_event = true
|
70
71
|
when Hash
|
71
72
|
supported = [:reminder]
|
72
|
-
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
73
|
+
unless (rest = hash_except!(cnf.dup, *supported)).empty?
|
73
74
|
unused.push(rest)
|
74
75
|
end
|
75
|
-
|
76
|
+
|
77
|
+
configure_reminder(cnf[:reminder]) if cnf.key?(:reminder)
|
76
78
|
else
|
77
79
|
unused.push(cnf)
|
78
80
|
end
|
79
|
-
end.
|
81
|
+
end.then do |unused|
|
80
82
|
super(*unused)
|
81
83
|
end
|
82
84
|
end
|
@@ -103,22 +105,21 @@ module Ecoportal
|
|
103
105
|
def configure_reminder(value)
|
104
106
|
case value
|
105
107
|
when :never, NilClass
|
106
|
-
self.remind_me_in =
|
108
|
+
self.remind_me_in = 'never'
|
107
109
|
when :one_day
|
108
|
-
self.remind_me_in =
|
110
|
+
self.remind_me_in = '1.day'
|
109
111
|
when :three_days
|
110
|
-
self.remind_me_in =
|
112
|
+
self.remind_me_in = '3.days'
|
111
113
|
when :one_week
|
112
|
-
self.remind_me_in =
|
114
|
+
self.remind_me_in = '1.week'
|
113
115
|
when :two_weeks
|
114
|
-
self.remind_me_in =
|
116
|
+
self.remind_me_in = '2.weeks'
|
115
117
|
when :one_month
|
116
|
-
self.remind_me_in =
|
117
|
-
else
|
118
|
+
self.remind_me_in = '1.month'
|
119
|
+
# else
|
118
120
|
# Unsupported
|
119
121
|
end
|
120
122
|
end
|
121
|
-
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
@@ -7,8 +7,8 @@ module Ecoportal
|
|
7
7
|
class << self
|
8
8
|
def new_doc
|
9
9
|
{
|
10
|
-
|
11
|
-
|
10
|
+
'id' => new_uuid,
|
11
|
+
'position' => 99
|
12
12
|
}
|
13
13
|
end
|
14
14
|
end
|
@@ -22,7 +22,7 @@ module Ecoportal
|
|
22
22
|
passdate :file_update_at, read_only: true
|
23
23
|
|
24
24
|
def to_s
|
25
|
-
[label, file_container_id].join(
|
25
|
+
[label, file_container_id].join(' => ')
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -4,20 +4,23 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class FilesField < Page::Component
|
7
|
-
embeds_many :items, klass:
|
7
|
+
embeds_many :items, klass: 'Ecoportal::API::V2::Page::Component::File', order_key: :position
|
8
8
|
|
9
9
|
def empty?
|
10
10
|
items.empty?
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def add_file(container_id, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
|
14
14
|
file_doc = items.items_class.new_doc
|
15
15
|
items.upsert!(file_doc, pos: pos, before: before, after: after) do |file|
|
16
|
-
file.file_container_id
|
17
|
-
|
16
|
+
file.file_container_id = container_id
|
17
|
+
|
18
|
+
if (prev = previous_file(file))
|
18
19
|
file.position = prev.position
|
19
20
|
end
|
21
|
+
|
20
22
|
yield(file) if block_given?
|
23
|
+
|
21
24
|
fix_file_positions!
|
22
25
|
end
|
23
26
|
end
|
@@ -43,10 +46,10 @@ module Ecoportal
|
|
43
46
|
def previous_file(value)
|
44
47
|
fls = ordered_files
|
45
48
|
pos = fls.index(value) - 1
|
46
|
-
return if pos
|
49
|
+
return if pos.negative?
|
50
|
+
|
47
51
|
fls[pos]
|
48
52
|
end
|
49
|
-
|
50
53
|
end
|
51
54
|
end
|
52
55
|
end
|
@@ -7,16 +7,17 @@ module Ecoportal
|
|
7
7
|
passthrough :value, :max
|
8
8
|
passthrough :active_color, read_only: true
|
9
9
|
|
10
|
-
embeds_many :stops, klass:
|
10
|
+
embeds_many :stops, klass: 'Ecoportal::API::V2::Page::Component::GaugeStop', order_key: :threshold
|
11
11
|
|
12
12
|
def empty?
|
13
13
|
!value
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
# Adds a stop at `threshold` with `color`
|
17
17
|
# @return [Ecoportal::API::V2::Page::Component::GaugeStop]
|
18
18
|
def add_stop(threshold: 0.0, color: '#e256d1')
|
19
19
|
stop_doc = stops.items_class.new_doc
|
20
|
+
|
20
21
|
stops.upsert!(stop_doc) do |stop|
|
21
22
|
stop.threshold = threshold
|
22
23
|
stop.color = color
|
@@ -4,13 +4,12 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class GaugeStop < Ecoportal::API::Common::Content::DoubleModel
|
7
|
-
|
8
7
|
class << self
|
9
8
|
def new_doc
|
10
9
|
{
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
'id' => new_uuid,
|
11
|
+
'threshold' => nil,
|
12
|
+
'color' => nil
|
14
13
|
}
|
15
14
|
end
|
16
15
|
end
|
@@ -26,8 +25,8 @@ module Ecoportal
|
|
26
25
|
# - :yellow, :orange, :pumpkin, :red, :magenta, :fuchsia, :purple, :violet
|
27
26
|
# @param value [String, Symbol] you can use a `symbol` to specify a color
|
28
27
|
def color=(value)
|
29
|
-
value
|
30
|
-
doc[
|
28
|
+
value = to_color(value) if value.is_a?(Symbol)
|
29
|
+
doc['color'] = value
|
31
30
|
end
|
32
31
|
|
33
32
|
# @return [Symbol] to get the `color` sym code
|
@@ -35,20 +34,22 @@ module Ecoportal
|
|
35
34
|
color_maps.each do |k, v|
|
36
35
|
return k if color == v
|
37
36
|
end
|
37
|
+
|
38
38
|
:undefined
|
39
39
|
end
|
40
40
|
|
41
41
|
private
|
42
42
|
|
43
43
|
def to_color(value)
|
44
|
-
return
|
44
|
+
return unless valid_color?(value)
|
45
45
|
return value if value.is_a?(String)
|
46
|
+
|
46
47
|
color_maps[value]
|
47
48
|
end
|
48
49
|
|
49
50
|
def valid_color?(value)
|
50
|
-
return true if value.is_a?(String) && colors.any?
|
51
|
-
|
51
|
+
return true if value.is_a?(String) && colors.any? {|c| c == value}
|
52
|
+
true if value.is_a?(Symbol) && color_syms.any? {|s| s == value}
|
52
53
|
end
|
53
54
|
|
54
55
|
def color_syms
|
@@ -61,25 +62,24 @@ module Ecoportal
|
|
61
62
|
|
62
63
|
def color_maps
|
63
64
|
@color_maps ||= [
|
64
|
-
[:blue,
|
65
|
-
[:blue_greyed,
|
66
|
-
[:blue_light,
|
67
|
-
[:turquoise,
|
68
|
-
[:jade,
|
69
|
-
[:green,
|
70
|
-
[:pistachio,
|
71
|
-
[:avocado,
|
72
|
-
[:yellow,
|
73
|
-
[:orange,
|
74
|
-
[:pumpkin,
|
75
|
-
[:red,
|
76
|
-
[:magenta,
|
77
|
-
[:fuchsia,
|
78
|
-
[:purple,
|
79
|
-
[:violet,
|
65
|
+
[:blue, '#5656e2'],
|
66
|
+
[:blue_greyed, '#568be2'],
|
67
|
+
[:blue_light, '#56c0e2'],
|
68
|
+
[:turquoise, '#56e2cf'],
|
69
|
+
[:jade, '#56e29b'],
|
70
|
+
[:green, '#56e267'],
|
71
|
+
[:pistachio, '#79e256'],
|
72
|
+
[:avocado, '#aee256'],
|
73
|
+
[:yellow, '#e2e156'],
|
74
|
+
[:orange, '#e2ad56'],
|
75
|
+
[:pumpkin, '#e27956'],
|
76
|
+
[:red, '#e25667'],
|
77
|
+
[:magenta, '#e2569c'],
|
78
|
+
[:fuchsia, '#e256d1'],
|
79
|
+
[:purple, '#be56e2'],
|
80
|
+
[:violet, '#8a56e2']
|
80
81
|
].to_h
|
81
82
|
end
|
82
|
-
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -5,12 +5,12 @@ module Ecoportal
|
|
5
5
|
class Component
|
6
6
|
class GeoField < Page::Component
|
7
7
|
passthrough :address
|
8
|
-
embeds_one :coordinates, klass:
|
8
|
+
embeds_one :coordinates, klass: 'Ecoportal::API::V2::Page::Component::GeoCoordinates'
|
9
9
|
|
10
10
|
def empty?
|
11
11
|
coordinates.empty?
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def to_s
|
15
15
|
coordinates.to_s
|
16
16
|
end
|
@@ -7,8 +7,8 @@ module Ecoportal
|
|
7
7
|
class << self
|
8
8
|
def new_doc
|
9
9
|
{
|
10
|
-
|
11
|
-
|
10
|
+
'id' => new_uuid,
|
11
|
+
'weight' => 9999
|
12
12
|
}
|
13
13
|
end
|
14
14
|
end
|
@@ -21,10 +21,11 @@ module Ecoportal
|
|
21
21
|
passthrough :dimensions, :styles
|
22
22
|
|
23
23
|
def upload_id=(value)
|
24
|
-
if value !=
|
25
|
-
doc[
|
24
|
+
if value != upload_id
|
25
|
+
doc['src_id'] = doc['upload_id'] = value
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
|
+
upload_id
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
@@ -4,31 +4,34 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ImagesField < Page::Component
|
7
|
-
|
8
7
|
class << self
|
9
8
|
def new_doc
|
10
9
|
{
|
11
|
-
|
10
|
+
'layout' => 'third'
|
12
11
|
}
|
13
12
|
end
|
14
13
|
end
|
15
14
|
|
16
15
|
passthrough :layout
|
17
16
|
passboolean :strech, :no_popup, :hide_options
|
18
|
-
embeds_many :images, klass:
|
17
|
+
embeds_many :images, klass: 'Ecoportal::API::V2::Page::Component::Image', order_key: :weight
|
19
18
|
|
20
19
|
def empty?
|
21
20
|
images.empty?
|
22
21
|
end
|
23
|
-
|
22
|
+
|
24
23
|
def add_image(upload_id, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
|
25
24
|
image_doc = images.items_class.new_doc
|
25
|
+
|
26
26
|
images.upsert!(image_doc, pos: pos, before: before, after: after) do |image|
|
27
|
-
image.upload_id
|
28
|
-
|
27
|
+
image.upload_id = upload_id
|
28
|
+
|
29
|
+
if (prev = previous_image(image))
|
29
30
|
image.weight = prev.weight
|
30
31
|
end
|
32
|
+
|
31
33
|
yield(image) if block_given?
|
34
|
+
|
32
35
|
fix_image_positions!
|
33
36
|
end
|
34
37
|
end
|
@@ -63,17 +66,17 @@ module Ecoportal
|
|
63
66
|
when :layout_button
|
64
67
|
self.hide_options = false
|
65
68
|
when Hash
|
66
|
-
supported = [
|
67
|
-
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
69
|
+
supported = %i[layout_button layout]
|
70
|
+
unless (rest = hash_except!(cnf.dup, *supported)).empty?
|
68
71
|
unused.push(rest)
|
69
72
|
end
|
70
73
|
|
71
|
-
|
72
|
-
if cnf.key?(:layout)
|
74
|
+
self.hide_options = !cnf[:layout_button] if cnf.key?(:layout_button)
|
75
|
+
configure_layout(cnf[:layout]) if cnf.key?(:layout)
|
73
76
|
else
|
74
77
|
unused.push(cnf)
|
75
78
|
end
|
76
|
-
end.
|
79
|
+
end.then do |unused|
|
77
80
|
super(*unused)
|
78
81
|
end
|
79
82
|
end
|
@@ -88,26 +91,24 @@ module Ecoportal
|
|
88
91
|
|
89
92
|
def previous_image(value)
|
90
93
|
imgs = ordered_images
|
91
|
-
pos
|
92
|
-
return if pos
|
94
|
+
pos = imgs.index(value) - 1
|
95
|
+
return if pos.negative?
|
96
|
+
|
93
97
|
imgs[pos]
|
94
98
|
end
|
95
99
|
|
96
100
|
def configure_layout(value)
|
97
101
|
case value
|
98
102
|
when :three
|
99
|
-
self.layout =
|
103
|
+
self.layout = 'third'
|
100
104
|
when :two
|
101
|
-
self.layout =
|
105
|
+
self.layout = 'half'
|
102
106
|
when :one
|
103
|
-
self.layout =
|
107
|
+
self.layout = 'fill'
|
104
108
|
when :three_crop
|
105
|
-
self.layout =
|
106
|
-
else
|
107
|
-
# Unsupported
|
109
|
+
self.layout = 'third_crop'
|
108
110
|
end
|
109
111
|
end
|
110
|
-
|
111
112
|
end
|
112
113
|
end
|
113
114
|
end
|
@@ -4,12 +4,11 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class Law < Ecoportal::API::Common::Content::DoubleModel
|
7
|
-
|
8
7
|
class << self
|
9
8
|
def new_doc
|
10
9
|
{
|
11
|
-
|
12
|
-
|
10
|
+
'id' => new_uuid,
|
11
|
+
'weight' => 999
|
13
12
|
}
|
14
13
|
end
|
15
14
|
end
|
@@ -22,7 +21,7 @@ module Ecoportal
|
|
22
21
|
passdate :updated_at, read_only: true
|
23
22
|
|
24
23
|
def to_s
|
25
|
-
[legislation, title, category, topic].join(
|
24
|
+
[legislation, title, category, topic].join(' <:> ')
|
26
25
|
end
|
27
26
|
end
|
28
27
|
end
|
@@ -4,12 +4,12 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class LawField < Page::Component
|
7
|
-
embeds_many :snippets, klass:
|
7
|
+
embeds_many :snippets, klass: 'Ecoportal::API::V2::Page::Component::Law', order_key: :weight
|
8
8
|
|
9
9
|
def empty?
|
10
10
|
snippets.empty?
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def ordered_snippets
|
14
14
|
snippets.sort_by.with_index do |snippet, index|
|
15
15
|
[snippet.weight, index]
|
@@ -7,7 +7,7 @@ module Ecoportal
|
|
7
7
|
passboolean :is_me_button
|
8
8
|
passthrough :attach_mode
|
9
9
|
passthrough :person_schema_id
|
10
|
-
embeds_many :viewable_fields, klass:
|
10
|
+
embeds_many :viewable_fields, klass: 'Ecoportal::API::V2::Page::Component::PeopleViewableField'
|
11
11
|
|
12
12
|
passboolean :singular
|
13
13
|
passthrough :requires_number
|
@@ -18,7 +18,7 @@ module Ecoportal
|
|
18
18
|
passboolean :attached_people_permissions_enabled, :attached_people_permissions_editable
|
19
19
|
passthrough :apply_attached_people_permissions_to
|
20
20
|
|
21
|
-
embeds_one :attached_people_permissions_flags, klass:
|
21
|
+
embeds_one :attached_people_permissions_flags, klass: 'Ecoportal::API::V2::Page::PermissionFlags'
|
22
22
|
|
23
23
|
def empty?
|
24
24
|
people_ids.empty?
|
@@ -36,7 +36,7 @@ module Ecoportal
|
|
36
36
|
|
37
37
|
# Adds a field to the `viewable_fields`
|
38
38
|
def add_viewable(field_id, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
|
39
|
-
viewable_fields.upsert!({
|
39
|
+
viewable_fields.upsert!({'id' => field_id}, pos: pos, before: before, after: after)
|
40
40
|
end
|
41
41
|
|
42
42
|
# Deletes a field from the `viewable_fields`
|
@@ -66,26 +66,27 @@ module Ecoportal
|
|
66
66
|
# - `:subscribed`
|
67
67
|
# - `:subscribed_to_tasks`
|
68
68
|
# - `requires: number` to fine the number of required people to be attached
|
69
|
-
def configure(*conf)
|
69
|
+
def configure(*conf) # rubocop:disable Metrics/AbcSize
|
70
70
|
conf.each_with_object([]) do |cnf, unused|
|
71
71
|
case cnf
|
72
72
|
when :snapshot
|
73
|
-
self.attach_mode =
|
73
|
+
self.attach_mode = 'snapshot'
|
74
74
|
when :live
|
75
|
-
self.attach_mode =
|
75
|
+
self.attach_mode = 'live'
|
76
76
|
when :me_button
|
77
77
|
self.is_me_button = true
|
78
78
|
when :singular
|
79
79
|
self.singular = true
|
80
80
|
when Hash
|
81
|
-
supported = [
|
82
|
-
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
81
|
+
supported = %i[singular permits requires]
|
82
|
+
unless (rest = hash_except!(cnf.dup, *supported)).empty?
|
83
83
|
unused.push(rest)
|
84
84
|
end
|
85
85
|
|
86
|
-
|
86
|
+
self.singular = !!cnf[:singular] if cnf.key?(:singular)
|
87
|
+
|
87
88
|
if cnf.key?(:permits)
|
88
|
-
if permits = cnf[:permits]
|
89
|
+
if (permits = cnf[:permits])
|
89
90
|
self.attached_people_permissions_enabled = true
|
90
91
|
configure_permits(*[permits].flatten.compact)
|
91
92
|
else
|
@@ -94,7 +95,7 @@ module Ecoportal
|
|
94
95
|
end
|
95
96
|
if cnf.key?(:requires)
|
96
97
|
self.singular = false
|
97
|
-
if requires = cnf[:requires]
|
98
|
+
if (requires = cnf[:requires])
|
98
99
|
self.required = true
|
99
100
|
self.requires_number = requires
|
100
101
|
else
|
@@ -105,7 +106,7 @@ module Ecoportal
|
|
105
106
|
else
|
106
107
|
unused.push(cnf)
|
107
108
|
end
|
108
|
-
end.
|
109
|
+
end.then do |unused|
|
109
110
|
super(*unused)
|
110
111
|
end
|
111
112
|
end
|
@@ -116,13 +117,13 @@ module Ecoportal
|
|
116
117
|
conf.each_with_object([]) do |cnf, flags|
|
117
118
|
case cnf
|
118
119
|
when :all
|
119
|
-
self.apply_attached_people_permissions_to =
|
120
|
+
self.apply_attached_people_permissions_to = 'page'
|
120
121
|
when :stages
|
121
|
-
self.apply_attached_people_permissions_to =
|
122
|
+
self.apply_attached_people_permissions_to = 'all_stages'
|
122
123
|
when :page
|
123
|
-
self.apply_attached_people_permissions_to =
|
124
|
+
self.apply_attached_people_permissions_to = 'page_only'
|
124
125
|
when :stage
|
125
|
-
self.apply_attached_people_permissions_to =
|
126
|
+
self.apply_attached_people_permissions_to = 'current_stage'
|
126
127
|
when :can_edit
|
127
128
|
self.attached_people_permissions_editable = true
|
128
129
|
when :can_view
|
@@ -130,11 +131,10 @@ module Ecoportal
|
|
130
131
|
else
|
131
132
|
flags.push(cnf)
|
132
133
|
end
|
133
|
-
end.
|
134
|
-
|
134
|
+
end.then do |flags|
|
135
|
+
attached_people_permissions_flags.configure(*flags)
|
135
136
|
end
|
136
137
|
end
|
137
|
-
|
138
138
|
end
|
139
139
|
end
|
140
140
|
end
|
@@ -12,7 +12,7 @@ module Ecoportal
|
|
12
12
|
def empty?
|
13
13
|
value.to_s.strip.empty?
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def to_s
|
17
17
|
value
|
18
18
|
end
|
@@ -33,20 +33,19 @@ module Ecoportal
|
|
33
33
|
when :exact_index
|
34
34
|
self.exact_index = true
|
35
35
|
when Hash
|
36
|
-
supported = [
|
37
|
-
unless (rest = hash_except(cnf.dup, *supported)).empty?
|
36
|
+
supported = %i[multiline max_length]
|
37
|
+
unless (rest = hash_except!(cnf.dup, *supported)).empty?
|
38
38
|
unused.push(rest)
|
39
39
|
end
|
40
|
-
if cnf.key?(:multiline)
|
41
|
-
|
40
|
+
self.multiline = !!cnf[:multiline] if cnf.key?(:multiline) # rubocop:disable Style/DoubleNegation
|
41
|
+
self.max_length = cnf[:max_length] if cnf.key?(:max_length)
|
42
42
|
else
|
43
43
|
unused.push(cnf)
|
44
44
|
end
|
45
|
-
end.
|
45
|
+
end.then do |unused|
|
46
46
|
super(*unused)
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
50
49
|
end
|
51
50
|
end
|
52
51
|
end
|
@@ -9,17 +9,17 @@ module Ecoportal
|
|
9
9
|
HTML_TAGS_REX = /<("[^"]*"|'[^']*'|[^'">])*>/
|
10
10
|
|
11
11
|
def empty?
|
12
|
-
to_s.
|
12
|
+
to_s.strip.empty?
|
13
13
|
end
|
14
14
|
|
15
15
|
def to_s
|
16
|
-
remove_html_tags(content)
|
16
|
+
remove_html_tags(content).to_s
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
21
|
def remove_html_tags(str)
|
22
|
-
str = str.gsub(HTML_TAGS_REX, ' ')
|
22
|
+
str = str.gsub(HTML_TAGS_REX, ' ') if str
|
23
23
|
str = str.gsub(/[^[:print:]]/, '') if str
|
24
24
|
str = str.gsub(": ", ' ') if str
|
25
25
|
str = str.gsub(""", '"') if str
|