render_turbo_stream 1.4.12 → 1.4.14

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: 344d9c5276c13acd3cbde921821be8d224befaca25d1492af766c45cb80f7993
4
- data.tar.gz: b7a86cd99b8d5808590c5ed14032f8275c3ae284e90e9682c5b4c2b8dcec332e
3
+ metadata.gz: c2c84aacdaefecd60e436ebd13e68801e87d02d3318ded429a643605b2ec94a3
4
+ data.tar.gz: 1b6089600ec4abe349d2cae88a1802f258a535e2303f9289cc29ec0e7c09bf66
5
5
  SHA512:
6
- metadata.gz: ee892284af2df779af7051f5e8c3f8132595657997429b1ba0d6a8585460a5ed087620c1c5182a786fe5a96c56f6968fc9c192db826f95a00b76a2d6d3ca14a7
7
- data.tar.gz: b74f6487ea7f28a854b98d088e547b80ab67cfb2bbfd1bb62dab24d9d36f2f6b78a42b7e1e78f95ff8c91930632a87fd37a3f3a9d8275b2a418b8a650931435e
6
+ metadata.gz: 83b71f6a084d9da96a09d710bc64c46506a424a8d704838ed0b91b54853cf799d3c1c336c2059bfd23f8ec70581f850c87341bbc03419efe2627c762fee94ff3
7
+ data.tar.gz: a623f4b6acf363a224adfbf4e4e246bec3fcd3f3cc267452ee66bb8bdd6067d0c50a94de45611edbd1640ab25c567d05a9a4853d24d2fbe885a8e2427c336454
@@ -0,0 +1,4 @@
1
+ module RenderTurboStream
2
+ class CableStream < ApplicationRecord
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ class CableStreams < ActiveRecord::Migration[7.0]
2
+ def change
3
+ end
4
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "1.4.12"
2
+ VERSION = "1.4.14"
3
3
  end
@@ -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
- # render_turbo_stream(streams)
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.12
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-25 00:00:00.000000000 Z
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