render_turbo_stream 3.0.3 → 3.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: 14a45858fbfebd69a6546511f25a1c46566a8f4911c788ea52b76538132748a6
4
- data.tar.gz: f87599a585edcbc7393a6e06749afb6dd7e1bcfcba5a899b8ad0c09223edc63d
3
+ metadata.gz: c984de11f7923f03531f0b53b0a4224bd3c56520f75bc4e92e16292c9e2a9e86
4
+ data.tar.gz: 184129722f704f61599a022f3ef6bb7306c3b7d1f74a5770a666cac9835e5839
5
5
  SHA512:
6
- metadata.gz: 37b4458882a14d7e50f186a725b7b9a5b14a2da0d452bfba41d24fd2c73cebff9e1c2de4f8f951af71c6ca5f089bb29c5caa66ac3e9140030f43cc394065d27a
7
- data.tar.gz: cc3fd5383fab67929924353fbd41280dd07b9588fb38317cb2bd5c0eb13c26524ec84742126afbe4756b28fe2ee446aaac78941ea9a76f86f6927cbe9ef20a70
6
+ metadata.gz: 5983031570c67f03c85ae84341d51bfd6cbb76f2f1e5b1543f2434cc6d133edbcdbd25205c6162b55bdacaa7531c79a411f397c65695598b76096e1395c54182
7
+ data.tar.gz: e672f2427971215dada8b1b3b6047a6331e0c0e39f7c1b5166f2fe2992e35cbc03dc94fb7d39abcc2f1091d20f650d3b0ad6b2720fa4f66b4476810b2865785f
data/README.md CHANGED
@@ -2,13 +2,11 @@
2
2
 
3
3
  DHH made a milestone in web development with [Rails 7, "Fulfilling a Vision"](https://rubyonrails.org/2021/12/15/Rails-7-fulfilling-a-vision). This gem is my contribution to that bold new step. The goal is to have a complete rails like workflow.
4
4
 
5
- Defining templates like `(create|update).turbo_stream.haml` annoyed me. Because it is a heavy mix of logic and view. Working consistently with turbo_stream or Turbo Streams Channel means shooting a lot of partials from the backend to the frontend. There are many ways and tedious details to handle redirects since Turbo! This all can be streamlined.
5
+ Defining templates like `(create|update).turbo_stream.haml` annoyed me. Because it is a heavy mix of logic and view. Working consistently with turbo_stream or Turbo Streams Channel means shooting a lot of partials from the backend to the frontend. And there are many ways and tedious details to handle redirects since Turbo! This can all be streamlined.
6
6
 
7
7
  Execute [turbo_power](https://github.com/marcoroth/turbo_power) commands such as adding a css class to an html element, pushing a state to the browser history, or running custom javascript actions through Turbo Stream can be written in pure ruby code. No need for embeds like `.html.erb`.
8
8
 
9
- Logic to ruby, view to views and the area between for the gem! And with specific testings for the Ruby side.
10
-
11
- This gem is in a early state.
9
+ Logic to Ruby, views to views, and the space in between for the gem! And all this together with a testing strategy for the Ruby side.
12
10
 
13
11
  An overview of how we design a rails-7 application with turbo
14
12
  is [published on dev.to](https://dev.to/chmich/rails-7-vite-wrapping-up-1pia).
@@ -53,22 +51,27 @@ Required Configurations for Flash Partial
53
51
  config.x.render_turbo_stream.flash_partial = 'layouts/flash'
54
52
  config.x.render_turbo_stream.flash_id = 'flash-box'
55
53
  config.x.render_turbo_stream.flash_action = 'prepend'
56
- config.x.render_turbo_stream.use_channel_for_turbo_stream_save = true
54
+ config.x.render_turbo_stream.allow_channel_for_turbo_stream_save = true
57
55
  ```
58
56
 
57
+ For the latter you have to setup channels, see below.
58
+
59
59
  The corresponding partials for flashes could look [like this](https://gitlab.com/sedl/renderturbostream/-/wikis/Flashes-example)
60
60
 
61
61
  **Translations**
62
62
 
63
63
  ```
64
- activerecord.success.successfully_created
65
- activerecord.success.successfully_updated
66
- activerecord.errors.messages.could_not_create
67
- activerecord.errors.messages.could_not_update
64
+ en:
65
+ activerecord:
66
+ success:
67
+ successfully_created: '%<model_name>s successfully created'
68
+ successfully_updated: '%<model_name>s successfully updated'
69
+ errors:
70
+ messages:
71
+ could_not_create: '%<model_name>s could not be created'
72
+ could_not_update: '%<model_name>s could not be updated'
68
73
  ```
69
74
 
70
- example value: `"%<model_name>s successfully created"`
71
-
72
75
  Model name translations, see: Rails Docs.
73
76
 
74
77
  **Turbo power**
@@ -158,7 +161,7 @@ Suppose you have a CRUD controller that should do all its actions inside a turbo
158
161
  There are two workarounds:
159
162
 
160
163
  ```ruby
161
- config.x.render_turbo_stream.use_channel_for_turbo_stream_save = true
164
+ config.x.render_turbo_stream.allow_channel_for_turbo_stream_save = true
162
165
  ```
163
166
 
164
167
  With this config, the `turbo_stream_save` method will send flash messages through `Turbo::StreamsChannel` (if installed as described above) to a channel to the currently logged in user in parallel with the redirect.
@@ -2,7 +2,7 @@ module RenderTurboStream
2
2
  module ControllerHelpers
3
3
 
4
4
  # Handles translated flash messages as defined in translations and configs.
5
- # If :redirect_on_success_to and channel set up and use_channel_for_turbo_stream_save are configured, sends flash message by channel_to_me.
5
+ # If :redirect_on_success_to and channel set up and allow_channel_for_turbo_stream_save are configured, sends flash message by channel_to_me.
6
6
  # you can add more stream actions to the same response
7
7
 
8
8
  def turbo_stream_save(
@@ -155,7 +155,7 @@ module RenderTurboStream
155
155
  ])
156
156
  elsif save_action && redirect_on_success_to.present?
157
157
  response.status = 302
158
- if (Rails.configuration.x.render_turbo_stream.use_channel_for_turbo_stream_save rescue false) && (helpers.current_user.id.present? rescue false)
158
+ if (Rails.configuration.x.render_turbo_stream.allow_channel_for_turbo_stream_save rescue false) && (helpers.current_user.id.present? rescue false)
159
159
  streams.each do |s|
160
160
  next unless s.is_a?(Hash)
161
161
  Rails.logger.debug(" • Send by Cable => «#{s}»")
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "3.0.3"
2
+ VERSION = "3.0.5"
3
3
  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: 3.0.3
4
+ version: 3.0.5
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-10 00:00:00.000000000 Z
11
+ date: 2023-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 7.0.4.3
19
+ version: 7.0.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.4.3
26
+ version: 7.0.3
27
27
  description: Handles translated flash messages, sets status and renders partials via
28
28
  Turbo Stream or Turbo::StreamsChannel directly from the controller. No need to write
29
29
  *.turbo_stream.* templates. Together with the turbo_power gem or custom turbo_stream