ecoportal-api-oozes 0.7.2 → 0.7.3

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: a177d3aabd94973437f3e4e15e16ee48d3a460031b73329d732ad30e9736a2b4
4
- data.tar.gz: 5cce90e07b02cfbb416cf710c2d7d345424c754c019d5d3f50bb4315cc0abf9a
3
+ metadata.gz: d9c761acea6fa4c7a6cef0c0b56716906368032d14e891fbcad192487a3d46f4
4
+ data.tar.gz: b16661800fd19357336f645832fe0a053105febdc2e58a4556d66c2c084742a8
5
5
  SHA512:
6
- metadata.gz: 88a46f8426347ccc3b771694eeb489f0591f8a9023dcc08860f83683ad369eb8e636bab3324389ec888e8e2aca990fdee2185bb3e1ad5d99f738bf40600246c9
7
- data.tar.gz: a3e0a5e6079e24fbe3773b88b4fc455e1f8a9d6db142689871dafe70277b1df92f1736a68e43203cb78abe399e4cc5284a7ade46bccfa8a95058310b5d63573a
6
+ metadata.gz: 2931d29722ac006672127d5c675ae3522c84b118075f244ec96c3b0d1534d2170595bfbcc4e0f616de9162f46f085f2e02bce50426ba55e331f3380ef20961d7
7
+ data.tar.gz: 40ca60459ecc7cf9569d49a8c57a3866176b867f7dbd620941e2b975f48e9071c53cea0a6e28dab1f8fe245ca048e4108351bf16ca2b05494952c202581d36ac
@@ -1,6 +1,45 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.7.3] - 2020-10-xx
5
+
6
+ ### Added
7
+ - `Ecoportal::API::Common::Content::CollectionModel#delete!` finally scoped how delete should work :)
8
+ - `Ecoportal::API::V2.new` better feedback on key error.
9
+ - `Ecoportal::API::V2::Page::Component::SignatureField` added property `signed_by_name`
10
+ - `Ecoportal::API::V2::Page::Component#required` this field property is currently supported
11
+ - `Ecoportal::API::V2::Page::Component::DateField` more supported properties:
12
+ * `show_time`, `today_button`, `past_only`, `create_event`, `remind_me_in`, `renews`, `renews_every`, `renews_unit`, `renews_until`
13
+ - `Ecoportal::API::V2::Page::Component::ChecklistField`
14
+ * added more methods: `add_item`, `ordered_items`
15
+ - `Ecoportal::API::V2::Page::Component::GaugeField`
16
+ * more supported properties: `max`, `active_color` and `stops`
17
+ - for `stops` added class `Ecoportal::API::V2::Page::Component::GaugeStop`
18
+ * added more methods: `add_stop`, `ordered_stops`
19
+ - `Ecoportal::API::V2::Page::Component::ReferenceField` more supported properties:
20
+ * `register_id`, `hide_create`, `hide_attach`, `hide_metadata`, `hide_dashboards`, `display_fields`, `display_fields_in_lookup`
21
+ - `Ecoportal::API::V2::Page::Component::ActionField`
22
+ * more supported properties:`create_actions`, `required_number_of_completed_actions`, `permits_and_rules_integration`, `add_subscribed`, `add_subscribed_to_tasks`
23
+ * added more methods: `add_task`, `ordered_tasks`
24
+ - `Ecoportal::API::V2::Page::Component::Action` modified, provided that some properties are `read_only`
25
+ - `Ecoportal::API::V2::Page::Component::PeopleField` more supported properties:
26
+ * `is_me_button`, `attach_mode`, `person_schema_id`, `viewable_fields`, `singular`, `requires_number`, `cached_people`, `attached_people_permissions_enabled`, `apply_attached_people_permissions_to`, `attached_people_permissions_editable`, `attached_people_permissions_flags`
27
+ - `Ecoportal::API::V2::Page::Component::PlainTextField` more supported properties:
28
+ * `multiline`, `max_length`, `exact_index`
29
+ - `Ecoportal::API::V2::Page::Component::SelectionField` more supported properties:
30
+ * `flat`
31
+ - `Ecoportal::API::V2::Page::Component::TagField` more supported properties:
32
+ * `single_select`, `use_defaults`, `tag_tree_id`, `button_text`
33
+ - `Ecoportal::API::V2::Page::Section` more supported properties:
34
+ * `minimized`
35
+
36
+
37
+ ### Changed
38
+ - upgraded `ecoportal-api` dependency
39
+
40
+ ### Fixed
41
+ - `Ecoportal::API::Common::Content::CollectionModel#upsert!` was not actually moving the element to the new position when it already existed
42
+
4
43
  ## [0.7.2] - 2020-10-07
5
44
 
6
45
  ### Added
@@ -27,5 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "redcarpet", ">= 3.5.0", "< 3.6"
28
28
  spec.add_development_dependency "pry"
29
29
 
30
- spec.add_dependency 'ecoportal-api', '>= 0.7.1', '< 0.8'
30
+ spec.add_dependency 'ecoportal-api', '>= 0.7.4', '< 0.8'
31
31
  end
@@ -134,6 +134,7 @@ module Ecoportal
134
134
  end
135
135
  end
136
136
 
137
+ # Get an element usign the `key`.
137
138
  def [](value)
138
139
  items_by_key[get_key(value)]
139
140
  end
@@ -161,6 +162,15 @@ module Ecoportal
161
162
  end
162
163
  end
163
164
 
165
+ def delete!(value)
166
+ unless value.is_a?(Hash) || value.is_a?(Content::DoubleModel)
167
+ raise "'Content::DoubleModel' or 'Hash' doc required"
168
+ end
169
+ if item = self[value]
170
+ _doc_delete(item.doc)
171
+ end
172
+ end
173
+
164
174
  protected
165
175
 
166
176
  def order_matters?; self.class.order_matters; end
@@ -220,6 +230,13 @@ module Ecoportal
220
230
  super
221
231
  end
222
232
 
233
+ def _doc_delete(value)
234
+ if current_pos = _doc_key(value)
235
+ _doc_items.delete_at(current_pos)
236
+ on_change
237
+ end
238
+ end
239
+
223
240
  def _doc_upsert(value, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
224
241
  current_pos = _doc_key(value)
225
242
  pos = case
@@ -228,7 +245,7 @@ module Ecoportal
228
245
  when used_param?(before)
229
246
  _doc_key(before)
230
247
  when used_param?(after)
231
- puts "to add after #{after.id}"
248
+ #puts "to add after #{after.id}"
232
249
  if i = _doc_key(after)
233
250
  i + 1
234
251
  end
@@ -237,10 +254,10 @@ module Ecoportal
237
254
  pos ||= current_pos
238
255
 
239
256
  if current_pos && pos
240
- _doc_items.delete(current_pos)
257
+ _doc_items.delete_at(current_pos)
241
258
  pos = (pos <= current_pos)? pos : pos - 1
242
259
  end
243
-
260
+
244
261
  pos = (pos && pos < _doc_items.length)? pos : _doc_items.length
245
262
 
246
263
  pos.tap do |i|
@@ -33,7 +33,7 @@ module Ecoportal
33
33
  # @param host [String] api server domain.
34
34
  # @param logger [Logger] an object with `Logger` interface to generate logs.
35
35
  def initialize(api_key = nil, user_key: nil, org_key: nil, host: "live.ecoportal.com", logger: default_logger)
36
- v2key = (user_key && org_key && self.class.v2key(user_key, org_key)) || api_key #|| ENV['X_ECOPORTAL_API_KEY']
36
+ v2key = get_key(api_key: api_key, user_key: user_key, org_key: org_key)
37
37
  @logger = logger
38
38
  @client = Common::Content::Client.new(
39
39
  api_key: v2key,
@@ -55,6 +55,15 @@ module Ecoportal
55
55
  pages_class.new(client)
56
56
  end
57
57
 
58
+ private
59
+
60
+ def get_key(api_key: nil, user_key: nil, org_key: nil)
61
+ return self.class.v2key(user_key, org_key) if user_key && org_key
62
+ return api_key if api_key #|| ENV['X_ECOPORTAL_API_KEY']
63
+ raise "You need to provide either an api_key or user_key" unless user_key
64
+ raise "You need to provide an org_key as well (not just a user_key)" unless org_key
65
+ end
66
+
58
67
  end
59
68
  end
60
69
  end
@@ -53,7 +53,8 @@ module Ecoportal
53
53
  people_field_class
54
54
  when "checklist"
55
55
  checklist_field_class
56
- when "page_action"
56
+ when "page_action","checklist_task"
57
+ #doc["type"] = "checklist_task"
57
58
  action_field_class
58
59
  when "file"
59
60
  files_field_class
@@ -75,7 +76,7 @@ module Ecoportal
75
76
  passkey :id
76
77
  passthrough :patch_ver, :undeletable
77
78
  passthrough :type, :label, :tooltip, :global_binding
78
- passthrough :hidden, :accent, :deindex
79
+ passthrough :hidden, :accent, :deindex, :required
79
80
  passthrough :hide_view, :hidden_on_reports, :hidden_on_mobile
80
81
 
81
82
  def ref
@@ -4,11 +4,22 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class Action < Common::Content::DoubleModel
7
+ class << self
8
+ def new_doc
9
+ {
10
+ "id" => new_uuid,
11
+ "weight" => 9999
12
+ }
13
+ end
14
+ end
15
+
7
16
  passkey :id
8
17
  passthrough :patch_ver, :name
9
- passthrough :weight, :complete, :overdue, :other_information
10
- passdate :due_date, :created_at #, :completed_at
11
- passthrough :created_by, :assigned_person_member_id
18
+ passthrough :weight, :complete, :other_information
19
+ passdate :due_date
20
+ pass_reader :overdue
21
+ passdate :created_at, read_only: true #, :completed_at
22
+ pass_reader :created_by, :assigned_person_member_id
12
23
  end
13
24
  end
14
25
  end
@@ -4,8 +4,46 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ActionField < Page::Component
7
- #class_resolver :action_class, "Ecoportal::API::V2::Page::Component::Action"
7
+ passthrough :create_actions
8
+ passthrough :required_number_of_completed_actions
9
+ passthrough :permits_and_rules_integration, :add_subscribed, :add_subscribed_to_tasks
10
+
8
11
  embeds_multiple :actions, klass: "Ecoportal::API::V2::Page::Component::Action", order_key: :weight
12
+
13
+ # Adds a task with `name` short description
14
+ # @return [Ecoportal::API::V2::Page::Component::Action]
15
+ def add_task (name)
16
+ task_doc = Ecoportal::API::V2::Page::Component::Action.new_doc
17
+ actions.upsert!(task_doc) do |task|
18
+ task.name = name
19
+ if prev = previous_task(task)
20
+ task.weight = prev.weight
21
+ end
22
+ yield(task) if block_given?
23
+ fix_task_weights!
24
+ end
25
+ end
26
+
27
+ def ordered_tasks
28
+ actions.each_with_index.sort_by do |task, index|
29
+ (task.weight >= 9999) ? [index, index] : [task.weight, index]
30
+ end.map(&:first)
31
+ end
32
+
33
+ private
34
+
35
+ def fix_task_weights!
36
+ ordered_tasks.each_with_index do |task, index|
37
+ task.weight = index
38
+ end
39
+ end
40
+
41
+ def previous_task(value)
42
+ tasks = ordered_tasks
43
+ pos = tasks.index(value) - 1
44
+ return if pos < 0
45
+ tasks[pos]
46
+ end
9
47
  end
10
48
  end
11
49
  end
@@ -4,8 +4,41 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ChecklistField < Page::Component
7
- #class_resolver :checklist_item_class, "Ecoportal::API::V2::Page::Component::ChecklistItem"
8
7
  embeds_multiple :items, klass: "Ecoportal::API::V2::Page::Component::ChecklistItem", order_key: :weight
8
+
9
+ def add_item(label:, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
10
+ itm_doc = Ecoportal::API::V2::Page::Component::ChecklistItem.new_doc
11
+ items.upsert!(itm_doc, pos: pos, before: before, after: after) do |item|
12
+ item.label = label
13
+ if prev = previous_item(item)
14
+ item.weight = prev.weight
15
+ end
16
+ yield(item) if block_given?
17
+ fix_item_weights!
18
+ end
19
+ end
20
+
21
+ def ordered_items
22
+ items.each_with_index.sort_by do |item, index|
23
+ (item.weight >= 9999) ? [index, index] : [item.weight, index]
24
+ end.map(&:first)
25
+ end
26
+
27
+ private
28
+
29
+ def fix_item_weights!
30
+ ordered_items.each_with_index do |item, index|
31
+ item.weight = index
32
+ end
33
+ end
34
+
35
+ def previous_item(value)
36
+ itms = ordered_items
37
+ pos = itms.index(value) - 1
38
+ return if pos < 0
39
+ itms[pos]
40
+ end
41
+
9
42
  end
10
43
  end
11
44
  end
@@ -4,6 +4,16 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ChecklistItem < Common::Content::DoubleModel
7
+
8
+ class << self
9
+ def new_doc
10
+ {
11
+ "id" => new_uuid,
12
+ "weight" => 9999
13
+ }
14
+ end
15
+ end
16
+
7
17
  passkey :id
8
18
  passthrough :patch_ver, :label
9
19
  passthrough :weight, :checked
@@ -5,6 +5,9 @@ module Ecoportal
5
5
  class Component
6
6
  class DateField < Page::Component
7
7
  passthrough :value
8
+ passthrough :show_time, :today_button, :past_only
9
+ passthrough :create_event, :remind_me_in
10
+ passthrough :renews, :renews_every, :renews_unit, :renews_until
8
11
  end
9
12
  end
10
13
  end
@@ -4,10 +4,33 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class GaugeField < Page::Component
7
- passthrough :value
7
+ passthrough :value, :max
8
+ passthrough :active_color
9
+
10
+ embeds_multiple :stops, klass: "Ecoportal::API::V2::Page::Component::GaugeStop", order_key: :threshold
11
+
12
+ # Adds a stop at `threshold` with `color`
13
+ # @return [Ecoportal::API::V2::Page::Component::GaugeStop]
14
+ def add_stop (threshold: 0.0, color: '#e256d1')
15
+ stop_doc = Ecoportal::API::V2::Page::Component::GaugeStop.new_doc
16
+ stops.upsert!(stop_doc) do |stop|
17
+ stop.threshold = threshold
18
+ stop.color = color
19
+ yield(stop) if block_given?
20
+ end
21
+ end
22
+
23
+ def ordered_stops
24
+ stops.each_with_index.sort_by do |stop, index|
25
+ (stop.threshold >= 9999) ? [index, index] : [stop.threshold, index]
26
+ end.map(&:first)
27
+ end
28
+
8
29
  end
9
30
  end
10
31
  end
11
32
  end
12
33
  end
13
34
  end
35
+
36
+ require 'ecoportal/api/v2/page/component/gauge_stop'
@@ -0,0 +1,26 @@
1
+ module Ecoportal
2
+ module API
3
+ class V2
4
+ class Page
5
+ class Component
6
+ class GaugeStop < Common::Content::DoubleModel
7
+
8
+ class << self
9
+ def new_doc
10
+ {
11
+ "id" => new_uuid,
12
+ "threshold" => nil,
13
+ "color" => nil
14
+ }
15
+ end
16
+ end
17
+
18
+ passkey :id
19
+ passthrough :patch_ver, :threshold
20
+ passthrough :color
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -4,7 +4,14 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class PeopleField < Page::Component
7
- passarray :people_ids
7
+ passthrough :is_me_button, :attach_mode
8
+ passthrough :person_schema_id
9
+ pass_reader :viewable_fields
10
+ passthrough :singular, :requires_number
11
+ passarray :people_ids
12
+ pass_reader :cached_people
13
+ passthrough :attached_people_permissions_enabled, :apply_attached_people_permissions_to
14
+ passthrough :attached_people_permissions_editable, :attached_people_permissions_flags
8
15
 
9
16
  def add(id)
10
17
  people_ids << id
@@ -5,6 +5,8 @@ module Ecoportal
5
5
  class Component
6
6
  class PlainTextField < Page::Component
7
7
  passthrough :value
8
+ passthrough :multiline, :max_length
9
+ pass_reader :exact_index
8
10
  end
9
11
  end
10
12
  end
@@ -4,6 +4,10 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class ReferenceField < Page::Component
7
+ passthrough :register_id
8
+ passthrough :hide_create, :hide_attach
9
+ passthrough :hide_metadata, :hide_dashboards
10
+ passthrough :display_fields, :display_fields_in_lookup
7
11
  end
8
12
  end
9
13
  end
@@ -4,7 +4,8 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class SelectionField < Page::Component
7
- passthrough :multiple, :other, :other_desc
7
+ passthrough :multiple, :flat
8
+ passthrough :other, :other_desc
8
9
 
9
10
  #class_resolver :selection_option_class, "Ecoportal::API::V2::Page::Component::SelectionOption"
10
11
  embeds_multiple :options, klass: "Ecoportal::API::V2::Page::Component::SelectionOption", order_key: :weight
@@ -33,7 +34,6 @@ module Ecoportal
33
34
  end
34
35
  end
35
36
 
36
- # a server bug prevents to add new options to an existing field
37
37
  def add_option(name:, value:, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
38
38
  opt_doc = Ecoportal::API::V2::Page::Component::SelectionOption.new_doc
39
39
  options.upsert!(opt_doc, pos: pos, before: before, after: after) do |option|
@@ -4,6 +4,7 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class SelectionOption < Common::Content::DoubleModel
7
+
7
8
  class << self
8
9
  def new_doc
9
10
  {
@@ -4,7 +4,7 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class SignatureField < Page::Component
7
- passthrough :signed_by_id, :signature_url
7
+ passthrough :signed_by_id, :signed_by_name, :signature_url
8
8
  passdate :signature_updated_at
9
9
  end
10
10
  end
@@ -4,6 +4,8 @@ module Ecoportal
4
4
  class Page
5
5
  class Component
6
6
  class TagField < Page::Component
7
+ passthrough :single_select, :use_defaults
8
+ passthrough :tag_tree_id, :button_text
7
9
  end
8
10
  end
9
11
  end
@@ -29,6 +29,7 @@ module Ecoportal
29
29
  passthrough :patch_ver, :weight, :type
30
30
  passthrough :heading, :left_heading, :right_heading
31
31
  passarray :component_ids, :left_component_ids, :right_component_ids
32
+ passthrough :minimized
32
33
 
33
34
  def split?
34
35
  doc && doc["type"] == "split"
@@ -1,7 +1,7 @@
1
1
  module Ecoportal
2
2
  module API
3
3
  class V2
4
- GEM_VERSION = "0.7.2"
4
+ GEM_VERSION = "0.7.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-oozes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-07 00:00:00.000000000 Z
11
+ date: 2021-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 0.7.1
133
+ version: 0.7.4
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0.8'
@@ -140,7 +140,7 @@ dependencies:
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: 0.7.1
143
+ version: 0.7.4
144
144
  - - "<"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0.8'
@@ -189,6 +189,7 @@ files:
189
189
  - lib/ecoportal/api/v2/page/component/file.rb
190
190
  - lib/ecoportal/api/v2/page/component/files_field.rb
191
191
  - lib/ecoportal/api/v2/page/component/gauge_field.rb
192
+ - lib/ecoportal/api/v2/page/component/gauge_stop.rb
192
193
  - lib/ecoportal/api/v2/page/component/geo_field.rb
193
194
  - lib/ecoportal/api/v2/page/component/image.rb
194
195
  - lib/ecoportal/api/v2/page/component/images_field.rb