render_turbo_stream 1.4.2 → 1.4.4

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: cf65f7ac19c9387a4ee6a42f9e2227082ec7996aef74e672cc45aa04f75becf7
4
- data.tar.gz: 558ecbee422b8eab39c292f82ae0df3df54cc5b439b0e8a7b83008dc863e00ec
3
+ metadata.gz: ab99348bf3118d88b5b5d1ae6bb12eca5c3b2a433c53ce8d7777a7519130f69c
4
+ data.tar.gz: 57958c45f249bab4fb1c1d4c118a5a30db4956f2991c04bca9ac36b50739e78f
5
5
  SHA512:
6
- metadata.gz: 11549d8a9b8145ca04e7e025516a74edbeeb726bfa9d3bfca0fa819c2d8bf76da7d354c860ec01ec461b4d50b80e0fb197aaf34b30502b1d29d72718982cf149
7
- data.tar.gz: 8405143aeae7793da5011b56e5993843dac2f0f97c5d0cce712d5fac0eca5a1e4045dd7680b72db76f6c5c761dd35f7f3fa24fb71e029dbde6bda8b49b140281
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
- redirect_on_success_to: edit_customer_path(@customer),
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.error(" RENDER TURBO STREAM => #{ctl}") %>
10
+ <% Rails.logger.debug(" RENDER TURBO STREAM => #{ctl}") %>
11
11
  <%= turbo_stream.send args.first, *(args[1..-1]) %>
12
12
 
13
13
 
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.4"
3
3
  end
@@ -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: 'form', # if nil: no partial is rendered
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
- streams += streams_on_success.select { |s| s[:id].present? }
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,14 +143,10 @@ module RenderTurboStream
135
143
  ])
136
144
  elsif save_action && redirect_on_success_to.present?
137
145
  response.status = 302
138
- flash.now[:alert] = flash_alerts
139
- flash.now[:notice] = flash_notices
140
- render_turbo_stream([
141
- [
142
- :redirect_to,
143
- turbo_redirect_on_success_to
144
- ]
145
- ])
146
+ flash[:alert] = flash_alerts
147
+ flash[:notice] = flash_notices
148
+ # render_turbo_stream(streams)
149
+ redirect_to redirect_on_success_to
146
150
 
147
151
  else
148
152
  flash.now[:alert] = flash_alerts
@@ -155,7 +159,9 @@ module RenderTurboStream
155
159
 
156
160
  ary = []
157
161
  array.each do |pr|
158
- if pr.is_a?(Hash)
162
+ if !pr.present?
163
+ a=1
164
+ elsif pr.is_a?(Hash)
159
165
  props = pr.symbolize_keys
160
166
  part = (props[:partial].present? ? props[:partial] : props[:id]).gsub('-', '_')
161
167
  partial = (part.to_s.include?('/') ? part : [controller_path, part].join('/'))
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: 1.4.2
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian