render_turbo_stream 3.0.4 → 3.0.5
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 +13 -8
- data/lib/render_turbo_stream/controller_helpers.rb +2 -2
- data/lib/render_turbo_stream/version.rb +1 -1
- 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: c984de11f7923f03531f0b53b0a4224bd3c56520f75bc4e92e16292c9e2a9e86
|
4
|
+
data.tar.gz: 184129722f704f61599a022f3ef6bb7306c3b7d1f74a5770a666cac9835e5839
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5983031570c67f03c85ae84341d51bfd6cbb76f2f1e5b1543f2434cc6d133edbcdbd25205c6162b55bdacaa7531c79a411f397c65695598b76096e1395c54182
|
7
|
+
data.tar.gz: e672f2427971215dada8b1b3b6047a6331e0c0e39f7c1b5166f2fe2992e35cbc03dc94fb7d39abcc2f1091d20f650d3b0ad6b2720fa4f66b4476810b2865785f
|
data/README.md
CHANGED
@@ -51,22 +51,27 @@ Required Configurations for Flash Partial
|
|
51
51
|
config.x.render_turbo_stream.flash_partial = 'layouts/flash'
|
52
52
|
config.x.render_turbo_stream.flash_id = 'flash-box'
|
53
53
|
config.x.render_turbo_stream.flash_action = 'prepend'
|
54
|
-
config.x.render_turbo_stream.
|
54
|
+
config.x.render_turbo_stream.allow_channel_for_turbo_stream_save = true
|
55
55
|
```
|
56
56
|
|
57
|
+
For the latter you have to setup channels, see below.
|
58
|
+
|
57
59
|
The corresponding partials for flashes could look [like this](https://gitlab.com/sedl/renderturbostream/-/wikis/Flashes-example)
|
58
60
|
|
59
61
|
**Translations**
|
60
62
|
|
61
63
|
```
|
62
|
-
|
63
|
-
activerecord
|
64
|
-
|
65
|
-
|
64
|
+
en:
|
65
|
+
activerecord:
|
66
|
+
success:
|
67
|
+
successfully_created: '%<model_name>s successfully created'
|
68
|
+
successfully_updated: '%<model_name>s successfully updated'
|
69
|
+
errors:
|
70
|
+
messages:
|
71
|
+
could_not_create: '%<model_name>s could not be created'
|
72
|
+
could_not_update: '%<model_name>s could not be updated'
|
66
73
|
```
|
67
74
|
|
68
|
-
example value: `"%<model_name>s successfully created"`
|
69
|
-
|
70
75
|
Model name translations, see: Rails Docs.
|
71
76
|
|
72
77
|
**Turbo power**
|
@@ -156,7 +161,7 @@ Suppose you have a CRUD controller that should do all its actions inside a turbo
|
|
156
161
|
There are two workarounds:
|
157
162
|
|
158
163
|
```ruby
|
159
|
-
config.x.render_turbo_stream.
|
164
|
+
config.x.render_turbo_stream.allow_channel_for_turbo_stream_save = true
|
160
165
|
```
|
161
166
|
|
162
167
|
With this config, the `turbo_stream_save` method will send flash messages through `Turbo::StreamsChannel` (if installed as described above) to a channel to the currently logged in user in parallel with the redirect.
|
@@ -2,7 +2,7 @@ module RenderTurboStream
|
|
2
2
|
module ControllerHelpers
|
3
3
|
|
4
4
|
# Handles translated flash messages as defined in translations and configs.
|
5
|
-
# If :redirect_on_success_to and channel set up and
|
5
|
+
# If :redirect_on_success_to and channel set up and allow_channel_for_turbo_stream_save are configured, sends flash message by channel_to_me.
|
6
6
|
# you can add more stream actions to the same response
|
7
7
|
|
8
8
|
def turbo_stream_save(
|
@@ -155,7 +155,7 @@ module RenderTurboStream
|
|
155
155
|
])
|
156
156
|
elsif save_action && redirect_on_success_to.present?
|
157
157
|
response.status = 302
|
158
|
-
if (Rails.configuration.x.render_turbo_stream.
|
158
|
+
if (Rails.configuration.x.render_turbo_stream.allow_channel_for_turbo_stream_save rescue false) && (helpers.current_user.id.present? rescue false)
|
159
159
|
streams.each do |s|
|
160
160
|
next unless s.is_a?(Hash)
|
161
161
|
Rails.logger.debug(" • Send by Cable => «#{s}»")
|