render_turbo_stream 4.0.3 → 4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7a06cc371f6543af918f87ee1d80f4c3e4c9640f10bc69b540d98ee1e5e7e20
4
- data.tar.gz: 69112643c6597fc51fd669d48b467bebcf100bb690f3028775cd661b72ce1568
3
+ metadata.gz: 35bd786f43a61b85aa26d790277b3e912687f4831abc9abcc677e936e5b978f2
4
+ data.tar.gz: 511c55b6ad3e503d76bb5f2aefa1f9d85fbffed996bc7e304e94944b78a75fcd
5
5
  SHA512:
6
- metadata.gz: a8790ae754ac41af06d4d375fd205eae8316c0b05551eace0c3aabe56572f7e91cd505aa40d9671d6856339468342319564bd1feea1815011cc3c097af499838
7
- data.tar.gz: 671730ab4d5df1918b05bd4a768336878f9d93a3cc0c43610359dd3847f85e7fd141cb6fbf99cfe6edae934afa247fa9fbb3db3d18106a02639b2a8b64478573
6
+ metadata.gz: 5955c95a112371c9bd890d03ce16288ab484c3bccd5c36b74d532cfc1e73993426c6f1d61f9665e7ff474ae45b760478c2c15f90bce82d7ccfcf590e4f248a74
7
+ data.tar.gz: 829ffda44d7e230c314cec9b29d1617833983fdba23a1422bde8e5c28f0bfde7fb098733fa6ef85f06bfc41605e4afab8028eefe930a231f620fa504602e837f
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  2021 DHH annouced a great milestone in web development with [Rails 7, "Fulfilling a Vision"](https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a-vision).
4
4
 
5
- To say it up front: If you want to have all the benefits of Turbo without disturbing the handy default Rails workflow, you must use WebSockets sometimes, which are well integrated in Turbo, see [README Turbo::StreamsChannel](https://gitlab.com/sedl/renderturbostream/-/blob/main/README-channels.md). But the starting point is here. And I recommend that you download my [Quick-and-dirty test project](https://gitlab.com/sedl/renderturbostream_railsapp), set it up, see all the tests succeed, and then read through this README.
5
+ This gem has a second [README Turbo::StreamsChannel](https://gitlab.com/sedl/renderturbostream/-/blob/main/README-channels.md). Starting point is here. And I recommend that you download my [Quick-and-dirty test project](https://gitlab.com/sedl/renderturbostream_railsapp), set it up, see all the tests succeed, and then read through this README.
6
6
 
7
7
  Defining templates like `(create|update).turbo_stream.haml` is a heavy mix of logic and view. This gem separates logic and view so that `*.turbo_stream.*` templates are no longer necessary and the logic can stay on the ruby side.
8
8
 
@@ -137,8 +137,8 @@ module RenderTurboStream
137
137
 
138
138
  if_success_redirect_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 ON THE SAME RESPONSE https://github.com/rails/rails/issues/48056
139
139
 
140
- if_success: nil, # hash for a partial to render or array with actions (as array) or hashes for partials within
141
- if_error: nil, # additional partials that should be rendered if save_action failed
140
+ if_success_add: nil, # hash for a partial to render or array with actions (as array) or hashes for partials within
141
+ if_error_add: nil, # additional partials that should be rendered if save_action failed
142
142
  add: [], # additional streams
143
143
 
144
144
  if_success_notices: nil, # array of strings, override default generated flash generation in the case of success
@@ -171,8 +171,8 @@ module RenderTurboStream
171
171
  )[:turbo_actions]
172
172
 
173
173
  turbo_actions += libs.additional_actions(
174
- if_success,
175
- if_error,
174
+ if_success_add,
175
+ if_error_add,
176
176
  add
177
177
  )
178
178
 
@@ -17,8 +17,8 @@ module RenderTurboStream
17
17
  action: 'replace', # options: append, prepend
18
18
  locals: {}, # locals used by the target_id
19
19
 
20
- if_success: nil, # hash for a partial to render or array with actions (as array) or hashes for partials within
21
- if_error: nil, # additional partials that should be rendered if save_action failed
20
+ if_success_add: nil, # hash for a partial to render or array with actions (as array) or hashes for partials within
21
+ if_error_add: nil, # additional partials that should be rendered if save_action failed
22
22
  add: [], # additional streams
23
23
 
24
24
  if_success_notices: nil, # array of strings, override default generated flash generation in the case of success
@@ -59,8 +59,8 @@ module RenderTurboStream
59
59
  streams += flashes[:turbo_actions]
60
60
 
61
61
  streams += libs.additional_actions(
62
- if_success,
63
- if_error,
62
+ if_success_add,
63
+ if_error_add,
64
64
  add
65
65
  )
66
66
 
@@ -89,9 +89,9 @@ module RenderTurboStream
89
89
  { turbo_actions: turbo_actions, alerts: alerts, notices: notices }
90
90
  end
91
91
 
92
- def additional_actions( if_success, if_error, add )
92
+ def additional_actions( if_success_add, if_error_add, add )
93
93
 
94
- (@save_action ? make_actions(if_success) : make_actions(if_error)) + make_actions(add)
94
+ (@save_action ? make_actions(if_success_add) : make_actions(if_error_add)) + make_actions(add)
95
95
 
96
96
  end
97
97
 
@@ -127,7 +127,7 @@ module RenderTurboStream
127
127
  private
128
128
 
129
129
  # streamline actions to array
130
- # valid inputs for if_success or if_error or add
130
+ # valid inputs for if_success_add or if_error_add or add
131
131
  # [:add_css_class, ...]
132
132
  # [[:add_css_class, ..], ..]
133
133
  # {target_id: '..', ..}
@@ -151,6 +151,9 @@ module RenderTurboStream
151
151
  if a.is_a?(Hash) && a.key?(:target_id)
152
152
  a = a.merge(target: "##{a[:target_id]}")
153
153
  a.delete(:target_id)
154
+ unless a.key?(:action)
155
+ a[:action] = :replace
156
+ end
154
157
  a
155
158
  else
156
159
  a
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "4.0.3"
2
+ VERSION = "4.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_turbo_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.3
4
+ version: 4.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian
@@ -24,12 +24,12 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.3
27
- description: 'It brings TurboStreams and TurboStreams::Channel together in a unified
28
- workflow with one testing strategy. It separates logic and views: All partial handling
29
- can be controlled directly from the controller. No need to write *.turbo_stream.*
30
- templates. A normal partial can be sent in any way. Execution of javascript actions
31
- can be done directly from the controller. Demo project with all this built in along
32
- with system and request tests is available.'
27
+ description: This gem brings a set of helpers that allow a unified workflow for TurboStream
28
+ and TurboStreams::Channel and allow a complete and detailed testing strategy. To
29
+ avoid a heavy view and logic mix inside *.turbo_stream.* templates, this allows
30
+ to completely separate view and logic and control all templates and partials directly
31
+ from the controller. Javascript actions can also be executed directly from the controller.
32
+ A demo project with all this built in along with system and request tests is available.
33
33
  email:
34
34
  - christian@sedlmair.ch
35
35
  executables: []