render_turbo_stream 1.4.12 → 1.4.14
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/app/models/render_turbo_stream/cable_stream.rb +4 -0
- data/db/migrate/20230428115511_cable_streams.rb +4 -0
- data/db/migrate/20230428115724_create_render_turbo_stream_cable_streams.rb +11 -0
- data/lib/render_turbo_stream/turbo_cable_helpers.rb +22 -0
- data/lib/render_turbo_stream/turbo_cable_view_helpers.rb +17 -0
- data/lib/render_turbo_stream/version.rb +1 -1
- data/lib/render_turbo_stream.rb +6 -3
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2c84aacdaefecd60e436ebd13e68801e87d02d3318ded429a643605b2ec94a3
|
4
|
+
data.tar.gz: 1b6089600ec4abe349d2cae88a1802f258a535e2303f9289cc29ec0e7c09bf66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83b71f6a084d9da96a09d710bc64c46506a424a8d704838ed0b91b54853cf799d3c1c336c2059bfd23f8ec70581f850c87341bbc03419efe2627c762fee94ff3
|
7
|
+
data.tar.gz: a623f4b6acf363a224adfbf4e4e246bec3fcd3f3cc267452ee66bb8bdd6067d0c50a94de45611edbd1640ab25c567d05a9a4853d24d2fbe885a8e2427c336454
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateRenderTurboStreamCableStreams < ActiveRecord::Migration[7.0]
|
2
|
+
def change
|
3
|
+
create_table :render_turbo_stream_cable_streams do |t|
|
4
|
+
t.string :request_id, limit: 80
|
5
|
+
t.text :locals
|
6
|
+
t.string :action, limit: 80
|
7
|
+
t.string :arguments
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RenderTurboStream
|
2
|
+
module TurboCableHelpers
|
3
|
+
|
4
|
+
|
5
|
+
def turbo_cable_to_authenticated
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
def turbo_cable_to_current_user(target, action, *args, partial: nil, locals: nil)
|
10
|
+
if [:append, :prepend, :replace].include?(action.to_sym)
|
11
|
+
Turbo::StreamsChannel.send("broadcast_#{action}_to", "current_user_#{helpers.current_user.id}", *args, target: target, partial: partial, locals: locals)
|
12
|
+
else
|
13
|
+
# Turbo::StreamsChannel.broadcast_action_to(
|
14
|
+
# "current_user_#{helpers.current_user.id}",
|
15
|
+
# action:'toggle_css_class',
|
16
|
+
# 'colored-element'
|
17
|
+
# )
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module RenderTurboStream
|
2
|
+
module TurboCableViewHelpers
|
3
|
+
|
4
|
+
def turbo_cable_from_current_user
|
5
|
+
if current_user
|
6
|
+
turbo_stream_from "current_user_#{current_user.id}"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def turbo_cable_from_authenticated_users
|
11
|
+
if user_signed_in?
|
12
|
+
turbo_stream_from "authenticated_users"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
data/lib/render_turbo_stream.rb
CHANGED
@@ -3,6 +3,8 @@ require "render_turbo_stream/railtie"
|
|
3
3
|
require 'render_turbo_stream/engine'
|
4
4
|
require 'render_turbo_stream/test/request_helpers'
|
5
5
|
require 'render_turbo_stream/test/rspec_request_helpers'
|
6
|
+
require 'render_turbo_stream/turbo_cable_helpers'
|
7
|
+
require 'render_turbo_stream/turbo_cable_view_helpers'
|
6
8
|
|
7
9
|
module RenderTurboStream
|
8
10
|
|
@@ -47,9 +49,7 @@ module RenderTurboStream
|
|
47
49
|
|
48
50
|
if save_action
|
49
51
|
response.status = 200
|
50
|
-
Rails.logger.debug('start loop')
|
51
52
|
streams_on_success.each do |s|
|
52
|
-
Rails.logger.debug('inside loop')
|
53
53
|
if s.is_a?(Array)
|
54
54
|
streams.push(s)
|
55
55
|
elsif s.is_a?(Hash) && s[:id].present?
|
@@ -135,6 +135,8 @@ module RenderTurboStream
|
|
135
135
|
response.status = 302
|
136
136
|
flash[:alert] = flash_alerts
|
137
137
|
flash[:notice] = flash_notices
|
138
|
+
Rails.logger.debug(" • Set flash[:alert] => #{flash_alerts}") if flash_alerts.present?
|
139
|
+
Rails.logger.debug(" • Set flash[:notice] => #{flash_notices}") if flash_notices.present?
|
138
140
|
render_turbo_stream([
|
139
141
|
[
|
140
142
|
:redirect_to,
|
@@ -145,7 +147,8 @@ module RenderTurboStream
|
|
145
147
|
response.status = 302
|
146
148
|
flash[:alert] = flash_alerts
|
147
149
|
flash[:notice] = flash_notices
|
148
|
-
#
|
150
|
+
Rails.logger.debug(" • Set flash[:alert] => #{flash_alerts}") if flash_alerts.present?
|
151
|
+
Rails.logger.debug(" • Set flash[:notice] => #{flash_notices}") if flash_notices.present?
|
149
152
|
redirect_to redirect_on_success_to
|
150
153
|
|
151
154
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: render_turbo_stream
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -38,13 +38,18 @@ files:
|
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
40
|
- app/controllers/render_turbo_stream/application_controller.rb
|
41
|
+
- app/models/render_turbo_stream/cable_stream.rb
|
41
42
|
- app/views/render_turbo_stream.html.erb
|
42
43
|
- app/views/render_turbo_stream.turbo_stream.erb
|
44
|
+
- db/migrate/20230428115511_cable_streams.rb
|
45
|
+
- db/migrate/20230428115724_create_render_turbo_stream_cable_streams.rb
|
43
46
|
- lib/render_turbo_stream.rb
|
44
47
|
- lib/render_turbo_stream/engine.rb
|
45
48
|
- lib/render_turbo_stream/railtie.rb
|
46
49
|
- lib/render_turbo_stream/test/request_helpers.rb
|
47
50
|
- lib/render_turbo_stream/test/rspec_request_helpers.rb
|
51
|
+
- lib/render_turbo_stream/turbo_cable_helpers.rb
|
52
|
+
- lib/render_turbo_stream/turbo_cable_view_helpers.rb
|
48
53
|
- lib/render_turbo_stream/version.rb
|
49
54
|
- lib/tasks/render_turbo_stream_tasks.rake
|
50
55
|
homepage: https://gitlab.com/sedl/renderturbostream
|