render_turbo_stream 4.0.5 → 4.1.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 +4 -4
- data/README.md +11 -8
- data/lib/render_turbo_stream/controller_helpers.rb +4 -4
- data/lib/render_turbo_stream/controller_libs.rb +2 -28
- data/lib/render_turbo_stream/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eb1342913ea7534aac8145b4de214534576e55e17d8dce89d935c2e80d32aac
|
4
|
+
data.tar.gz: 2e4ac7cc3f18ba8549af29963d0130d01b390656453f467841720b03ac75a297
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1ea181eea942f225631d35a0351da9cfa4b57ddd8d576e283a1f103cd0d5cd72a60aab4774c8721fe441c7353f82391bd04096612ce378132c04afd4016a6ed
|
7
|
+
data.tar.gz: 4f0a4432bf2a0c2e075318a64975f9fdf63cd508e6dad81adb26f999aab1bc4223cf7bc26b6b097d08357565392ee1a5e94c280b8e81ec25a3d755755a49b848
|
data/README.md
CHANGED
@@ -67,15 +67,18 @@ The corresponding partials for flashes could look [like this](https://gitlab.com
|
|
67
67
|
```
|
68
68
|
en:
|
69
69
|
activerecord:
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
70
|
+
render_turbo_stream_success:
|
71
|
+
create: '%<model_name>s successfully created'
|
72
|
+
update: '%<model_name>s successfully updated'
|
73
|
+
destroy: '%<model_name>s successfully destroyed'
|
74
|
+
render_turbo_stream_errors:
|
75
|
+
create: '%<model_name>s could not be created'
|
76
|
+
update: '%<model_name>s could not be updated'
|
77
|
+
destroy: '%<model_name>s could not be destroyed'
|
77
78
|
```
|
78
79
|
|
80
|
+
The last key (e.g. `update`) marks the controller action.
|
81
|
+
|
79
82
|
Model name translations, see: Rails Docs.
|
80
83
|
|
81
84
|
**Turbo power**
|
@@ -167,7 +170,7 @@ If this config is set to true, Turbo::StreamsChannel is installed and a current
|
|
167
170
|
|
168
171
|
If an `if_success_redirect_to` argument is provided and the save action was successful, `turbo_stream_save` would send the partials by channel.
|
169
172
|
|
170
|
-
# Testing
|
173
|
+
# Request Testing
|
171
174
|
|
172
175
|
To test if the whole system works together, including javascript actions, so that finally a part reaches the surface, there is **Capybara** system testing. But it is a good practice to **break tests into smaller pieces**. So, there are helpers for **enabling the much faster request tests that are much easier to maintain**.
|
173
176
|
|
@@ -97,10 +97,10 @@ module RenderTurboStream
|
|
97
97
|
c_libs = RenderTurboStream::ChannelLibs.new(response)
|
98
98
|
c_libs.send_actions_to_channel("authenticated-user-#{helpers.current_user.id}", streams, @render_turbo_stream_evaluate_instance_variables)
|
99
99
|
else
|
100
|
-
flash[:alert] =
|
101
|
-
flash[:notice] =
|
102
|
-
Rails.logger.debug(" • Set flash[:alert] => #{
|
103
|
-
Rails.logger.debug(" • Set flash[:notice] => #{
|
100
|
+
flash[:alert] = flashes[:alerts]
|
101
|
+
flash[:notice] = flashes[:notices]
|
102
|
+
Rails.logger.debug(" • Set flash[:alert] => #{flashes[:alerts]}") if flashes[:alerts].present?
|
103
|
+
Rails.logger.debug(" • Set flash[:notice] => #{flashes[:notices]}") if flashes[:notices].present?
|
104
104
|
end
|
105
105
|
redirect_to if_success_redirect_to
|
106
106
|
|
@@ -18,22 +18,9 @@ module RenderTurboStream
|
|
18
18
|
if @save_action
|
19
19
|
notices = if if_success_notices
|
20
20
|
if_success_notices
|
21
|
-
elsif controller_action.to_sym == :create
|
22
|
-
str = I18n.t(
|
23
|
-
'activerecord.success.successfully_created',
|
24
|
-
default: '%<model_name>s successfully created'
|
25
|
-
)
|
26
|
-
[format(str, model_name: model_name)]
|
27
|
-
elsif controller_action.to_sym == :update
|
28
|
-
str = I18n.t(
|
29
|
-
'activerecord.success.successfully_updated',
|
30
|
-
default: '%<model_name>s successfully updated'
|
31
|
-
)
|
32
|
-
[format(str, model_name: model_name)]
|
33
21
|
else
|
34
22
|
str = I18n.t(
|
35
|
-
"activerecord.
|
36
|
-
default: '%<model_name>s successfully updated'
|
23
|
+
"activerecord.render_turbo_stream_success.#{controller_action}"
|
37
24
|
)
|
38
25
|
[format(str, model_name: model_name)]
|
39
26
|
end
|
@@ -41,22 +28,9 @@ module RenderTurboStream
|
|
41
28
|
else
|
42
29
|
alerts = if if_error_alerts
|
43
30
|
if_error_alerts
|
44
|
-
elsif controller_action.to_sym == :create
|
45
|
-
str = I18n.t(
|
46
|
-
'activerecord.errors.messages.could_not_create',
|
47
|
-
default: '%<model_name>s could not be created'
|
48
|
-
)
|
49
|
-
[format(str, model_name: model_name)]
|
50
|
-
elsif controller_action.to_sym == :update
|
51
|
-
str = I18n.t(
|
52
|
-
'activerecord.errors.messages.could_not_update',
|
53
|
-
default: '%<model_name>s could not be updated'
|
54
|
-
)
|
55
|
-
[format(str, model_name: model_name)]
|
56
31
|
else
|
57
32
|
str = I18n.t(
|
58
|
-
"activerecord.
|
59
|
-
default: '%<model_name>s could not be updated'
|
33
|
+
"activerecord.render_turbo_stream_errors.#{controller_action}"
|
60
34
|
)
|
61
35
|
[format(str, model_name: model_name)]
|
62
36
|
end
|
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: 4.
|
4
|
+
version: 4.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,12 +24,12 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 7.0.3
|
27
|
-
description:
|
28
|
-
and
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
description: A set of helpers that allow a unified workflow for TurboStream and TurboStreams::Channel
|
28
|
+
and a testing strategy. To avoid a heavy view and logic mix inside *.turbo_stream.*
|
29
|
+
templates, partials and templates can be rendered directly from the controller.
|
30
|
+
There is no need to write *.turbo_stream.* templates anymore. Javascript actions
|
31
|
+
can also be executed directly from the controller. A demo project with all this
|
32
|
+
built in, along with system and request tests, is linked in the README.
|
33
33
|
email:
|
34
34
|
- christian@sedlmair.ch
|
35
35
|
executables: []
|