render_turbo_stream 4.3.13 → 4.3.14

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: 74c586fc8f14f7f8c158b25c3cb0d548e9ebbacc77a3e6327beae1aff722bf4a
4
- data.tar.gz: dfba23e8a945c98873e6d27c377382a6bddaf4948b97990471908a379a986871
3
+ metadata.gz: a7cdf1b3f0af6bf441e0c0d08919985aaa0a83ef49671724860cdb8e6ff45521
4
+ data.tar.gz: 23e55905c875439a1203a970fca7a9f72bde401de75d886849ed604213d05db6
5
5
  SHA512:
6
- metadata.gz: 70d324640d87e5c29887b3bf0e19a0a0a5e5c72081983a827a9cfcb2f86943c48d42f0ff10f6b1e9010cbdca5e29067d82c61ce45c41300bdd6bdf09fafaf39d
7
- data.tar.gz: 937778d9f95feff150b9af5b1a3581cc73fbc2613e33a187046a11c85363e6bf166cc6ab1f6237307f6cc0ef3256d318cdb595492729afbbade9e5742c456db1
6
+ metadata.gz: 1bfed3d855085bbd4834b5cce5fa13351e3fac306082172b8cc78525c677515b66de762b2291b08c2c25321e5b7c2e52e245560e465e27bb8ff5154029307189
7
+ data.tar.gz: d7d0257d9b7210c5f1516cd7fee00765942d6222b32e4ec9338d4c2f452e2ffcce432a7242208045acd7c49fcffedcbdfe7ccabb979fb1b51c7da843fdc5b9db
data/README.md CHANGED
@@ -17,8 +17,6 @@ Has a testing strategy.
17
17
  An overview of how we design a rails-7 application with turbo
18
18
  is [published on dev.to](https://dev.to/chmich/rails-7-vite-wrapping-up-1pia).
19
19
 
20
- Hope it helps :)
21
-
22
20
  **Chris**
23
21
 
24
22
  ## Installation
@@ -45,7 +43,7 @@ Create a Initializer
45
43
  ActionView::Base.send :include, RenderTurboStream::ViewHelpers
46
44
  ```
47
45
 
48
- spec/rails_helper.rb (We are using rspec instead of minitest)
46
+ spec/rails_helper.rb (for rspec)
49
47
 
50
48
  ```ruby
51
49
  RSpec.configure do |config|
@@ -67,6 +65,10 @@ Required Configurations for Flash Partial
67
65
 
68
66
  # In case of redirection a flash cannot be sent by TurboStream
69
67
  config.x.render_turbo_stream.allow_channel_to_me_for_turbo_stream_save = true
68
+
69
+ config.x.render_turbo_stream.store_last_saved_object = true # default: false
70
+ # saves the last successful saved record into session['last_saved_object'] as global_id
71
+ # this can be accessed by view_helper #last_saved_object
70
72
  ```
71
73
 
72
74
  For the latter you have to setup channels, see below.
@@ -183,7 +183,11 @@ module RenderTurboStream
183
183
  raise libs.action_errors(turbo_actions).join(', ')
184
184
  end
185
185
 
186
- unless save_action
186
+ if save_action
187
+ if Rails.configuration.x.store_last_saved_object && object.id
188
+ session['last_saved_object'] = object.to_global_id
189
+ end
190
+ else
187
191
  RenderTurboStream::Libs.debug_save_errors(object, flash_controller_action_name)
188
192
  end
189
193
 
@@ -65,7 +65,11 @@ module RenderTurboStream
65
65
  raise libs.action_errors(streams).join(', ')
66
66
  end
67
67
 
68
- unless save_action
68
+ if save_action
69
+ if Rails.configuration.x.store_last_saved_object && object.id
70
+ session['last_saved_object'] = object.to_global_id
71
+ end
72
+ else
69
73
  response.status = 422
70
74
  RenderTurboStream::Libs.debug_save_errors(object, flash_controller_action_name)
71
75
  end
@@ -171,9 +175,8 @@ module RenderTurboStream
171
175
 
172
176
  end
173
177
 
174
-
175
178
  def stream_partial(partial, id: nil, action: :replace, locals: {})
176
- render_turbo_stream([{partial: partial, locals: locals, id: id, action: action}])
179
+ render_turbo_stream([{ partial: partial, locals: locals, id: id, action: action }])
177
180
  end
178
181
 
179
182
  end
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "4.3.13"
2
+ VERSION = "4.3.14"
3
3
  end
@@ -16,5 +16,9 @@ module RenderTurboStream
16
16
  libs.target_id(virt_path, obj)
17
17
  end
18
18
 
19
+ def last_saved_object
20
+ GlobalID::Locator.locate(session[:last_saved_object])
21
+ end
22
+
19
23
  end
20
24
  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.3.13
4
+ version: 4.3.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian