katalyst-tables 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c5cc96bc55db7f0cf4c3a22659e6054607640e6d33af939805d4be6ca8f25c1
|
4
|
+
data.tar.gz: 1661c91c498d7c994afca1cb4a0bfcb69b6e2076a419ae71b138c5ae086e4a0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6f94b4a381ec3f9e952d594e1525b61b97d17d2d8c42fcc230fa81328303768d174f2778eb3918f681f28d38227cf9f3c83af340e0ea5ecc78857c6dad7c44d
|
7
|
+
data.tar.gz: 01a7fcf97aea5435986ab2b0357249bfd03bb60bc98fb22769aef88c154520753e9b340fe981edcf74f6bf4d32eafbd45bd318158cf92926fe3162f459928ff7
|
@@ -11,13 +11,9 @@ module Katalyst
|
|
11
11
|
include ActiveModel::Dirty
|
12
12
|
include ActiveSupport::Configurable
|
13
13
|
|
14
|
-
|
15
|
-
class_attribute :reducers, default: ActionDispatch::MiddlewareStack.new
|
16
|
-
|
17
|
-
class << self
|
18
|
-
delegate :use, :before, to: :reducers
|
19
|
-
end
|
14
|
+
include Reducers
|
20
15
|
|
16
|
+
included do
|
21
17
|
attr_accessor :items
|
22
18
|
|
23
19
|
delegate :model, :to_model, :each, :count, :empty?, to: :items, allow_nil: true
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Tables
|
5
|
+
module Collection
|
6
|
+
# Adds stackable reducers to a collection.
|
7
|
+
# Inspired by ActiveDispatch::MiddlewareStack which unfortunately can't
|
8
|
+
# be used due to monkey patches from gems such as NewRelic which assume
|
9
|
+
# it is only used for Rack middleware.
|
10
|
+
module Reducers
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
class_attribute :reducers, default: Stack.new
|
15
|
+
end
|
16
|
+
|
17
|
+
class_methods do
|
18
|
+
delegate :use, :insert, to: :reducers
|
19
|
+
end
|
20
|
+
|
21
|
+
class Stack # :nodoc:
|
22
|
+
def initialize
|
23
|
+
@stack = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def use(klass)
|
27
|
+
@stack << Reducer.new(klass) unless index(klass)
|
28
|
+
end
|
29
|
+
|
30
|
+
def insert(other, klass)
|
31
|
+
@stack.insert(index(other), Reducer.new(klass))
|
32
|
+
end
|
33
|
+
|
34
|
+
def index(klass)
|
35
|
+
@stack.index(Reducer.new(klass))
|
36
|
+
end
|
37
|
+
|
38
|
+
def build(&block)
|
39
|
+
@stack.freeze.reduce(block) do |app, reducer|
|
40
|
+
reducer.build(app)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Reducer # :nodoc:
|
46
|
+
attr_reader :klass
|
47
|
+
|
48
|
+
def initialize(klass)
|
49
|
+
@klass = klass
|
50
|
+
end
|
51
|
+
|
52
|
+
def build(app)
|
53
|
+
klass.new(app)
|
54
|
+
end
|
55
|
+
|
56
|
+
def ==(other)
|
57
|
+
klass.name == other.klass.name
|
58
|
+
end
|
59
|
+
|
60
|
+
def inspect
|
61
|
+
"#<#{self.class.name} #{klass.name}>"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katalyst Interactive
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-attributes-utils
|
@@ -68,6 +68,7 @@ files:
|
|
68
68
|
- app/components/katalyst/turbo/table_component.rb
|
69
69
|
- app/models/concerns/katalyst/tables/collection/core.rb
|
70
70
|
- app/models/concerns/katalyst/tables/collection/pagination.rb
|
71
|
+
- app/models/concerns/katalyst/tables/collection/reducers.rb
|
71
72
|
- app/models/concerns/katalyst/tables/collection/sorting.rb
|
72
73
|
- app/models/katalyst/tables/collection.rb
|
73
74
|
- config/importmap.rb
|