avo 2.50.0 → 2.52.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/app/controllers/avo/base_controller.rb +9 -4
- data/lib/avo/base_resource.rb +2 -2
- data/lib/avo/fields/belongs_to_field.rb +4 -4
- data/lib/avo/fields/has_base_field.rb +4 -4
- data/lib/avo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecf46732c743cb0408230bc9b73ec747d2094603d9ac4673b9a8bcf6e3510247
|
4
|
+
data.tar.gz: b74e17cfa53122dc69ccc4cf91578132f59ac3b3ef3f912e0991360db1380ecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9e9b5751953ed132817a67240cda51c1aa46c23331fe54715fac61207e60eba5cd1605b650b34eed205818b20fd8ce965757f40ba9b200974aae45a6aaf1660
|
7
|
+
data.tar.gz: f97d7ef68d013033215daed86e2be33bb116c37ddd9a6113bc8d4eb1954ede77689a20c664ea4e9fe896e726d96e4e2f909f6231bfbb5cfe07bc05e8275a4cd8
|
data/Gemfile.lock
CHANGED
@@ -48,13 +48,18 @@ module Avo
|
|
48
48
|
@query = @query.unscope(:order)
|
49
49
|
end
|
50
50
|
|
51
|
+
sanitized_sort_direction = @index_params[:sort_direction].presence_in(["asc", "desc"])
|
52
|
+
|
51
53
|
# Check if the sortable field option is actually a proc and we need to do a custom sort
|
52
|
-
|
53
|
-
field = @resource.
|
54
|
+
sort_by = @index_params[:sort_by].to_sym
|
55
|
+
field = @resource.get_field(sort_by)
|
54
56
|
@query = if field&.sortable.is_a?(Proc)
|
55
|
-
field.sortable.call(@query,
|
57
|
+
field.sortable.call(@query, sanitized_sort_direction)
|
58
|
+
elsif field.present? && sanitized_sort_direction
|
59
|
+
@query.order("#{@resource.model_class.table_name}.#{sort_by} #{sanitized_sort_direction}")
|
60
|
+
# Transform Model to ActiveRecord::Relation because Avo expects one.
|
56
61
|
else
|
57
|
-
@query.
|
62
|
+
@query.where("1=1")
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
data/lib/avo/base_resource.rb
CHANGED
@@ -114,7 +114,7 @@ module Avo
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def get_record_associations(record)
|
117
|
-
record.
|
117
|
+
record.class.reflections
|
118
118
|
end
|
119
119
|
|
120
120
|
def valid_association_name(record, association_name)
|
@@ -382,7 +382,7 @@ module Avo
|
|
382
382
|
|
383
383
|
if field.type == "belongs_to"
|
384
384
|
|
385
|
-
reflection = @model.
|
385
|
+
reflection = @model.class.reflections[@params[:via_relation]]
|
386
386
|
|
387
387
|
if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params[:via_relation_class])
|
388
388
|
# set the value to the actual record
|
@@ -245,10 +245,10 @@ module Avo
|
|
245
245
|
|
246
246
|
reflection_key = polymorphic_as || id
|
247
247
|
|
248
|
-
if @model.
|
249
|
-
App.get_resource_by_model_name @model.
|
250
|
-
elsif @model.
|
251
|
-
App.get_resource_by_model_name @model.
|
248
|
+
if @model.class.reflect_on_association(reflection_key).klass.present?
|
249
|
+
App.get_resource_by_model_name @model.class.reflect_on_association(reflection_key).klass.to_s
|
250
|
+
elsif @model.class.reflect_on_association(reflection_key).options[:class_name].present?
|
251
|
+
App.get_resource_by_model_name @model.class.reflect_on_association(reflection_key).options[:class_name]
|
252
252
|
else
|
253
253
|
App.get_resource_by_name reflection_key.to_s
|
254
254
|
end
|
@@ -59,10 +59,10 @@ module Avo
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def target_resource
|
62
|
-
if @model.
|
63
|
-
Avo::App.get_resource_by_model_name @model.
|
64
|
-
elsif @model.
|
65
|
-
Avo::App.get_resource_by_model_name @model.
|
62
|
+
if @model.class.reflect_on_association(id).klass.present?
|
63
|
+
Avo::App.get_resource_by_model_name @model.class.reflect_on_association(id).klass.to_s
|
64
|
+
elsif @model.class.reflect_on_association(id).options[:class_name].present?
|
65
|
+
Avo::App.get_resource_by_model_name @model.class.reflect_on_association(id).options[:class_name]
|
66
66
|
else
|
67
67
|
Avo::App.get_resource_by_name id.to_s
|
68
68
|
end
|
data/lib/avo/version.rb
CHANGED
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: 2.
|
4
|
+
version: 2.52.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-08-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|