avo 3.6.3 → 3.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c1a1850dcbe5a9b1d2756241fe2983fb8d89a1dfecffb99bedefdb5d1cf93f9
4
- data.tar.gz: a246d51c7555b95a849077fb5a727751c0def5f08dd18b92ee559c591404177e
3
+ metadata.gz: 1686cd42a28d62d2877e3db2582df2ad34a6e30d27002151c1f3cc3b92490ac7
4
+ data.tar.gz: 319d4b0e6ad38d87e88379cef31c8ec650961643c5268d86b20e5579bb693b35
5
5
  SHA512:
6
- metadata.gz: 837aecd1b17eb2cd2b20448ee9826ea82ad72c6dbc754bf37dbf797f3f72be54c88b97b8efe70991ab00a6bc8a5e129caed5fff2fd97f8dfe22c4087380032d2
7
- data.tar.gz: caa6839f4f059e8e2ee596f1df9b8a02780c1b59dc5f540a2963305e6cfd00f811850157d550a200808b2b98680ff992b9144242db36c8860d0f0a3973597374
6
+ metadata.gz: 6bb3637bf610b0ee8b78642685661015e26371d44e9dd7c31bf3e0796b89c9698f4e026a37f0378c4457e933a381f63040e66cd3dc55f155e7ba74e746b7b743
7
+ data.tar.gz: '081b731423609d9f8f53dd1fa1866b37674aacf3374f7911d582b426a533ee1caf3d390563c7d2807db52a58db916c6ced8099ec1d703ffc2c13c1d31882b950'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.6.3)
4
+ avo (3.6.4)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -4,7 +4,9 @@ class Avo::Index::ResourceTableComponent < Avo::BaseComponent
4
4
  include Avo::ApplicationHelper
5
5
  attr_reader :pagy, :query
6
6
 
7
- def before_render = cache_table_rows
7
+ def before_render
8
+ @header_fields, @table_row_components = cache_table_rows
9
+ end
8
10
 
9
11
  def initialize(resources: nil, resource: nil, reflection: nil, parent_record: nil, parent_resource: nil, pagy: nil, query: nil, actions: nil)
10
12
  @resources = resources
@@ -45,33 +47,33 @@ class Avo::Index::ResourceTableComponent < Avo::BaseComponent
45
47
  def cache_table_rows
46
48
  # Cache the execution of the following block if caching is enabled in Avo configuration
47
49
  cache_if Avo.configuration.cache_resources_on_index_view, @resource.cache_hash(@parent_record), expires_in: 1.day do
48
- # Initialize arrays to hold header fields and table row components
49
- @header_fields = []
50
- @table_row_components = []
51
-
52
- generate_table_row_components
53
-
54
- # Remove duplicate header fields based on table_header_label
55
- @header_fields.uniq!(&:table_header_label)
50
+ header_fields, table_row_components = generate_table_row_components
56
51
 
57
52
  # Create an array of header field labels used for each row to render values on the right column
58
- @header_fields_ids = @header_fields.map(&:table_header_label)
53
+ header_fields_ids = header_fields.map(&:table_header_label)
59
54
 
60
55
  # Assign header field IDs to each TableRowComponent
61
56
  # We assign it here because only complete header fields array after last table row.
62
- @table_row_components.map { |table_row_component| table_row_component.header_fields = @header_fields_ids }
57
+ table_row_components.map { |table_row_component| table_row_component.header_fields = header_fields_ids }
58
+
59
+ # Return header fields and table row components
60
+ return [header_fields, table_row_components]
63
61
  end
64
62
  end
65
63
 
66
64
  def generate_table_row_components
65
+ # Initialize arrays to hold header fields and table row components
66
+ header_fields = []
67
+ table_row_components = []
68
+
67
69
  # Loop through each resource in @resources
68
70
  @resources.each do |resource|
69
71
  # Get fields for the current resource and concat them to the @header_fields
70
72
  row_fields = resource.get_fields(reflection: @reflection, only_root: true)
71
- @header_fields.concat row_fields
73
+ header_fields.concat row_fields
72
74
 
73
75
  # Create a TableRowComponent instance for the resource and add it to @table_row_components
74
- @table_row_components << Avo::Index::TableRowComponent.new(
76
+ table_row_components << Avo::Index::TableRowComponent.new(
75
77
  resource: resource,
76
78
  fields: row_fields,
77
79
  reflection: @reflection,
@@ -80,5 +82,10 @@ class Avo::Index::ResourceTableComponent < Avo::BaseComponent
80
82
  actions: @actions
81
83
  )
82
84
  end
85
+
86
+ # Remove duplicate header fields based on table_header_label
87
+ header_fields.uniq!(&:table_header_label)
88
+
89
+ [header_fields, table_row_components]
83
90
  end
84
91
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.6.3" unless const_defined?(:VERSION)
2
+ VERSION = "3.6.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.6.3
4
+ version: 3.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin