katalyst-tables 2.1.1 → 2.1.3
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/README.md +1 -1
- data/app/assets/javascripts/controllers/tables/turbo_collection_controller.js +12 -1
- data/app/components/concerns/katalyst/tables/turbo_replaceable.rb +4 -4
- data/app/components/katalyst/tables/pagy_nav_component.rb +3 -1
- data/app/models/concerns/katalyst/tables/collection/pagination.rb +3 -3
- data/app/models/concerns/katalyst/tables/collection/sorting.rb +0 -2
- data/config/importmap.rb +1 -0
- data/lib/katalyst/tables/backend.rb +5 -0
- data/lib/katalyst/tables/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f13db4214a34d37ef3f5cdc1ce35b92d89102f627be22b31794496dad2ca4a7
|
4
|
+
data.tar.gz: 0d6f8dd7971eab72d20d3d1438e75daaf61ae1029c170e77653570312b07e150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3bc64f42389475a49357b0c30236e854a8be2bcc81034d5be4a085a7e5bba54668ac7f0231ab55f8d63feb902620fb9019c9c1040f3422e5d0fd85512102abc
|
7
|
+
data.tar.gz: '09dcc5204e076d9e3e2e6d406d884b23d7bd3e8495bf3d8a6f4dfeb47c6d2109b4e8688d85de884d44d18f3cbe0c3696ce50bce8d0189ed45686c0f87c1e48fd'
|
data/README.md
CHANGED
@@ -281,8 +281,8 @@ def index
|
|
281
281
|
table = Katalyst::Turbo::TableComponent.new(collection:, id: "people")
|
282
282
|
|
283
283
|
respond_to do |format|
|
284
|
+
format.turbo_stream { render table } if self_referred?
|
284
285
|
format.html { render locals: { table: table } }
|
285
|
-
format.turbo_stream { render table }
|
286
286
|
end
|
287
287
|
end
|
288
288
|
```
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Controller } from "@hotwired/stimulus";
|
2
|
+
import { Turbo } from "@hotwired/turbo";
|
2
3
|
|
3
4
|
export default class TurboCollectionController extends Controller {
|
4
5
|
static values = {
|
@@ -7,7 +8,7 @@ export default class TurboCollectionController extends Controller {
|
|
7
8
|
}
|
8
9
|
|
9
10
|
urlValueChanged(url) {
|
10
|
-
|
11
|
+
Turbo.navigator.history.replace(this.#url(url));
|
11
12
|
}
|
12
13
|
|
13
14
|
sortValueChanged(sort) {
|
@@ -19,4 +20,14 @@ export default class TurboCollectionController extends Controller {
|
|
19
20
|
get #sortSelector() {
|
20
21
|
return "input[name='sort']";
|
21
22
|
}
|
23
|
+
|
24
|
+
#url(relativeUrl) {
|
25
|
+
const frame = this.element.closest("turbo-frame");
|
26
|
+
|
27
|
+
if (frame) {
|
28
|
+
return new URL(relativeUrl, frame.baseURI);
|
29
|
+
} else {
|
30
|
+
return new URL(relativeUrl, window.location.href);
|
31
|
+
}
|
32
|
+
}
|
22
33
|
}
|
@@ -47,10 +47,10 @@ module Katalyst
|
|
47
47
|
component_class.alias_method(:vc_render_template_for, :render_template_for)
|
48
48
|
component_class.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
49
49
|
def render_template_for(variant = nil)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
if turbo? && response.media_type.eql?("text/vnd.turbo-stream.html")
|
51
|
+
turbo_stream.replace(id, vc_render_template_for(variant))
|
52
|
+
else
|
53
|
+
vc_render_template_for(variant)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
RUBY
|
@@ -3,7 +3,9 @@
|
|
3
3
|
module Katalyst
|
4
4
|
module Tables
|
5
5
|
class PagyNavComponent < ViewComponent::Base # :nodoc:
|
6
|
-
|
6
|
+
# Pagy is not a required gem unless you're using pagination
|
7
|
+
# Expect to see NoMethodError failures if pagy is not available
|
8
|
+
"Pagy::Frontend".safe_constantize&.tap { |pagy| include(pagy) }
|
7
9
|
|
8
10
|
attr_reader :pagy_options
|
9
11
|
|
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "pagy/backend"
|
4
|
-
|
5
3
|
module Katalyst
|
6
4
|
module Tables
|
7
5
|
module Collection
|
@@ -41,7 +39,9 @@ module Katalyst
|
|
41
39
|
end
|
42
40
|
|
43
41
|
class Paginate # :nodoc:
|
44
|
-
|
42
|
+
# Pagy is not a required gem unless you're using pagination
|
43
|
+
# Expect to see NoMethodError failures if pagy is not available
|
44
|
+
"Pagy::Backend".safe_constantize&.tap { |pagy| include(pagy) }
|
45
45
|
|
46
46
|
def initialize(app)
|
47
47
|
@app = app
|
data/config/importmap.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
4
|
+
pin "@hotwired/turbo", to: "turbo.min.js", preload: true
|
4
5
|
|
5
6
|
pin_all_from Katalyst::Tables::Engine.root.join("app/assets/javascripts"),
|
6
7
|
# preload in tests so that we don't start clicking before controllers load
|
@@ -27,6 +27,11 @@ module Katalyst
|
|
27
27
|
.apply(collection)
|
28
28
|
end
|
29
29
|
|
30
|
+
def self_referred?
|
31
|
+
request.referer.present? && URI.parse(request.referer).path == request.path
|
32
|
+
end
|
33
|
+
alias self_refered? self_referred?
|
34
|
+
|
30
35
|
included do
|
31
36
|
class_attribute :_default_table_component, instance_accessor: false
|
32
37
|
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.3
|
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-
|
11
|
+
date: 2023-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: html-attributes-utils
|