katalyst-tables 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +151 -103
- data/app/assets/config/katalyst-tables.js +1 -0
- data/app/assets/javascripts/controllers/tables/turbo_collection_controller.js +22 -0
- data/app/components/concerns/katalyst/tables/configurable_component.rb +31 -0
- data/app/components/concerns/katalyst/tables/has_html_attributes.rb +45 -0
- data/app/components/concerns/katalyst/tables/has_table_content.rb +33 -0
- data/app/components/concerns/katalyst/tables/sortable.rb +32 -0
- data/app/components/concerns/katalyst/tables/turbo_replaceable.rb +62 -0
- data/app/components/katalyst/table_component.rb +51 -40
- data/app/components/katalyst/tables/body_cell_component.rb +4 -4
- data/app/components/katalyst/tables/body_row_component.rb +3 -3
- data/app/components/katalyst/tables/empty_caption_component.html.erb +6 -0
- data/app/components/katalyst/tables/empty_caption_component.rb +38 -0
- data/app/components/katalyst/tables/header_cell_component.rb +20 -16
- data/app/components/katalyst/tables/header_row_component.rb +6 -5
- data/app/components/katalyst/tables/pagy_nav_component.rb +26 -0
- data/app/components/katalyst/turbo/pagy_nav_component.rb +23 -0
- data/app/components/katalyst/turbo/table_component.rb +48 -0
- data/app/models/concerns/katalyst/tables/collection/core.rb +71 -0
- data/app/models/concerns/katalyst/tables/collection/pagination.rb +66 -0
- data/app/models/concerns/katalyst/tables/collection/sorting.rb +63 -0
- data/app/models/katalyst/tables/collection.rb +32 -0
- data/config/importmap.rb +7 -0
- data/lib/katalyst/tables/backend/sort_form.rb +16 -2
- data/lib/katalyst/tables/engine.rb +13 -0
- data/lib/katalyst/tables/frontend/helper.rb +4 -14
- data/lib/katalyst/tables/version.rb +1 -1
- metadata +33 -2
@@ -6,6 +6,19 @@ module Katalyst
|
|
6
6
|
module Tables
|
7
7
|
class Engine < ::Rails::Engine # :nodoc:
|
8
8
|
isolate_namespace Katalyst::Tables
|
9
|
+
|
10
|
+
initializer "katalyst-tables.asset" do
|
11
|
+
config.after_initialize do |app|
|
12
|
+
app.config.assets.precompile += %w[katalyst-tables.js] if app.config.respond_to?(:assets)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer "katalyst-tables.importmap", before: "importmap" do |app|
|
17
|
+
if app.config.respond_to?(:importmap)
|
18
|
+
app.config.importmap.paths << root.join("config/importmap.rb")
|
19
|
+
app.config.importmap.cache_sweepers << root.join("app/assets/javascripts")
|
20
|
+
end
|
21
|
+
end
|
9
22
|
end
|
10
23
|
end
|
11
24
|
end
|
@@ -3,30 +3,20 @@
|
|
3
3
|
module Katalyst
|
4
4
|
module Tables
|
5
5
|
module Frontend
|
6
|
+
# @deprecated Use {Katalyst::TableComponent} instead.
|
6
7
|
module Helper # :nodoc:
|
7
8
|
extend ActiveSupport::Concern
|
8
9
|
|
9
|
-
def initialize(**options)
|
10
|
-
super()
|
11
|
-
|
12
|
-
options(**options)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Add HTML options to the current component.
|
16
|
-
def options(html: {}, **options)
|
17
|
-
@html_options = options.slice(:id, :aria, :class, :data).merge(html)
|
18
|
-
@html_options.stringify_keys!
|
19
|
-
end
|
20
|
-
|
21
10
|
# Generates a url for applying/toggling sort for the given column.
|
22
11
|
#
|
23
12
|
# @param sort [String, nil] sort parameter to apply, or nil to remove sorting
|
24
13
|
# @return [String] URL for toggling column sorting
|
25
|
-
|
14
|
+
# @deprecated Use {Katalyst::TablesComponent} instead.
|
15
|
+
def sort_url_for(sort: nil, default: nil)
|
26
16
|
# Implementation inspired by pagy's `pagy_url_for` helper.
|
27
17
|
# Preserve any existing GET parameters
|
28
18
|
# CAUTION: these parameters are not sanitised
|
29
|
-
params = if sort
|
19
|
+
params = if sort && !sort.eql?(default)
|
30
20
|
request.GET.merge("sort" => sort).except("page")
|
31
21
|
else
|
32
22
|
request.GET.except("page", "sort")
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-tables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: html-attributes-utils
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: view_component
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -35,11 +49,28 @@ files:
|
|
35
49
|
- CHANGELOG.md
|
36
50
|
- LICENSE.txt
|
37
51
|
- README.md
|
52
|
+
- app/assets/config/katalyst-tables.js
|
53
|
+
- app/assets/javascripts/controllers/tables/turbo_collection_controller.js
|
54
|
+
- app/components/concerns/katalyst/tables/configurable_component.rb
|
55
|
+
- app/components/concerns/katalyst/tables/has_html_attributes.rb
|
56
|
+
- app/components/concerns/katalyst/tables/has_table_content.rb
|
57
|
+
- app/components/concerns/katalyst/tables/sortable.rb
|
58
|
+
- app/components/concerns/katalyst/tables/turbo_replaceable.rb
|
38
59
|
- app/components/katalyst/table_component.rb
|
39
60
|
- app/components/katalyst/tables/body_cell_component.rb
|
40
61
|
- app/components/katalyst/tables/body_row_component.rb
|
62
|
+
- app/components/katalyst/tables/empty_caption_component.html.erb
|
63
|
+
- app/components/katalyst/tables/empty_caption_component.rb
|
41
64
|
- app/components/katalyst/tables/header_cell_component.rb
|
42
65
|
- app/components/katalyst/tables/header_row_component.rb
|
66
|
+
- app/components/katalyst/tables/pagy_nav_component.rb
|
67
|
+
- app/components/katalyst/turbo/pagy_nav_component.rb
|
68
|
+
- app/components/katalyst/turbo/table_component.rb
|
69
|
+
- app/models/concerns/katalyst/tables/collection/core.rb
|
70
|
+
- app/models/concerns/katalyst/tables/collection/pagination.rb
|
71
|
+
- app/models/concerns/katalyst/tables/collection/sorting.rb
|
72
|
+
- app/models/katalyst/tables/collection.rb
|
73
|
+
- config/importmap.rb
|
43
74
|
- lib/katalyst/tables.rb
|
44
75
|
- lib/katalyst/tables/backend.rb
|
45
76
|
- lib/katalyst/tables/backend/sort_form.rb
|