avo 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

@@ -114,7 +114,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
114
114
  end
115
115
 
116
116
  def sidebars
117
- return if Avo.license.lacks_with_trial(:resource_sidebar)
117
+ return [] if Avo.license.lacks_with_trial(:resource_sidebar)
118
118
 
119
119
  @item.items.select do |item|
120
120
  item.is_sidebar?
@@ -87,19 +87,19 @@ module Avo
87
87
  unless only_root
88
88
  # Dive into panels to fetch their fields
89
89
  if item.is_panel?
90
- fields << extract_fields_from_items(item)
90
+ fields << extract_fields(item)
91
91
  end
92
92
 
93
93
  # Dive into tabs to fetch their fields
94
94
  if item.is_tab_group?
95
95
  item.items.map do |tab|
96
- fields << extract_fields_from_items(tab)
96
+ fields << extract_fields(tab)
97
97
  end
98
98
  end
99
99
 
100
100
  # Dive into sidebar to fetch their fields
101
101
  if item.is_sidebar?
102
- fields << extract_fields_from_items(item)
102
+ fields << extract_fields(item)
103
103
  end
104
104
  end
105
105
 
@@ -108,11 +108,11 @@ module Avo
108
108
  end
109
109
 
110
110
  if item.is_row?
111
- fields << extract_fields_from_items(tab)
111
+ fields << extract_fields(tab)
112
112
  end
113
113
 
114
114
  if item.is_main_panel?
115
- fields << extract_fields_from_items(item)
115
+ fields << extract_fields(item)
116
116
  end
117
117
  end
118
118
 
@@ -309,18 +309,24 @@ module Avo
309
309
  end
310
310
  end
311
311
 
312
- def extract_fields_from_items(thing)
313
- fields = []
314
-
315
- thing.items.each do |item|
312
+ # Extracts fields from a structure
313
+ # Structures can be panels, rows and sidebars
314
+ def extract_fields(structure)
315
+ structure.items.map do |item|
316
316
  if item.is_field?
317
- fields << item
318
- elsif item.is_panel? || item.is_row?
319
- fields << extract_fields_from_items(item)
317
+ item
318
+ elsif extractable_structure?(item)
319
+ extract_fields(item)
320
+ else
321
+ nil
320
322
  end
321
- end
323
+ end.compact
324
+ end
322
325
 
323
- fields
326
+ # Extractable structures are panels, rows and sidebars
327
+ # Sidebars are only extractable if they are not on the index view
328
+ def extractable_structure?(structure)
329
+ structure.is_panel? || structure.is_row? || (structure.is_sidebar? && !view.index?)
324
330
  end
325
331
 
326
332
  # Standalone items are fields that don't have their own panel
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.0.3" unless const_defined?(:VERSION)
2
+ VERSION = "3.0.4" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-11-22 00:00:00.000000000 Z
12
+ date: 2023-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord