view_component_reflex 0.5.0 → 0.5.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 730dc20cb5c31f500fb8c6fd63c5e21286a4a3ea28f63a64aaa06c1640ef4844
|
4
|
+
data.tar.gz: 911b8665fd95a69b28de2bf366ffa9edb4240070c8e29c145090d27ba8eaf271
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 679abeb33702936136cfc32244be5bd7ed85cbe8526594eb3f3ed8138b0aec7e004507eab5c4624fa0accd19958999a62641122dbfd67693ab9c3bf11424fd9f
|
7
|
+
data.tar.gz: 97f3b2645a43893d09a253c3d8c780ce1c141aab599c67db3fb6bd47ed443780960d831da6b10ff2930a1bdb0eb063ff667c5292b1c23f1e6eb9f1292f890c40
|
@@ -13,7 +13,7 @@ module ViewComponentReflex
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def refresh!
|
16
|
-
@channel.render_page_and_broadcast_morph
|
16
|
+
@channel.send :render_page_and_broadcast_morph, self, ["[data-controller=\"#{stimulus_controller}\"]"], {
|
17
17
|
dataset: element.dataset.to_h,
|
18
18
|
args: [],
|
19
19
|
attrs: element.attributes.to_h,
|
@@ -21,7 +21,7 @@ module ViewComponentReflex
|
|
21
21
|
target: "#{self.class.name}##{method_name}",
|
22
22
|
url: request.url,
|
23
23
|
permanentAttributeName: "data-reflex-permanent"
|
24
|
-
}
|
24
|
+
}
|
25
25
|
end
|
26
26
|
|
27
27
|
def set_state(new_state = {})
|
@@ -55,6 +55,10 @@ module ViewComponentReflex
|
|
55
55
|
@state = obj
|
56
56
|
end
|
57
57
|
|
58
|
+
def stimulus_reflex?
|
59
|
+
helpers.controller.instance_variable_get(:@stimulus_reflex)
|
60
|
+
end
|
61
|
+
|
58
62
|
# key is required if you're using state
|
59
63
|
# We can't initialize the session state in the initial method
|
60
64
|
# because it doesn't have a view_context yet
|
@@ -63,11 +67,11 @@ module ViewComponentReflex
|
|
63
67
|
@key ||= caller.find { |p| p.include? ".html.erb" }&.hash.to_s
|
64
68
|
|
65
69
|
# initialize session state
|
66
|
-
if session[@key].nil?
|
70
|
+
if !stimulus_reflex? || session[@key].nil?
|
67
71
|
ViewComponentReflex::Engine.state_adapter.store_state(request, @key, @state)
|
68
72
|
ViewComponentReflex::Engine.state_adapter.store_state(request, "#{@key}_initial", @state)
|
69
73
|
else
|
70
|
-
ViewComponentReflex::Engine.state_adapter.reconcile_state(request, @key, @state)
|
74
|
+
# ViewComponentReflex::Engine.state_adapter.reconcile_state(request, @key, @state)
|
71
75
|
end
|
72
76
|
@key
|
73
77
|
end
|
@@ -9,18 +9,5 @@ module ViewComponentReflex
|
|
9
9
|
def self.configure
|
10
10
|
yield self if block_given?
|
11
11
|
end
|
12
|
-
|
13
|
-
config.to_prepare do
|
14
|
-
class StimulusReflex::Channel < ActionCable::Channel::Base
|
15
|
-
def render_page_and_broadcast_morph(reflex, selectors, data = {})
|
16
|
-
html = render_page(reflex)
|
17
|
-
if reflex.respond_to? :stimulus_controller
|
18
|
-
selectors = ["[data-controller=\"#{reflex.stimulus_controller}\"]"]
|
19
|
-
end
|
20
|
-
broadcast_morphs selectors, data, html if html.present?
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
12
|
end
|
26
13
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: view_component_reflex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua LeBlanc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|