ecoportal-api-v2 0.8.18 → 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: 752926633d87b225938d5dc32b89e1250d2931a615875df1896052afbabd17de
4
- data.tar.gz: c3b5522c590eb27125783b31b20f8864d24aef43bd07d72f258ed02548d73581
3
+ metadata.gz: 11e7f2b8bb7544cb9d99ad0660b3a52ec388725f2fe76018f3b0bc2f8e122c04
4
+ data.tar.gz: 31e3858fa5c4d3c632f5d3e04a51a3bc75b64cd719f646f22b5a6e24e42a1a95
5
5
  SHA512:
6
- metadata.gz: 2a714d48b68220f8deefed8437772a61830146e6b68453a58f13817a50b1cc746ce7098a131b7919d161b46b850c73a35abb1bc8d414bc0f3c59579c7f25be0a
7
- data.tar.gz: c919b046a896afb11f8540288d374e8f1c0e5b5d9970793caaaa3814b9b12a9cb3587abf9e0e81f7230d97a72ed34d71f22e319086c637b8bcc02cc338eb3d9c
6
+ metadata.gz: 4b4eda0998b1f122c2df6480ba283200bd9df1c985fa761f514231e6f6dddd89beff13d2c4bfa52e7e3d8ca39644efef57508caa369eca2b2b13478ac1faea5f
7
+ data.tar.gz: 31ab53da2363812cb340c41233eae35efe2c3e4024f77d670c6ffd2fb33f1697eabfacafc6bb85f895e4ef8faeed7b8d65858905fb967330bd181c4061198442
data/CHANGELOG.md CHANGED
@@ -1,11 +1,24 @@
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.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
+
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
+
8
20
  ### Fixed
21
+ - typo in `PageStage#validate`
9
22
 
10
23
  ## [0.8.17] - 2021-09-29
11
24
 
@@ -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)
@@ -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,38 +21,24 @@ 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
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.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.18
4
+ version: 0.8.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura