ecoportal-api-v2 0.8.18 → 0.8.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -1
  3. data/ecoportal-api-v2.gemspec +1 -1
  4. data/lib/ecoportal/api/common/content/array_model.rb +4 -0
  5. data/lib/ecoportal/api/v2/page/component/action.rb +13 -0
  6. data/lib/ecoportal/api/v2/page/component/action_field.rb +4 -0
  7. data/lib/ecoportal/api/v2/page/component/checklist_field.rb +4 -0
  8. data/lib/ecoportal/api/v2/page/component/checklist_item.rb +4 -0
  9. data/lib/ecoportal/api/v2/page/component/date_field.rb +4 -0
  10. data/lib/ecoportal/api/v2/page/component/file.rb +4 -0
  11. data/lib/ecoportal/api/v2/page/component/files_field.rb +4 -0
  12. data/lib/ecoportal/api/v2/page/component/gauge_field.rb +3 -0
  13. data/lib/ecoportal/api/v2/page/component/geo_coordinates.rb +4 -0
  14. data/lib/ecoportal/api/v2/page/component/geo_field.rb +4 -0
  15. data/lib/ecoportal/api/v2/page/component/images_field.rb +5 -1
  16. data/lib/ecoportal/api/v2/page/component/people_field.rb +4 -0
  17. data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +4 -0
  18. data/lib/ecoportal/api/v2/page/component/reference_field.rb +11 -0
  19. data/lib/ecoportal/api/v2/page/component/rich_text_field.rb +17 -0
  20. data/lib/ecoportal/api/v2/page/component/selection_field.rb +6 -0
  21. data/lib/ecoportal/api/v2/page/component/tag_field.rb +4 -0
  22. data/lib/ecoportal/api/v2/page/component.rb +1 -1
  23. data/lib/ecoportal/api/v2/page/section.rb +4 -5
  24. data/lib/ecoportal/api/v2/page/stage.rb +2 -2
  25. data/lib/ecoportal/api/v2/page/stages.rb +5 -5
  26. data/lib/ecoportal/api/v2/page.rb +14 -0
  27. data/lib/ecoportal/api/v2/pages/page_stage.rb +9 -23
  28. data/lib/ecoportal/api/v2_version.rb +1 -1
  29. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 752926633d87b225938d5dc32b89e1250d2931a615875df1896052afbabd17de
4
- data.tar.gz: c3b5522c590eb27125783b31b20f8864d24aef43bd07d72f258ed02548d73581
3
+ metadata.gz: d6699a6cd1b82c54b0bf097dde24c034b4b114faa6cf23a7765429c384d45b3d
4
+ data.tar.gz: eef7fb625d8073d7de972f028fe9628886eb04e3b1eee6e9a8bf760170e64a1c
5
5
  SHA512:
6
- metadata.gz: 2a714d48b68220f8deefed8437772a61830146e6b68453a58f13817a50b1cc746ce7098a131b7919d161b46b850c73a35abb1bc8d414bc0f3c59579c7f25be0a
7
- data.tar.gz: c919b046a896afb11f8540288d374e8f1c0e5b5d9970793caaaa3814b9b12a9cb3587abf9e0e81f7230d97a72ed34d71f22e319086c637b8bcc02cc338eb3d9c
6
+ metadata.gz: b6eb538df89c4d99b7715d23c75c3eea53a4ffbb3063c612a797a7aebe58f4e427393c410a10e7b67b3744f4986d550c24659ad4d17b9dd870d742f924c0d7c7
7
+ data.tar.gz: 3da71eae2f509fa6a7afaf7b6744e18210741efddffa5f7d06858de091922f1dccbc64017be8dbc9b13bc8f6aaaaea4abb0b94b433f8a7bb178f07407268dd57
data/CHANGELOG.md CHANGED
@@ -1,11 +1,55 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.8.18] - 2021-09-xx
4
+ ## [0.8.22] - 2021-12-23
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
+ - `Ecoportal::API::V2::Page::Section#add_component` was not using correctly `before` and `after`
10
+ - It was not correctly translating them into the existing component
11
+
12
+ ## [0.8.21] - 2021-12-15
13
+
14
+ ### Added
15
+ - To children of `Ecoportal::API::V2::Page::Component` added method `#to_s` (for exporting)
16
+ - `Ecoportal::API::V2::Page::Component::ReferenceField`
17
+ - added `#references` (the lookup results)
18
+ - added `#reference_ids` (the `ids` of the referenced oozes)
19
+
20
+ ### Changed
21
+ - Re-exposed `Ecoportal::API::V2::Stages#ordered`
22
+
23
+ ### Fixed
24
+ - `Ecoportal::API::V2::Page::Component::ImagesField#images` typo in `klass`
25
+
26
+ ## [0.8.20] - 2021-12-09
27
+
28
+ ### Changed
29
+ - `Ecoportal::API::V2::Pages::PageStage#permits` removed
30
+ - The reason is that it should be changed using the `Stage#permits` instead
31
+ - Upgraded `ecoportal-api` gem dependency
32
+
33
+ ### Fixed
34
+ - `Ecoportal::API::V2::Page::Stage#sections` typo
35
+
36
+ ## [0.8.19] - 2021-09-29
37
+
38
+ ### Changed
39
+ - Moved validation of components multi-section from `PageStage` to `Page`
40
+ - Removed validation from `PageStage#as_update`
41
+ - This means that the validation will not run natively, but in the client lib
42
+
43
+ ### Fixed
44
+ - `Ecoportal::V2::Page::Stage#section?` fixed typo
45
+ - `Ecoportal::V2::Page::Stage`
46
+ - `#attached?` added missing code
47
+ - `#component?` fixed typo
48
+
49
+ ## [0.8.18] - 2021-09-29
50
+
51
+ ### Fixed
52
+ - typo in `PageStage#validate`
9
53
 
10
54
  ## [0.8.17] - 2021-09-29
11
55
 
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
30
30
  spec.add_development_dependency "pry" , ">= 0.14"
31
31
 
32
- spec.add_dependency 'ecoportal-api', '>= 0.8.3', '< 0.9'
32
+ spec.add_dependency 'ecoportal-api', '>= 0.8.4', '< 0.9'
33
33
  end
@@ -55,6 +55,10 @@ module Ecoportal
55
55
  doc.tap {|d| d.uniq! if uniq?}
56
56
  end
57
57
 
58
+ def to_s(delimiter: "|")
59
+ map(&:to_s).join(delimiter)
60
+ end
61
+
58
62
  # @see #_items
59
63
  # @return [Array] a **copy** of the `Array` elements
60
64
  def to_a
@@ -29,6 +29,19 @@ module Ecoportal
29
29
  passthrough :duration_in_days, read_only: true
30
30
  passarray :file_container_ids
31
31
 
32
+ def to_s
33
+ stat = case
34
+ when overdue
35
+ "Overdue"
36
+ when complete
37
+ "Complete"
38
+ else
39
+ "Pending"
40
+ end
41
+ assignee = assigned_person_member["name"] || assigned_person_member["email"]
42
+ "#{name}, #{created_at.to_s}, #{stat}, #{assignee}"
43
+ end
44
+
32
45
  end
33
46
  end
34
47
  end
@@ -30,6 +30,10 @@ module Ecoportal
30
30
  end
31
31
  end
32
32
 
33
+ def to_s(delimiter: "\n")
34
+ ordered_tasks.map(&:to_s).join(delimiter)
35
+ end
36
+
33
37
  # Quick config helper
34
38
  # @param conf [Symbol, Array<Symbol>]
35
39
  # - `:requires` required number of completed actions
@@ -24,6 +24,10 @@ module Ecoportal
24
24
  end
25
25
  end
26
26
 
27
+ def to_s(delimiter: "\n")
28
+ ordered_items.map(&:to_s).compact.join(delimiter)
29
+ end
30
+
27
31
  private
28
32
 
29
33
  def fix_item_weights!
@@ -19,6 +19,10 @@ module Ecoportal
19
19
  passthrough :label
20
20
  passthrough :weight
21
21
  passboolean :checked
22
+
23
+ def to_s
24
+ checked ? label : nil
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -34,6 +34,10 @@ module Ecoportal
34
34
  doc["create_event"] = !!value
35
35
  end
36
36
 
37
+ def to_s
38
+ value.to_s
39
+ end
40
+
37
41
  # Quick config helper
38
42
  # @param conf [Symbol, Array<Symbol>]
39
43
  # - `:time` to show time
@@ -19,6 +19,10 @@ module Ecoportal
19
19
  passthrough :file_size, :content_type, :token, read_only: true
20
20
  passthrough :file_container_id
21
21
  passdate :file_update_at, read_only: true
22
+
23
+ def to_s
24
+ file_container_id
25
+ end
22
26
  end
23
27
  end
24
28
  end
@@ -24,6 +24,10 @@ module Ecoportal
24
24
  end
25
25
  end
26
26
 
27
+ def to_s(delimiter: "\n")
28
+ ordered_files.map(&:to_s).join(delimiter)
29
+ end
30
+
27
31
  private
28
32
 
29
33
  def fix_file_positions!
@@ -26,6 +26,9 @@ module Ecoportal
26
26
  end
27
27
  end
28
28
 
29
+ def to_s
30
+ value.to_s
31
+ end
29
32
  end
30
33
  end
31
34
  end
@@ -5,6 +5,10 @@ module Ecoportal
5
5
  class Component
6
6
  class GeoCoordinates < Common::Content::DoubleModel
7
7
  passthrough :lat, :lon
8
+
9
+ def to_s
10
+ "#{lat},#{lon}" if lat & lon
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -6,6 +6,10 @@ module Ecoportal
6
6
  class GeoField < Page::Component
7
7
  passthrough :address
8
8
  embeds_one :coordinates, klass: "Ecoportal::API::V2::Page::Component::GeoCoordinates"
9
+
10
+ def to_s
11
+ coordinates.to_s
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -15,7 +15,11 @@ module Ecoportal
15
15
 
16
16
  passthrough :layout
17
17
  passboolean :strech, :no_popup, :hide_options
18
- embeds_many :images, klass: "Ecoportal::API::V2::Page::Image", order_key: :weight
18
+ embeds_many :images, klass: "Ecoportal::API::V2::Page::Component::Image", order_key: :weight
19
+
20
+ def to_s
21
+ images.count
22
+ end
19
23
 
20
24
  # Quick config helper
21
25
  # @param conf [Symbol, Array<Symbol>]
@@ -40,6 +40,10 @@ module Ecoportal
40
40
  viewable_fields.delete!(field_id)
41
41
  end
42
42
 
43
+ def to_s(delimiter: "\n")
44
+ people_ids.join(delimiter)
45
+ end
46
+
43
47
  # Quick config helper
44
48
  # @param conf [Symbol, Array<Symbol>]
45
49
  # - `:snapshot` to set mode to `snapshot`
@@ -9,6 +9,10 @@ module Ecoportal
9
9
  passthrough :max_length
10
10
  passboolean :exact_index
11
11
 
12
+ def to_s
13
+ value
14
+ end
15
+
12
16
  # Quick config helper
13
17
  # @param conf [Symbol, Array<Symbol>]
14
18
  # - `:multiline` multi line mode
@@ -5,10 +5,21 @@ module Ecoportal
5
5
  class Component
6
6
  class ReferenceField < Page::Component
7
7
  passthrough :register_id
8
+ passarray :references
8
9
  passboolean :hide_create, :hide_attach
9
10
  passboolean :hide_metadata, :hide_dashboards
10
11
  passboolean :display_fields, :display_fields_in_lookup
11
12
 
13
+ def reference_ids
14
+ references.map do |ref|
15
+ ref["id"]
16
+ end
17
+ end
18
+
19
+ def to_s(delimiter: "\n")
20
+ reference_ids.to_a.join(delimiter)
21
+ end
22
+
12
23
  # Quick config helper
13
24
  # @param conf [Symbol, Array<Symbol>]
14
25
  # - `:show_fields` specify if the public register fields should be shown (requires `register_id`)
@@ -5,6 +5,23 @@ module Ecoportal
5
5
  class Component
6
6
  class RichTextField < Page::Component
7
7
  passthrough :content
8
+
9
+ HTML_TAGS_REX = /<("[^"]*"|'[^']*'|[^'">])*>/
10
+
11
+ def to_s
12
+ remove_html_tags(content)
13
+ end
14
+
15
+ private
16
+
17
+ def remove_html_tags(str)
18
+ str = str.gsub(HTML_TAGS_REX, ' ') if str
19
+ str = str.gsub(/[^[:print:]]/, '') if str
20
+ str = str.gsub(":&nbsp;", ' ') if str
21
+ str = str.gsub("&#34;", '"') if str
22
+ str = str.gsub("&amp;", '&') if str
23
+ str
24
+ end
8
25
  end
9
26
  end
10
27
  end
@@ -63,6 +63,12 @@ module Ecoportal
63
63
  end
64
64
  end
65
65
 
66
+ def to_s(name: true, delimiter: "\n")
67
+ [selected].flatten.compact.map do |opt|
68
+ name ? opt.name : opt.value
69
+ end.join(delimiter)
70
+ end
71
+
66
72
  # Quick config helper
67
73
  # @param conf [Symbol, Array<Symbol>]
68
74
  # - `:flat` to display in flat mode
@@ -7,6 +7,10 @@ module Ecoportal
7
7
  passboolean :single_select, :use_defaults
8
8
  passthrough :tag_tree_id, :button_text
9
9
 
10
+ def to_s(delimiter: "\n")
11
+ root.tags.to_s(delimiter: delimiter)
12
+ end
13
+
10
14
  # Quick config helper
11
15
  # @param conf [Symbol, Array<Symbol>]
12
16
  # - `:multiple` to allow multiple selection
@@ -110,7 +110,7 @@ module Ecoportal
110
110
  # Looks up the section that this component belongs to.
111
111
  # @return [Ecoportal::API::V2::Page::Section, nil] the section where this field is attached to.
112
112
  def section
113
- root.sections.find {|sec| sec.component?(id)}
113
+ ooze.sections.find {|sec| sec.component?(id)}
114
114
  end
115
115
 
116
116
  # @return [Boolean] whether or not this field is attached to any section.
@@ -45,7 +45,7 @@ module Ecoportal
45
45
 
46
46
  # @return [Boolean] whether or not the section appears in an ooze instance
47
47
  def attached?
48
- !ooze.stages? || stages.any?
48
+ !ooze.stages? || stages.any? {|stg| stg.section?(self)}
49
49
  end
50
50
 
51
51
  # @return [Boolean] whether or not this section is a split section
@@ -67,7 +67,7 @@ module Ecoportal
67
67
  when Ecoportal::API::V2::Page::Component
68
68
  component?(com_or_id.id)
69
69
  when String
70
- all_component_ids.include?(id)
70
+ all_component_ids.include?(com_or_id)
71
71
  else
72
72
  msg = "Missuse: com_or_id should be a Component or a String. Given: #{com_or_id.class}"
73
73
  raise ArgumentError.new(msg)
@@ -137,7 +137,7 @@ module Ecoportal
137
137
  if before
138
138
  before_fld = to_component(before, side: side)
139
139
  elsif after
140
- after_fld = to_component(afterm, side: side)
140
+ after_fld = to_component(after, side: side)
141
141
  end
142
142
 
143
143
  if split?
@@ -145,7 +145,6 @@ module Ecoportal
145
145
  else
146
146
  ids_ary = component_ids
147
147
  end
148
-
149
148
  ids_ary.insert_one(field.id, before: before_fld&.id, after: after_fld&.id)
150
149
  self
151
150
  end
@@ -168,7 +167,7 @@ module Ecoportal
168
167
 
169
168
  fields.find do |fld|
170
169
  found = nil
171
- found ||= !!value if value.is_a?(Ecoportal::API::V2::Page::Component)
170
+ found ||= fld.id == value.id if value.is_a?(Ecoportal::API::V2::Page::Component)
172
171
  found ||= fld.id == value
173
172
  found ||= same_string?(fld.label, value)
174
173
  end
@@ -28,7 +28,7 @@ module Ecoportal
28
28
  sec_ids = section_ids.to_a
29
29
  root.sections.values_at(*sec_ids).select.with_index do |sec, i|
30
30
  puts "Warning: section #{id} points to missing section #{sec_ids[i]}" if !sec
31
- fld && (!block_given? || yield(sec))
31
+ sec && (!block_given? || yield(sec))
32
32
  end.sort_by.with_index {|sec, index| [sec.weight, index]}
33
33
  end
34
34
 
@@ -41,7 +41,7 @@ module Ecoportal
41
41
  when Ecoportal::API::V2::Page::Section
42
42
  section?(sec_or_id.id)
43
43
  when String
44
- self.section_ids.include?(id)
44
+ self.section_ids.include?(sec_or_id)
45
45
  else
46
46
  raise ArgumentError.new("sec_or_id must be either a Section or a String. Given: #{sec_or_id.class}")
47
47
  end
@@ -19,11 +19,11 @@ module Ecoportal
19
19
  end
20
20
  end
21
21
 
22
- #def ordered
23
- # self.sort_by.with_index do |stage, index|
24
- # [stage.ordering, index]
25
- # end
26
- #end
22
+ def ordered
23
+ self.sort_by.with_index do |stage, index|
24
+ [stage.ordering, index]
25
+ end
26
+ end
27
27
 
28
28
  end
29
29
  end
@@ -54,6 +54,20 @@ module Ecoportal
54
54
  self.stages.count > 0
55
55
  end
56
56
 
57
+ # @return [String] with feedback, if for this page instance, there are any of:
58
+ # 1. components multi-section (fields belonging to more than one section)
59
+ def validate
60
+ msg = ""
61
+ if (multi = components.multi_section).length > 0
62
+ msg += "There are fields attached to more than one section:\n • "
63
+ msg += multi.map do |fld|
64
+ fld.label
65
+ end.join("\n • ") + "\n"
66
+ end
67
+
68
+ msg.empty?? true : msg
69
+ end
70
+
57
71
  private
58
72
 
59
73
  def _doc_bug_fix(hash)
@@ -7,7 +7,7 @@ module Ecoportal
7
7
  passthrough :task_priority, :state, :status
8
8
  passthrough :votes_enabled, :upvotes, :downvotes
9
9
 
10
- embeds_many :permits, klass: "Ecoportal::API::V2::Page::Permit"
10
+ #embeds_many :permits, klass: "Ecoportal::API::V2::Page::Permit"
11
11
  passarray :force_errors, :subtags, order_matters: false
12
12
 
13
13
  # @return [String] `id` of the stage we got the data of.
@@ -22,37 +22,23 @@ module Ecoportal
22
22
  end
23
23
  end
24
24
 
25
- # @raise [Exception] if for this page instance, there are any of:
25
+ # @return [String] with feedback, if for this page instance, there are any of:
26
26
  # 1. orphaned components (fields not belonging to any section)
27
- # 2. components multi-section (fields belonging to more than one section)
28
- # 3. orphaned sections (sections not belonging to any stage)
29
- def as_update(*args, **kargs)
30
- validate.tap do |validation|
31
- raise validation if validation.is_a?(String)
32
- end
33
- super(*args, **kargs)
34
- end
35
-
36
- private
37
-
27
+ # 2. orphaned sections (sections not belonging to any stage)
38
28
  def validate
39
- msg = ""
40
- if (orphans = components.unattached).length > 0
41
- msg += "There are fields not attached to any sections:"
42
- msg += orphans.map do |fld|
43
- fld.label
44
- end.join("\n • ") + "\n"
45
- end
29
+ msg = super
30
+ msg = "" unless msg.is_a?(String)
46
31
 
47
- if (multi = components.multi_section).length > 0
48
- msg += "There are fields attached to more than one section:"
32
+ orphans = components.unattached.select {|comp| comp.global_binding.to_s.strip.empty?}
33
+ if orphans.length > 0
34
+ msg += "There are fields not attached to any sections:\n • "
49
35
  msg += orphans.map do |fld|
50
36
  fld.label
51
37
  end.join("\n • ") + "\n"
52
38
  end
53
39
 
54
40
  if (orphans = sections.unattached).length > 0
55
- msg += "There are sections not attached to any stage:"
41
+ msg += "There are sections not attached to any stage:\n • "
56
42
  msg += orphans.map do |sec|
57
43
  "'#{sec.heading}' (#{sec.id})"
58
44
  end.join("\n • ") + "\n"
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GEM2_VERSION = "0.8.18"
3
+ GEM2_VERSION = "0.8.22"
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.18
4
+ version: 0.8.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-28 00:00:00.000000000 Z
11
+ date: 2021-12-23 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.8.3
133
+ version: 0.8.4
134
134
  - - "<"
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0.9'
@@ -140,7 +140,7 @@ dependencies:
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: 0.8.3
143
+ version: 0.8.4
144
144
  - - "<"
145
145
  - !ruby/object:Gem::Version
146
146
  version: '0.9'