render_turbo_stream 0.1.12 → 0.1.14

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: aa9b9cefa95d380af39fd2f096f569cb4eabe94fe024164722cae8497b7d076f
4
- data.tar.gz: 9973fe128954730c6b1dc9f52ecc63a6b633951d118f06eae0e2672c54a519d2
3
+ metadata.gz: c53012e599712119f8dce38d60478187e1c472e35dc72667b57ce2c4fd6ff6af
4
+ data.tar.gz: 7151a27c089c6cc312b4dcd3dd3e3b89d3fc9c775c9d484f04e82fae68d32e48
5
5
  SHA512:
6
- metadata.gz: 1738911b840851ed5d3974702bea36029f8bcb453786b5524bef7c1f2fee0ee78dccfc0f275e8e5f72b724f787425aa13f821c7c251c5ad92876c5c728b2bad5
7
- data.tar.gz: 6be68eb76a040ab06fb97380d80d03ce16e55096819062a5c8760604a5d9df5808ba1c72229afe7a9807e9ec6c6e69a305b17be2a94ed110eae4ec8461c148cd
6
+ metadata.gz: a648d90c84cc4e40e9360ce99aaf16b2e230111631ee04afacb4b0346bea3d318753655bb7af7e505c8a7d9617962cb5f64a3091ff6d4ec43fcc571506086607
7
+ data.tar.gz: ba138cb22413010ef0f60a52dedf74deaa27a2dd49dc48d4741315f449fabe34527102d4fe9cfb79c6241beedfc29b11b15776a688a876e3395b4ca42f9c7e1b
data/README.md CHANGED
@@ -1,14 +1,10 @@
1
1
  # RenderTurboStream
2
2
 
3
- The machine gun for your turbo-stream partials.
3
+ Defining templates like `(create|update).turbo_stream.haml` annoyed me.
4
4
 
5
- Creating a gem from this is in work, see [rails issue](https://github.com/rails/rails/issues/47954)
5
+ Working consistently with turbo_stream means shooting lots of partials from the backend to the frontend, which always needs the same attributes: ID, partial, and maybe some locals. This gem serializes that: Partials can be controlled directly from the controller.
6
6
 
7
- Defining templates like `update.turbo_stream.haml` annoyed me.
8
-
9
- Working consistently by turbo_stream means: shooting many partials to the frontend which always needs the same attributes: ID, partial and maybe some locals. This gem serializes that: Partials can be steered directly from the controller.
10
-
11
- Currently it is only possible by copy and paste the code, see below.
7
+ It sets the status, generates a flash message, handles redirection, pushes it all to the front and prepares a response for request-specs.
12
8
 
13
9
  ## Installation
14
10
 
@@ -20,12 +16,20 @@ gem 'render_turbo_stream'
20
16
  bundle install
21
17
  ```
22
18
 
23
- **ApplicationController**
19
+ ApplicationController
24
20
 
25
21
  ```ruby
26
22
  include RenderTurboStream
27
23
  ```
28
24
 
25
+ necessary configs for flash partials
26
+
27
+ ```ruby
28
+ config.x.render_turbo_stream.flash_partial = 'layouts/flash'
29
+ config.x.render_turbo_stream.flash_id = 'flash-box'
30
+ config.x.render_turbo_stream.flash_action = 'prepend'
31
+ ```
32
+
29
33
  The corresponding partials for flashes could look [like this](https://gitlab.com/sedl/renderturbostream/-/wikis/flashes)
30
34
 
31
35
  ## Usage
@@ -150,20 +154,6 @@ example value: `"%<model_name>s successfully created"`
150
154
 
151
155
  .. and Model Name Translations
152
156
 
153
- **Flash configuration**
154
-
155
- Flash messages are pushed as arrays into `flash[:alert]`, `flash.now[:alert]`, `flash[:notice]` or `flash.now[:notice]`
156
-
157
- The corresponding partial has to be configured by
158
-
159
- `config.x.render_turbo_stream.flash_partial` #=> example: `layouts/flashes`
160
-
161
- and a corresponding html-ID for pushing the partial to the right destination inside the layout
162
-
163
- `config.x.render_turbo_stream.flash_id` #=> example: `flash-wrapper`
164
-
165
- `config.x.render_turbo_stream.flash_action` #=> example: 'prepend'
166
-
167
157
  ## Contributing
168
158
 
169
159
  Contribution welcome.
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.14"
3
3
  end
@@ -57,21 +57,38 @@ module RenderTurboStream
57
57
  flash_notices = if flashes_on_success.present?
58
58
  flashes_on_success
59
59
  elsif action_name == 'create'
60
- [format(I18n.t('activerecord.success.successfully_created'), model_name: model_name)]
60
+ str = I18n.t(
61
+ 'activerecord.success.successfully_created',
62
+ default: '%<model_name>s successfully created'
63
+ )
64
+ [format(str, model_name: model_name)]
61
65
  elsif action_name == 'update'
62
- [format(I18n.t('activerecord.success.successfully_updated'), model_name: model_name)]
66
+ str = I18n.t(
67
+ 'activerecord.success.successfully_updated',
68
+ default: '%<model_name>s successfully updated'
69
+ )
70
+ [format(str, model_name: model_name)]
63
71
  end
64
72
  flash_alerts = []
65
73
  else
66
74
  flash_alerts = if flashes_on_error.present?
67
75
  flashes_on_error
68
76
  elsif action_name == 'create'
69
- [format(I18n.t('activerecord.errors.messages.could_not_create'), model_name: model_name)]
77
+ str = I18n.t(
78
+ 'activerecord.errors.messages.could_not_create',
79
+ default: '%<model_name>s could not be created'
80
+ )
81
+ [format(str, model_name: model_name)]
70
82
  elsif action_name == 'update'
71
- [format(I18n.t('activerecord.errors.messages.could_not_update'), model_name: model_name)]
83
+ str = I18n.t(
84
+ 'activerecord.errors.messages.could_not_update',
85
+ default: '%<model_name>s could not be updated'
86
+ )
87
+ [format(str, model_name: model_name)]
72
88
  end
73
89
  flash_notices = []
74
90
  end
91
+
75
92
  flash_notices += add_flash_notices
76
93
  flash_alerts += add_flash_alerts
77
94
  _flash_id = Rails.configuration.x.render_turbo_stream.flash_id
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: 0.1.12
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian
@@ -25,9 +25,9 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 7.0.4.3
27
27
  description: 'Writing views like (create|update).turbo_stream.haml annoyed me. This
28
- gem handles translated flash messages, set status and renders turbo-stream partials.
29
- You can steer your turbo-stream partials directly from the contoller. It also handles
30
- redirection: turbo_power is included.'
28
+ gem handles translated flash messages, sets status, and renders turbo-stream partials.
29
+ You can control your turbo-stream partials directly from the controller. It also
30
+ handles redirection: turbo_power is included.'
31
31
  email:
32
32
  - christian@sedlmair.ch
33
33
  executables: []