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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca7591fd58fc849aefad7508d07e7902d5016ccaa19642dc7f8bb94b2ad445ca
4
- data.tar.gz: c0a76091ed2702c29973d7295654f447425bf8e819e9684913bc71132eeccc9a
3
+ metadata.gz: dbeee3d71e92e44bd48070ae3cafcbc0d1422f7e1a266ae7a36cfd241e4674f1
4
+ data.tar.gz: 3a6ba98734b9fae590adee2ed5b83394d0fe4389d919f0a7e6287e683efa9220
5
5
  SHA512:
6
- metadata.gz: aab5c8003ceb2d0bfc71169f9a2bcda26cb37253cad9a6ec277309c4d2c6bb1a3e4a4fc8717b69286a81b4b6cf43b8e3c969267171f5d4b529fefbe1c85e2da8
7
- data.tar.gz: 96d45a7aba715ea08eb0b96f6920f2dae25a8f27383f460e4883bf79233a9efb2a26bea10025d7b8a7931b3450c9650e1518da52044c90e03f8edfcbba8f9058
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.29] - 2022-06-xx
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 unless lbl.length >= 3
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
 
@@ -41,7 +41,6 @@ module Ecoportal
41
41
  assignee = assigned_person_member["name"] || assigned_person_member["email"]
42
42
  "#{name}, #{created_at.to_s}, #{stat}, #{assignee}"
43
43
  end
44
-
45
44
  end
46
45
  end
47
46
  end
@@ -35,7 +35,8 @@ module Ecoportal
35
35
  end
36
36
 
37
37
  def to_s
38
- value.to_s
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
@@ -22,7 +22,7 @@ module Ecoportal
22
22
  passdate :file_update_at, read_only: true
23
23
 
24
24
  def to_s
25
- file_container_id
25
+ [label, file_container_id].join(" => ")
26
26
  end
27
27
  end
28
28
  end
@@ -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'
@@ -5,6 +5,10 @@ module Ecoportal
5
5
  class Component
6
6
  class NumberField < Page::Component
7
7
  passthrough :value
8
+
9
+ def to_s
10
+ value
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -41,7 +41,7 @@ module Ecoportal
41
41
  end
42
42
 
43
43
  def to_s(delimiter: "\n")
44
- people_ids.join(delimiter)
44
+ people_ids.to_a.join(delimiter)
45
45
  end
46
46
 
47
47
  # Quick config helper
@@ -130,9 +130,9 @@ module Ecoportal
130
130
  end
131
131
  end
132
132
 
133
- def to_s(name: true, delimiter: "\n")
133
+ def to_s(value: true, delimiter: "\n")
134
134
  [selected].flatten.compact.map do |opt|
135
- name ? opt.name : opt.value
135
+ value ? opt.value : opt.name
136
136
  end.join(delimiter)
137
137
  end
138
138
 
@@ -18,6 +18,9 @@ module Ecoportal
18
18
  passdate :signature_updated_at, read_only: true
19
19
  passthrough :signature_content, :color
20
20
 
21
+ def to_s
22
+ [signed_by_name, signature_updated_at].join(" at ")
23
+ end
21
24
  end
22
25
  end
23
26
  end
@@ -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
@@ -102,6 +102,7 @@ module Ecoportal
102
102
  end
103
103
  end
104
104
 
105
+ require 'ecoportal/api/v2/page/mould_counter'
105
106
  require 'ecoportal/api/v2/page/permission_flags'
106
107
  require 'ecoportal/api/v2/page/permit'
107
108
  require 'ecoportal/api/v2/page/component'
@@ -3,20 +3,28 @@ module Ecoportal
3
3
  class V2
4
4
  class Pages
5
5
  class PageStage < V2::Page
6
- passthrough :mould_counter, :archive
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
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GEM2_VERSION = "0.8.29"
3
+ GEM2_VERSION = "0.8.30"
4
4
  end
5
5
  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.29
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-07 00:00:00.000000000 Z
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