ecoportal-api-v2 0.8.29 → 0.8.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +22 -1
- data/lib/ecoportal/api/common/content/string_digest.rb +4 -4
- data/lib/ecoportal/api/v2/page/component/action.rb +0 -1
- data/lib/ecoportal/api/v2/page/component/date_field.rb +19 -1
- data/lib/ecoportal/api/v2/page/component/file.rb +1 -1
- data/lib/ecoportal/api/v2/page/component/law.rb +32 -0
- data/lib/ecoportal/api/v2/page/component/law_field.rb +13 -0
- data/lib/ecoportal/api/v2/page/component/number_field.rb +4 -0
- data/lib/ecoportal/api/v2/page/component/people_field.rb +1 -1
- data/lib/ecoportal/api/v2/page/component/selection_field.rb +2 -2
- data/lib/ecoportal/api/v2/page/component/signature_field.rb +3 -0
- data/lib/ecoportal/api/v2/page/component.rb +4 -4
- data/lib/ecoportal/api/v2/page/mould_counter.rb +32 -0
- data/lib/ecoportal/api/v2/page.rb +1 -0
- data/lib/ecoportal/api/v2/pages/page_stage.rb +11 -4
- data/lib/ecoportal/api/v2_version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbeee3d71e92e44bd48070ae3cafcbc0d1422f7e1a266ae7a36cfd241e4674f1
|
4
|
+
data.tar.gz: 3a6ba98734b9fae590adee2ed5b83394d0fe4389d919f0a7e6287e683efa9220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 178fb29cef779e7a804e12d04098b00baf862a00a53947f7c00783a2b19884bf377b699d9ffd5ddaa0cf7dec2b3d21379e6e79bc1cc90a23fb27c075c0a2b860
|
7
|
+
data.tar.gz: 2c10eb056a68dfaad088420680f32f1ad2b5945c6603f0f3f786bf3ec0581b08cc1a5b073d43a4cc47024ed7f9b691b9ebb78f85b6582c8f89dfa43bc7cf1c3c
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,28 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [0.8.
|
4
|
+
## [0.8.30] - 2022-07-xx
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- `Ecoportal::API::V2::Page::MoultCounter`
|
8
|
+
- Available on `Ecoportal::API::V2::Pages::PageStage`
|
9
|
+
- `Ecoportal::API::V2::Page::Component#Law` added support for `LawField` content
|
10
|
+
- where `Ecoportal::API::V2::Page::Component#LawField` has many of
|
11
|
+
- `Ecoportal::API::V2::Component` added parameter `any_length:` for
|
12
|
+
- `#ref` and `#indexable_label` (aiming to enhance data exportability)
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
- Reviewed `to_s` method on multiple components, to ensure smooth export
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- `Ecoportal::API::V2::Pages::PageStage#uid`
|
19
|
+
- Should check if `mould_conter` exists
|
20
|
+
- Should return `id` if `mould_counter` does not exist
|
21
|
+
- **Exports**
|
22
|
+
- `Ecoportal::API::V2::Pages::Component::PeopleField#to_s`: fix type conversion
|
23
|
+
- `Ecoportal::API::V2::Pages::Component::DateField#to_s`: make time to work to the local timezone where the client script runs
|
24
|
+
|
25
|
+
## [0.8.29] - 2022-07-07
|
5
26
|
|
6
27
|
### Added
|
7
28
|
- `Ecoportal::API::V2::Page::Component::ActionField#permitted_person_schema_ids`
|
@@ -7,16 +7,16 @@ module Ecoportal
|
|
7
7
|
module StringDigest
|
8
8
|
MAX_HASH_LABEL = 64
|
9
9
|
|
10
|
-
def indexable_label(str)
|
10
|
+
def indexable_label(str, any_length: false)
|
11
11
|
return nil unless str
|
12
12
|
lbl = str.downcase.gsub(/[^A-Za-z]+/,"-").slice(0, MAX_HASH_LABEL)
|
13
|
-
return nil
|
13
|
+
return nil if (lbl.length < 3) && !any_length
|
14
14
|
lbl
|
15
15
|
end
|
16
16
|
|
17
17
|
# Calculates the Hash of the field based on label
|
18
|
-
def hash_label(str)
|
19
|
-
return nil unless lbl = indexable_label(str)
|
18
|
+
def hash_label(str, any_length: false)
|
19
|
+
return nil unless lbl = indexable_label(str, any_length: any_length)
|
20
20
|
"z" + Digest::MD5.hexdigest(lbl).slice(0, 8);
|
21
21
|
end
|
22
22
|
|
@@ -35,7 +35,8 @@ module Ecoportal
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def to_s
|
38
|
-
value
|
38
|
+
return nil unless value
|
39
|
+
to_local_time(value).strftime(ISO8601)
|
39
40
|
end
|
40
41
|
|
41
42
|
# Quick config helper
|
@@ -78,6 +79,23 @@ module Ecoportal
|
|
78
79
|
|
79
80
|
private
|
80
81
|
|
82
|
+
def to_local_time(value)
|
83
|
+
case value
|
84
|
+
when DateTime
|
85
|
+
value.new_offset(local_offset).to_time
|
86
|
+
when String
|
87
|
+
to_local_time(Time.parse(value))
|
88
|
+
when Date
|
89
|
+
to_local_time(value.to_time)
|
90
|
+
when Time
|
91
|
+
to_local_time(value.to_datetime)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def local_offset
|
96
|
+
@local_offset ||= DateTime.now.offset
|
97
|
+
end
|
98
|
+
|
81
99
|
def configure_reminder(value)
|
82
100
|
case value
|
83
101
|
when :never, NilClass
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class Law < Common::Content::DoubleModel
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def new_doc
|
10
|
+
{
|
11
|
+
"id" => new_uuid,
|
12
|
+
"weight" => 999
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
passkey :id
|
18
|
+
passforced :patch_ver, default: 1
|
19
|
+
passthrough :title, :weight
|
20
|
+
passthrough :content, :product
|
21
|
+
passthrough :legislation, :category, :topic
|
22
|
+
passdate :updated_at, read_only: true
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
[legislation, title, category, topic].join(" <:> ")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -4,9 +4,22 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class LawField < Page::Component
|
7
|
+
embeds_many :snippets, klass: "Ecoportal::API::V2::Page::Component::Law", order_key: :weight
|
8
|
+
|
9
|
+
def ordered_snippets
|
10
|
+
snippets.sort_by.with_index do |snippet, index|
|
11
|
+
[snippet.weight, index]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s(delimiter: "\n")
|
16
|
+
ordered_snippets.map(&:to_s).join(delimiter)
|
17
|
+
end
|
7
18
|
end
|
8
19
|
end
|
9
20
|
end
|
10
21
|
end
|
11
22
|
end
|
12
23
|
end
|
24
|
+
|
25
|
+
require 'ecoportal/api/v2/page/component/law'
|
@@ -130,9 +130,9 @@ module Ecoportal
|
|
130
130
|
end
|
131
131
|
end
|
132
132
|
|
133
|
-
def to_s(
|
133
|
+
def to_s(value: true, delimiter: "\n")
|
134
134
|
[selected].flatten.compact.map do |opt|
|
135
|
-
|
135
|
+
value ? opt.value : opt.name
|
136
136
|
end.join(delimiter)
|
137
137
|
end
|
138
138
|
|
@@ -101,8 +101,8 @@ module Ecoportal
|
|
101
101
|
refs.first
|
102
102
|
end
|
103
103
|
|
104
|
-
def ref
|
105
|
-
if digest = self.class.hash_label(label)
|
104
|
+
def ref(any_length: false)
|
105
|
+
if digest = self.class.hash_label(label, any_length: any_length)
|
106
106
|
[type, digest].join(".")
|
107
107
|
end
|
108
108
|
end
|
@@ -144,8 +144,8 @@ module Ecoportal
|
|
144
144
|
forces.count > 0
|
145
145
|
end
|
146
146
|
|
147
|
-
def indexable_label
|
148
|
-
self.class.indexable_label(label)
|
147
|
+
def indexable_label(any_length: false)
|
148
|
+
self.class.indexable_label(label, any_length: any_length)
|
149
149
|
end
|
150
150
|
|
151
151
|
# Quick config helper
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class MouldCounter < Common::Content::DoubleModel
|
6
|
+
UID_REGEX = /^(?<prefix>.*?)(?<counter>\d+)(?<postfix>.*)$/i
|
7
|
+
STR_LEN = 5
|
8
|
+
BASE_NUM_STR = "0" * STR_LEN
|
9
|
+
|
10
|
+
passthrough :prefix, :postfix
|
11
|
+
passthrough :counter
|
12
|
+
passthrough :render
|
13
|
+
|
14
|
+
def set(uid)
|
15
|
+
return nil unless uid.is_a?(String)
|
16
|
+
return nil unless match = uid.match(UID_REGEX)
|
17
|
+
self.counter = count_str(match[:counter])
|
18
|
+
self.prefix = match[:prefix]
|
19
|
+
self.postfix = match[:postfix]
|
20
|
+
self.render = "#{match[:prefix]}#{counter}#{match[:postfix]}"
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def count_str(num)
|
26
|
+
(BASE_NUM_STR + num.to_s)[-5..-1]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -3,20 +3,28 @@ module Ecoportal
|
|
3
3
|
class V2
|
4
4
|
class Pages
|
5
5
|
class PageStage < V2::Page
|
6
|
-
passthrough :
|
6
|
+
passthrough :archive
|
7
|
+
embeds_one :mould_counter, klass: "Ecoportal::API::V2::Page::MouldCounter"
|
7
8
|
passthrough :task_priority, :state, :status
|
8
9
|
passthrough :votes_enabled, :upvotes, :downvotes
|
9
10
|
|
10
11
|
#embeds_many :permits, klass: "Ecoportal::API::V2::Page::Permit"
|
11
12
|
passarray :force_errors, :subtags, order_matters: false
|
12
13
|
|
14
|
+
# @return [Boolean] whether or not this entry has mould counter
|
15
|
+
def mould_counter?
|
16
|
+
!!doc["moult_counter"]
|
17
|
+
end
|
18
|
+
|
13
19
|
# @return [String] unique id
|
14
20
|
def uid
|
15
|
-
if counter = mould_counter
|
21
|
+
if mould_counter? && counter = mould_counter
|
16
22
|
counter.render
|
23
|
+
else
|
24
|
+
id
|
17
25
|
end
|
18
26
|
end
|
19
|
-
|
27
|
+
|
20
28
|
# @return [String] `id` of the stage we got the data of.
|
21
29
|
def current_stage_id
|
22
30
|
doc.dig("active_stage", "id") || doc["current_stage_id"]
|
@@ -52,7 +60,6 @@ module Ecoportal
|
|
52
60
|
end
|
53
61
|
msg.empty?? true : msg
|
54
62
|
end
|
55
|
-
|
56
63
|
end
|
57
64
|
end
|
58
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecoportal-api-v2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -206,6 +206,7 @@ files:
|
|
206
206
|
- lib/ecoportal/api/v2/page/component/geo_field.rb
|
207
207
|
- lib/ecoportal/api/v2/page/component/image.rb
|
208
208
|
- lib/ecoportal/api/v2/page/component/images_field.rb
|
209
|
+
- lib/ecoportal/api/v2/page/component/law.rb
|
209
210
|
- lib/ecoportal/api/v2/page/component/law_field.rb
|
210
211
|
- lib/ecoportal/api/v2/page/component/number_field.rb
|
211
212
|
- lib/ecoportal/api/v2/page/component/people_field.rb
|
@@ -222,6 +223,7 @@ files:
|
|
222
223
|
- lib/ecoportal/api/v2/page/force/binding.rb
|
223
224
|
- lib/ecoportal/api/v2/page/force/bindings.rb
|
224
225
|
- lib/ecoportal/api/v2/page/forces.rb
|
226
|
+
- lib/ecoportal/api/v2/page/mould_counter.rb
|
225
227
|
- lib/ecoportal/api/v2/page/permission_flags.rb
|
226
228
|
- lib/ecoportal/api/v2/page/permit.rb
|
227
229
|
- lib/ecoportal/api/v2/page/section.rb
|