avo 3.17.7 → 3.17.8

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: 5d37cac842e01c924da20b541aae0072dac630d725d61faa4760d3b90d077ae5
4
- data.tar.gz: 1838971f0c60d36aa7d47457f4e394c9106afdd5442a930c14a39e3425d908f1
3
+ metadata.gz: 9e776b4d3c05d50eb82a2f18d433fba1f0eb772708aa1454f5261acf02c40e90
4
+ data.tar.gz: 286dc3f948587185ea5120d4644d050142c7a3623e907329b8d7e1cec5df72dd
5
5
  SHA512:
6
- metadata.gz: d1a371f602937cb5b3146d13e12dcef3a3a0d4f84db2f5e7691c28c1b5f5c83573c385e1d2ce27e359c388dbaef077c0702cd96c6674752ff069b09e071c6f69
7
- data.tar.gz: 3cb0dc6ff3b544fa46a67cce144beadb2451b91acc9dfb936257b464b6bcf81dc2dabea079d4359c8db84725a8da18823957b2f32e5b179ffbfcca035fad5254
6
+ metadata.gz: 67ee9428d2759f669805fc3b3f4a5f5472f6f8ddbbc8a9e22982854f41dd78d4a5a5528d3f385fd9b1a23195fae936bd96af883b12039cff68e6ab309ef6760d
7
+ data.tar.gz: 96cb89c794b12fd7a327f79ffd13a7ab7bab2a92d75d934324a4022fb772d160049ccaa9ed56ddcf6b29f69a43a85c401e8682d255cc0a73418be9361e09766e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (3.17.7)
4
+ avo (3.17.8)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -129,18 +129,18 @@ GEM
129
129
  avo-money_field (0.0.5)
130
130
  money-rails (~> 1.12)
131
131
  avo-record_link_field (0.0.2)
132
- aws-eventstream (1.3.0)
133
- aws-partitions (1.1050.0)
134
- aws-sdk-core (3.218.1)
132
+ aws-eventstream (1.3.1)
133
+ aws-partitions (1.1052.0)
134
+ aws-sdk-core (3.219.0)
135
135
  aws-eventstream (~> 1, >= 1.3.0)
136
136
  aws-partitions (~> 1, >= 1.992.0)
137
137
  aws-sigv4 (~> 1.9)
138
138
  base64
139
139
  jmespath (~> 1, >= 1.6.1)
140
- aws-sdk-kms (1.98.0)
140
+ aws-sdk-kms (1.99.0)
141
141
  aws-sdk-core (~> 3, >= 3.216.0)
142
142
  aws-sigv4 (~> 1.5)
143
- aws-sdk-s3 (1.180.0)
143
+ aws-sdk-s3 (1.182.0)
144
144
  aws-sdk-core (~> 3, >= 3.216.0)
145
145
  aws-sdk-kms (~> 1)
146
146
  aws-sigv4 (~> 1.5)
@@ -178,7 +178,7 @@ GEM
178
178
  rack-test (>= 0.6.3)
179
179
  regexp_parser (>= 1.5, < 3.0)
180
180
  xpath (~> 3.2)
181
- chartkick (5.1.3)
181
+ chartkick (5.1.4)
182
182
  childprocess (5.1.0)
183
183
  logger (~> 1.5)
184
184
  coercible (1.0.0)
@@ -376,7 +376,7 @@ GEM
376
376
  listen (3.9.0)
377
377
  rb-fsevent (~> 0.10, >= 0.10.3)
378
378
  rb-inotify (~> 0.9, >= 0.9.10)
379
- logger (1.6.5)
379
+ logger (1.6.6)
380
380
  loofah (2.24.0)
381
381
  crass (~> 1.0.2)
382
382
  nokogiri (>= 1.12.0)
@@ -422,9 +422,9 @@ GEM
422
422
  net-smtp (0.5.1)
423
423
  net-protocol
424
424
  nio4r (2.7.4)
425
- nokogiri (1.18.2-arm64-darwin)
425
+ nokogiri (1.18.3-arm64-darwin)
426
426
  racc (~> 1.4)
427
- nokogiri (1.18.2-x86_64-linux-gnu)
427
+ nokogiri (1.18.3-x86_64-linux-gnu)
428
428
  racc (~> 1.4)
429
429
  observer (0.1.2)
430
430
  orm_adapter (0.5.0)
@@ -527,7 +527,7 @@ GEM
527
527
  railties (>= 5.2)
528
528
  reverse_markdown (3.0.0)
529
529
  nokogiri
530
- rexml (3.4.0)
530
+ rexml (3.4.1)
531
531
  ripper-tags (1.0.2)
532
532
  rspec-core (3.13.3)
533
533
  rspec-support (~> 3.13.0)
@@ -645,7 +645,7 @@ GEM
645
645
  standard-performance (1.6.0)
646
646
  lint_roller (~> 1.1)
647
647
  rubocop-performance (~> 1.23.0)
648
- stringio (3.1.2)
648
+ stringio (3.1.3)
649
649
  syntax_tree (6.2.0)
650
650
  prettier_print (>= 1.2.0)
651
651
  terminal-table (4.0.0)
@@ -696,7 +696,7 @@ GEM
696
696
  xpath (3.2.0)
697
697
  nokogiri (~> 1.8)
698
698
  yard (0.9.37)
699
- zeitwerk (2.7.1)
699
+ zeitwerk (2.7.2)
700
700
 
701
701
  PLATFORMS
702
702
  arm64-darwin-23
@@ -3,6 +3,7 @@
3
3
  class Avo::PaginatorComponent < Avo::BaseComponent
4
4
  prop :resource
5
5
  prop :parent_record
6
+ prop :parent_resource
6
7
  prop :pagy
7
8
  prop :turbo_frame do |frame|
8
9
  frame.present? ? CGI.escapeHTML(frame) : :_top
@@ -12,7 +13,14 @@ class Avo::PaginatorComponent < Avo::BaseComponent
12
13
 
13
14
  def change_items_per_page_url(option)
14
15
  if @parent_record.present?
15
- helpers.related_resources_path(@parent_record, @parent_record, per_page: option, keep_query_params: true, page: 1)
16
+ helpers.related_resources_path(
17
+ @parent_record,
18
+ @parent_record,
19
+ parent_resource: @parent_resource,
20
+ per_page: option,
21
+ keep_query_params: true,
22
+ page: 1
23
+ )
16
24
  else
17
25
  helpers.resources_path(resource: @resource, per_page: option, keep_query_params: true, page: 1)
18
26
  end
@@ -79,7 +79,7 @@
79
79
  <% if view_type.to_sym == :table || view_type.to_sym == :map %>
80
80
  <% if @records.present? %>
81
81
  <div class="mt-4 w-full">
82
- <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame, index_params: @index_params, resource: @resource, parent_record: @parent_record, discreet_pagination: field&.discreet_pagination %>
82
+ <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame, index_params: @index_params, resource: @resource, parent_record: @parent_record, parent_resource: @parent_resource, discreet_pagination: field&.discreet_pagination %>
83
83
  </div>
84
84
  <% end %>
85
85
  <% end %>
@@ -88,7 +88,7 @@
88
88
  <%= render Avo::Index::ResourceGridComponent.new(resources: @resources, resource: @resource, reflection: @reflection, parent_record: @parent_record, parent_resource: @parent_resource, actions: @actions) %>
89
89
  </div>
90
90
  <div class="mt-6">
91
- <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame, index_params: @index_params, resource: @resource, parent_record: @parent_record, discreet_pagination: field&.discreet_pagination %>
91
+ <%= render Avo::PaginatorComponent.new pagy: @pagy, turbo_frame: @turbo_frame, index_params: @index_params, resource: @resource, parent_record: @parent_record, parent_resource: @parent_resource, discreet_pagination: field&.discreet_pagination %>
92
92
  </div>
93
93
  <% end %>
94
94
  <% end %>
@@ -61,6 +61,7 @@ module Avo
61
61
  parent_record,
62
62
  record,
63
63
  keep_query_params: false,
64
+ parent_resource: nil,
64
65
  **args
65
66
  )
66
67
  return if record.nil?
@@ -75,7 +76,9 @@ module Avo
75
76
  rescue
76
77
  end
77
78
 
78
- avo.resources_associations_index_path(parent_record.model_name.route_key, record.to_param, **existing_params, **args)
79
+ route_key = parent_resource&.route_key || parent_record.model_name.route_key
80
+
81
+ avo.resources_associations_index_path(route_key, record.to_param, **existing_params, **args)
79
82
  end
80
83
 
81
84
  def resource_view_path(**args)
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "3.17.7" unless const_defined?(:VERSION)
2
+ VERSION = "3.17.8" unless const_defined?(:VERSION)
3
3
  end
@@ -185,11 +185,34 @@ module Generators
185
185
 
186
186
  def fields_from_model_associations
187
187
  associations.each do |name, association|
188
- fields[name] = if association.is_a? ActiveRecord::Reflection::ThroughReflection
189
- field_from_through_association(association)
190
- else
191
- ::Avo::Mappings::ASSOCIATIONS_MAPPING[association.class]
192
- end
188
+ fields[name] =
189
+ if association.polymorphic?
190
+ field_with_polymorphic_association(association)
191
+ elsif association.is_a?(ActiveRecord::Reflection::ThroughReflection)
192
+ field_from_through_association(association)
193
+ else
194
+ ::Avo::Mappings::ASSOCIATIONS_MAPPING[association.class]
195
+ end
196
+ end
197
+ end
198
+
199
+ def field_with_polymorphic_association(association)
200
+ Rails.application.eager_load! unless Rails.application.config.eager_load
201
+
202
+ types = polymorphic_association_types(association)
203
+
204
+ {
205
+ field: "belongs_to",
206
+ options: {
207
+ polymorphic_as: ":#{association.name}",
208
+ types: types.presence || "[] # Types weren't computed correctly. Please configure them."
209
+ }
210
+ }
211
+ end
212
+
213
+ def polymorphic_association_types(association)
214
+ ActiveRecord::Base.descendants.filter_map do |model|
215
+ Inspector.new(model.name) if model.reflect_on_all_associations(:has_many).any? { |assoc| assoc.options[:as] == association.name }
193
216
  end
194
217
  end
195
218
 
@@ -293,5 +316,20 @@ module Generators
293
316
  end
294
317
  end
295
318
  end
319
+
320
+ # This class modifies the inspect function to correctly handle polymorphic associations.
321
+ # It is used in the polymorphic_association_types function.
322
+ # Without modification: Model(id: integer, name: string)
323
+ # After modification: Model
324
+ class Inspector
325
+ attr_accessor :name
326
+ def initialize(name)
327
+ @name = name
328
+ end
329
+
330
+ def inspect
331
+ name
332
+ end
333
+ end
296
334
  end
297
335
  end
@@ -1,7 +1,7 @@
1
1
  @charset "UTF-8";
2
2
 
3
3
  /**
4
- * easymde v2.18.0
4
+ * easymde v2.19.0
5
5
  * Copyright Jeroen Akkerman
6
6
  * @link https://github.com/ionaru/easy-markdown-editor
7
7
  * @license MIT
@@ -7726,6 +7726,18 @@ tag.tagify__tag{
7726
7726
  margin-bottom:2rem
7727
7727
  }
7728
7728
 
7729
+ .me-1{
7730
+ margin-inline-end:0.25rem
7731
+ }
7732
+
7733
+ .me-2{
7734
+ margin-inline-end:0.5rem
7735
+ }
7736
+
7737
+ .me-3{
7738
+ margin-inline-end:0.75rem
7739
+ }
7740
+
7729
7741
  .ml-0{
7730
7742
  margin-left:0px
7731
7743
  }