ecoportal-api-v2 0.8.15 → 0.8.19

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: d4f6bfdd1ce54813ef02902b34773ec5225a51c8628e37637f7a7e2dad47dec0
4
- data.tar.gz: f271e97cf27b4217a129471f98b8e8a6f91e98238f2c8c3adcbecde2c3c08075
3
+ metadata.gz: 11e7f2b8bb7544cb9d99ad0660b3a52ec388725f2fe76018f3b0bc2f8e122c04
4
+ data.tar.gz: 31e3858fa5c4d3c632f5d3e04a51a3bc75b64cd719f646f22b5a6e24e42a1a95
5
5
  SHA512:
6
- metadata.gz: 7a3d8f76ee199d399b2b61c4b24790555bdbf17326f0a2179ab7a196daadbc5fdcb38bc6e695323bca30397c1b95f61335354bdcd8a44bb6f909ad65d06b0f93
7
- data.tar.gz: 68ec0d9b8f8958fc67e3b9e68e7ddcd78556d326c0be12415e086f2034011bbb293218cfa5dec10f2e1a2f9ef02988d23dc769137370d281672951daa0d99d77
6
+ metadata.gz: 4b4eda0998b1f122c2df6480ba283200bd9df1c985fa761f514231e6f6dddd89beff13d2c4bfa52e7e3d8ca39644efef57508caa369eca2b2b13478ac1faea5f
7
+ data.tar.gz: 31ab53da2363812cb340c41233eae35efe2c3e4024f77d670c6ffd2fb33f1697eabfacafc6bb85f895e4ef8faeed7b8d65858905fb967330bd181c4061198442
data/CHANGELOG.md CHANGED
@@ -1,12 +1,34 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [0.8.15] - 2021-09-xx
4
+ ## [0.8.19] - 2021-09-29
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
+ - Moved validation of components multi-section from `PageStage` to `Page`
9
+ - Removed validation from `PageStage#as_update`
10
+ - This means that the validation will not run natively, but in the client lib
11
+
8
12
  ### Fixed
13
+ - `Ecoportal::V2::Page::Stage#section?` fixed typo
14
+ - `Ecoportal::V2::Page::Stage`
15
+ - `#attached?` added missing code
16
+ - `#component?` fixed typo
17
+
18
+ ## [0.8.18] - 2021-09-29
19
+
20
+ ### Fixed
21
+ - typo in `PageStage#validate`
22
+
23
+ ## [0.8.17] - 2021-09-29
9
24
 
25
+ ### Fixed
26
+ - Typo in `Section#attached?`
27
+
28
+ ## [0.8.15] - 2021-09-29
29
+
30
+ ### Fixed
31
+ - Typo in `Section#component?`
10
32
 
11
33
  ## [0.8.14] - 2021-09-28
12
34
 
@@ -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.
@@ -40,12 +40,12 @@ module Ecoportal
40
40
 
41
41
  # @return [Array<Ecoportal::API::V2::Page::Stage>] the stage(s) this section belongs to.
42
42
  def stages
43
- ooze.stages.select {|stg| stg.has_section?(self)}
43
+ ooze.stages.select {|stg| stg.section?(self)}
44
44
  end
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)
@@ -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
@@ -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)
@@ -21,40 +21,26 @@ module Ecoportal
21
21
  stages[stage_id]
22
22
  end
23
23
  end
24
-
25
- # @raise [Exception] if for this page instance, there are any of:
24
+
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
- "'#{sec.header}' (#{sec.id})"
43
+ "'#{sec.heading}' (#{sec.id})"
58
44
  end.join("\n • ") + "\n"
59
45
  end
60
46
  msg.empty?? true : msg
@@ -1,5 +1,5 @@
1
1
  module Ecoportal
2
2
  module API
3
- GEM2_VERSION = "0.8.15"
3
+ GEM2_VERSION = "0.8.19"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecoportal-api-v2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.15
4
+ version: 0.8.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura