katalyst-tables 3.10.0 → 3.11.1
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/app/components/katalyst/tables/pagy_nav_component.rb +16 -2
- data/app/models/concerns/katalyst/tables/collection/core.rb +8 -1
- data/app/models/concerns/katalyst/tables/collection/pagination.rb +13 -6
- data/app/models/concerns/katalyst/tables/collection/sorting.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e8456c713efa8b079198dff2fd156ba028258ff09eb056b6a9a95cc5eb1aeaf
|
|
4
|
+
data.tar.gz: 4f6045cabeecbb034134151167dae9e9ce1c0f8744e32576829665fde2ec9117
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b22f53a017c4e9120fab8d73fedc699d929c5ce855e659ce67cc20a592b27dd0400111ace41ddf0d0b5cc9646a5836263b82c564b3ed795fc2fff9b8137b7f61
|
|
7
|
+
data.tar.gz: 8bee047ee8e2ca64e849f8735a87f1f917ef4a83d757b9372d9be3e1f176a17de390ac0f57cab1140d967cc4dbc1c94496a9c5063bf68dc69cbbe5ddc6fd962e
|
data/CHANGELOG.md
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
|
@@ -3,18 +3,25 @@
|
|
|
3
3
|
module Katalyst
|
|
4
4
|
module Tables
|
|
5
5
|
module Collection
|
|
6
|
+
class Config
|
|
7
|
+
attr_accessor :paginate, :sorting
|
|
8
|
+
end
|
|
9
|
+
|
|
6
10
|
module Core # :nodoc:
|
|
7
11
|
extend ActiveSupport::Concern
|
|
8
12
|
|
|
9
13
|
include ActiveModel::Model
|
|
10
14
|
include ActiveModel::Attributes
|
|
11
15
|
include ActiveModel::Dirty
|
|
12
|
-
include ActiveSupport::Configurable
|
|
13
16
|
|
|
14
17
|
include HasParams
|
|
15
18
|
include Reducers
|
|
16
19
|
|
|
17
20
|
class_methods do
|
|
21
|
+
def config
|
|
22
|
+
@config ||= Config.new
|
|
23
|
+
end
|
|
24
|
+
|
|
18
25
|
def permitted_params
|
|
19
26
|
_default_attributes.to_h.each_with_object([]) do |(k, v), h|
|
|
20
27
|
h << case v
|
|
@@ -20,11 +20,9 @@ module Katalyst
|
|
|
20
20
|
attr_accessor :pagination
|
|
21
21
|
|
|
22
22
|
attribute :page, :integer, default: 1, filter: false
|
|
23
|
-
|
|
24
|
-
config_accessor :paginate
|
|
25
23
|
end
|
|
26
24
|
|
|
27
|
-
def initialize(paginate: config.paginate, **)
|
|
25
|
+
def initialize(paginate: self.class.config.paginate, **)
|
|
28
26
|
super(**)
|
|
29
27
|
|
|
30
28
|
@paginate = paginate.freeze
|
|
@@ -38,7 +36,7 @@ module Katalyst
|
|
|
38
36
|
opts = @paginate.is_a?(Hash) ? @paginate : {}
|
|
39
37
|
opts = opts.dup
|
|
40
38
|
|
|
41
|
-
if PagyNavComponent.
|
|
39
|
+
if PagyNavComponent.pagy_pre_8?
|
|
42
40
|
opts[:anchor_string] ||= "data-turbo-action=\"replace\""
|
|
43
41
|
end
|
|
44
42
|
|
|
@@ -48,7 +46,11 @@ module Katalyst
|
|
|
48
46
|
class Paginate # :nodoc:
|
|
49
47
|
# Pagy is not a required gem unless you're using pagination
|
|
50
48
|
# Expect to see NoMethodError failures if pagy is not available
|
|
51
|
-
"Pagy::
|
|
49
|
+
if (pagy_method = "Pagy::Method".safe_constantize)
|
|
50
|
+
include(pagy_method)
|
|
51
|
+
else
|
|
52
|
+
"Pagy::Backend".safe_constantize&.tap { |pagy| include(pagy) }
|
|
53
|
+
end
|
|
52
54
|
|
|
53
55
|
def initialize(app)
|
|
54
56
|
@app = app
|
|
@@ -64,7 +66,12 @@ module Katalyst
|
|
|
64
66
|
|
|
65
67
|
# pagy shim
|
|
66
68
|
def params
|
|
67
|
-
@collection.
|
|
69
|
+
@collection.to_params
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Pagy 43 expects a request object; provide the minimal hash interface it supports.
|
|
73
|
+
def request
|
|
74
|
+
{ base_url: nil, path: nil, params:, cookie: nil }
|
|
68
75
|
end
|
|
69
76
|
end
|
|
70
77
|
end
|
|
@@ -55,7 +55,7 @@ module Katalyst
|
|
|
55
55
|
attr_reader :default_sort
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def initialize(sorting: config.sorting, **)
|
|
58
|
+
def initialize(sorting: self.class.config.sorting, **)
|
|
59
59
|
@default_sort = sorting.to_param if sorting.present?
|
|
60
60
|
|
|
61
61
|
super(sort: @default_sort, **) # set default sort based on config
|