katalyst-tables 3.10.0 → 3.11.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: 1f28bfdf9aae3a6cf0fc5822baa12cfe8da12dbd23b4a3b28c2bd6b816fad9f2
4
- data.tar.gz: 31828abc1872970d1d9f7280ff166074e5cd8444ccdcc599a9bcf03095296a0b
3
+ metadata.gz: '058d981c1598d836b758da0286de162feed139ae80aa1b59465a4505bd3ef0e2'
4
+ data.tar.gz: ed95bb712fdf61560678659121b5a368839830ae3577eca4ae9d4c98d04f5b6c
5
5
  SHA512:
6
- metadata.gz: ac366753b188bb5a4d90da55fda2b6e285ca5640681a5aac053decad8ca499cded748569875de0647439cc08691830fed2517b01e05bc0308d8aa6b13a23b38d
7
- data.tar.gz: a15ba7a25da90dda2bb5a235977d67c1ee8807058b83799ef6e56f15c16d7f573d0e44d11a511736a9669ac5184563c4e51579a4e930061f5917c29f8b5b398f
6
+ metadata.gz: a24284360f7f865e46001614c877a4564c87b2c6a197a94ece8430d55ac1aa14b49d5f86be1b7304f662c56418b0d288e8ddfc8933298277b7579c0eff1042f5
7
+ data.tar.gz: e6cb76f7383fb3a146465701b2842ebe54f4e0352e6fd0fb0d88ea83c9c397de7789b66fdf8d1e589fafcef78a50f3063a359b9e588bf88422e8797fa38a8f3d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [3.11.0]
2
+
3
+ * Support for Pagy 43
4
+
1
5
  ## [3.10.0]
2
6
 
3
7
  * Support for Rails 8.1
@@ -8,7 +8,15 @@ module Katalyst
8
8
  "Pagy::Frontend".safe_constantize&.tap { |pagy| include(pagy) }
9
9
 
10
10
  def self.pagy_legacy?
11
- Pagy::VERSION.scan(/\d+/).first.to_i <= 8
11
+ pagy_major < 43
12
+ end
13
+
14
+ def self.pagy_pre_8?
15
+ pagy_major < 8
16
+ end
17
+
18
+ def self.pagy_major
19
+ @pagy_major ||= Pagy::VERSION.scan(/\d+/).first.to_i
12
20
  end
13
21
 
14
22
  delegate :pagy_legacy?, to: :class
@@ -25,7 +33,7 @@ module Katalyst
25
33
  end
26
34
 
27
35
  def call
28
- pagy_nav(@pagy, **pagy_options).html_safe # rubocop:disable Rails/OutputSafety
36
+ render_nav.html_safe # rubocop:disable Rails/OutputSafety
29
37
  end
30
38
 
31
39
  def pagy_options
@@ -38,6 +46,12 @@ module Katalyst
38
46
 
39
47
  private
40
48
 
49
+ def render_nav
50
+ return pagy_nav(@pagy, **pagy_options) if pagy_legacy?
51
+
52
+ @pagy.series_nav(**pagy_options)
53
+ end
54
+
41
55
  def default_pagy_options
42
56
  pagy_legacy? ? {} : { anchor_string: 'data-turbo-action="replace"' }
43
57
  end
@@ -38,7 +38,7 @@ module Katalyst
38
38
  opts = @paginate.is_a?(Hash) ? @paginate : {}
39
39
  opts = opts.dup
40
40
 
41
- if PagyNavComponent.pagy_legacy?
41
+ if PagyNavComponent.pagy_pre_8?
42
42
  opts[:anchor_string] ||= "data-turbo-action=\"replace\""
43
43
  end
44
44
 
@@ -48,7 +48,11 @@ module Katalyst
48
48
  class Paginate # :nodoc:
49
49
  # Pagy is not a required gem unless you're using pagination
50
50
  # Expect to see NoMethodError failures if pagy is not available
51
- "Pagy::Backend".safe_constantize&.tap { |pagy| include(pagy) }
51
+ if (pagy_method = "Pagy::Method".safe_constantize)
52
+ include(pagy_method)
53
+ else
54
+ "Pagy::Backend".safe_constantize&.tap { |pagy| include(pagy) }
55
+ end
52
56
 
53
57
  def initialize(app)
54
58
  @app = app
@@ -64,7 +68,12 @@ module Katalyst
64
68
 
65
69
  # pagy shim
66
70
  def params
67
- @collection.attributes.with_indifferent_access
71
+ @collection.to_params
72
+ end
73
+
74
+ # Pagy 43 expects a request object; provide the minimal hash interface it supports.
75
+ def request
76
+ { base_url: nil, path: nil, params:, cookie: nil }
68
77
  end
69
78
  end
70
79
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katalyst-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.10.0
4
+ version: 3.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katalyst Interactive