render_turbo_stream 1.4.3 → 1.4.4

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: 740e9df76f8c575bc3a993c3bc3ad524d70e1a4593c21906ca41d16dc426399b
4
- data.tar.gz: 6ea17ebf4b85712130b3b5289cecffcf76d043cb6d1638bfa68f27c7d1aa7494
3
+ metadata.gz: ab99348bf3118d88b5b5d1ae6bb12eca5c3b2a433c53ce8d7777a7519130f69c
4
+ data.tar.gz: 57958c45f249bab4fb1c1d4c118a5a30db4956f2991c04bca9ac36b50739e78f
5
5
  SHA512:
6
- metadata.gz: 4dd54e9153f44bc4e6104132d75f1b7ad9613569f8f2c49c5b0a44711aacb6eac92c0c77a82bec52b82491b3450010fcffc581221340d5510c0f87bcf2650b74
7
- data.tar.gz: e337836ec7353f535236f6e9aac1b7aa4c514d3eb370464bfb6cc7499f32b41c3501c89146a864781b15ba6145d2849439fb91564676f9a0b3a2b197ea686455
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.3"
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,9 +143,9 @@ 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(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.is_a?(Hash)
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('/'))
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.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian