render_turbo_stream 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/app/views/render_turbo_stream.turbo_stream.erb +1 -1
- data/lib/render_turbo_stream/version.rb +1 -1
- data/lib/render_turbo_stream.rb +17 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab99348bf3118d88b5b5d1ae6bb12eca5c3b2a433c53ce8d7777a7519130f69c
|
4
|
+
data.tar.gz: 57958c45f249bab4fb1c1d4c118a5a30db4956f2991c04bca9ac36b50739e78f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 725ca7fb7f726dbb70c796ed8438ebf74ea63310055188c635bd94d59f5297f99c974d44677fc8b7bf2d033c07960fcc5ccb7c68cf1a0ebbbe5d868b0c9f2af4
|
7
|
+
data.tar.gz: 7d2639a7744be4b9f9e28a620a7d2c55adedc7a2948b197ef4ced797d2ff585041cb9ffba61b72a55c87766fc803581098b7ad65595708dd76378d80e39b69e5
|
data/README.md
CHANGED
@@ -78,7 +78,7 @@ A comprehensive tutorial on turbo and how to check that it is working properly c
|
|
78
78
|
def update
|
79
79
|
turbo_stream_save(
|
80
80
|
@customer.update(customer_params),
|
81
|
-
|
81
|
+
turbo_redirect_on_success_to: edit_customer_path(@customer),
|
82
82
|
)
|
83
83
|
end
|
84
84
|
```
|
@@ -139,6 +139,10 @@ render_turbo_stream(
|
|
139
139
|
|
140
140
|
Under the hood, inside a `*.turbo_stream.erb` template, it does the following: `= turbo_stream.send args.first, *(args[1..-1])`
|
141
141
|
|
142
|
+
**WORKAROUND for redirects inside frame**
|
143
|
+
|
144
|
+
How to handle a classical redirect_to, together with a flash message, within a frame for a CRUD controller? see [workaround](https://gitlab.com/sedl/renderturbostream/-/issues/3)
|
145
|
+
|
142
146
|
**Parameters for turbo_stream_save**
|
143
147
|
|
144
148
|
save_action,
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<% if args.is_a?(Array) %>
|
8
8
|
|
9
9
|
<% ctl = "turbo_stream.#{args.first}, #{args[1..-1].join(', ')}" %>
|
10
|
-
<% Rails.logger.
|
10
|
+
<% Rails.logger.debug(" RENDER TURBO STREAM => #{ctl}") %>
|
11
11
|
<%= turbo_stream.send args.first, *(args[1..-1]) %>
|
12
12
|
|
13
13
|
|
data/lib/render_turbo_stream.rb
CHANGED
@@ -8,10 +8,10 @@ module RenderTurboStream
|
|
8
8
|
|
9
9
|
def turbo_stream_save(
|
10
10
|
save_action,
|
11
|
-
redirect_on_success_to: nil, # does a regular redirect. Works if you are inside a turbo_frame and just want to redirect inside that frame
|
11
|
+
redirect_on_success_to: nil, # does a regular redirect. Works if you are inside a turbo_frame and just want to redirect inside that frame BUT CANNOT STREAM OTHERS ACTIONS AT SAME TIME https://github.com/rails/rails/issues/48056
|
12
12
|
turbo_redirect_on_success_to: nil, # does a full page redirect (break out of all frames by turbo_power redirect)
|
13
13
|
object: nil, # object used in save_action, example: @customer
|
14
|
-
id:
|
14
|
+
id: nil, # if nil: no partial is rendered
|
15
15
|
partial: nil, # example: 'customers/form' default: "#{controller_path}/#{id}"
|
16
16
|
action: 'replace', # options: append, prepend
|
17
17
|
locals: {}, # locals used by the partial
|
@@ -47,7 +47,15 @@ module RenderTurboStream
|
|
47
47
|
|
48
48
|
if save_action
|
49
49
|
response.status = 200
|
50
|
-
|
50
|
+
Rails.logger.debug('start loop')
|
51
|
+
streams_on_success.each do |s|
|
52
|
+
Rails.logger.debug('inside loop')
|
53
|
+
if s.is_a?(Array)
|
54
|
+
streams.push(s)
|
55
|
+
elsif s.is_a?(Hash) && s[:id].present?
|
56
|
+
streams.push(s)
|
57
|
+
end
|
58
|
+
end
|
51
59
|
else
|
52
60
|
response.status = :unprocessable_entity
|
53
61
|
streams += streams_on_error.select { |s| s[:id].present? }
|
@@ -135,9 +143,9 @@ module RenderTurboStream
|
|
135
143
|
])
|
136
144
|
elsif save_action && redirect_on_success_to.present?
|
137
145
|
response.status = 302
|
138
|
-
flash
|
139
|
-
flash
|
140
|
-
render_turbo_stream(streams)
|
146
|
+
flash[:alert] = flash_alerts
|
147
|
+
flash[:notice] = flash_notices
|
148
|
+
# render_turbo_stream(streams)
|
141
149
|
redirect_to redirect_on_success_to
|
142
150
|
|
143
151
|
else
|
@@ -151,7 +159,9 @@ module RenderTurboStream
|
|
151
159
|
|
152
160
|
ary = []
|
153
161
|
array.each do |pr|
|
154
|
-
if pr.
|
162
|
+
if !pr.present?
|
163
|
+
a=1
|
164
|
+
elsif pr.is_a?(Hash)
|
155
165
|
props = pr.symbolize_keys
|
156
166
|
part = (props[:partial].present? ? props[:partial] : props[:id]).gsub('-', '_')
|
157
167
|
partial = (part.to_s.include?('/') ? part : [controller_path, part].join('/'))
|