avo 2.50.0 → 2.51.0

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: 6ec2fc0304d9fb79831bfe41b68a8ca9b4df52526e2212f2e8db9cd073837ee8
4
- data.tar.gz: 45b6b466d8528de3f7bbf182b53ce38b1efb5c14ad6958fa58e5ce4a83070a57
3
+ metadata.gz: 47e343f6db0d2739fc03fcf0969f1f4a315d3d79502ce7c8179ff3e373820ce9
4
+ data.tar.gz: 58fd4554a1f1bc28a3ead98ce1ee0350a2665b8778835a9dda7747bb855e814c
5
5
  SHA512:
6
- metadata.gz: 65de9dbd9c220bd8a9723f5e952db9339def09d0f4a9ec0470b3f7dca05d8c970591341cff79986167136821658ad5a400e74bdce12ea66c692108b53b82ffa4
7
- data.tar.gz: 5732cf3b83f079b62f4eb4754114d759ad5a4ecc5673ddebe0e7da58f3ff48b294266945d2104ac70aa16681acdc3bafd09b81c2a7227851791786f19589a1f5
6
+ metadata.gz: 343a36a7b481bf9c42729b849e9aafd2409809ce7ae740f670d491aa5409b40d39a6523babf73e0ef4cb843d027eecb8c6ba438752545c9e7b78d8823cd540a3
7
+ data.tar.gz: f7f1df73690020c4584b375754b08381e4174b39a911c8daf02980df2d1f8c679106e6f350404c6a56bf7ea82c63200c9ddf3b3147454e1246d3ceccad6708b0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (2.50.0)
4
+ avo (2.51.0)
5
5
  actionview (>= 6.0)
6
6
  active_link_to
7
7
  activerecord (>= 6.0)
@@ -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
- field_id = @index_params[:sort_by].to_sym
53
- field = @resource.get_field_definitions.find { |field| field.id == field_id }
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, @index_params[:sort_direction])
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.order("#{@resource.model_class.table_name}.#{@index_params[:sort_by]} #{@index_params[:sort_direction]}")
62
+ @query.where("1=1")
58
63
  end
59
64
  end
60
65
 
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "2.50.0" unless const_defined?(:VERSION)
2
+ VERSION = "2.51.0" 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: 2.50.0
4
+ version: 2.51.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-05-07 00:00:00.000000000 Z
13
+ date: 2024-05-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord