render_turbo_stream 0.1.13 → 0.1.15

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: 9de1041648648938b0c80d1c55e0e4b891528efbe92d1a80e063db1408d33934
4
- data.tar.gz: 11078d44a6e593b4409a4110e2bb99574f1b09bf487c890a929902d5a43550fe
3
+ metadata.gz: 6b14cca0fede85f072fa0c0fd6e854067a48a6842c37bf1cc25a767202b9cd44
4
+ data.tar.gz: 5f68d9d74db8da5da80ea51ce2427fc9c7863748ce19b214e3885f34197cd746
5
5
  SHA512:
6
- metadata.gz: 801afcaa11485be7be69514166552910ede01a3a00d26899780935e29d53c9201f4d502ad214065935fd2b0f0699b9f5ccb71e6d78baf03495f8dd80c2e154a9
7
- data.tar.gz: d3aee9bd2741bf7c6596fa5e8156aed73260ed47a9487b5a26e75b798f5eeb0108be1dac23a683e0055ae3edb28d47a3054531c41836a4008f9eb9cf351cca54
6
+ metadata.gz: 5f54ca6c438da2e9b426a113c3793af72598ce200161b8f87f7252fb6e2378239541eeb8b0a1c56345e4bda4f8fc9107c26dc2c0fb371ef5d5966dfe4f9c64f5
7
+ data.tar.gz: 15172f63ecb115b722f11fd0a1a43ce4bcc7a884d4abc065cf9d53dbe60487ab43650e96970a038acd7360e58e2e6453867be6b623fbe2e235c8095e25ec8462
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.13"
2
+ VERSION = "0.1.15"
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.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian
@@ -26,8 +26,8 @@ dependencies:
26
26
  version: 7.0.4.3
27
27
  description: 'Writing views like (create|update).turbo_stream.haml annoyed me. This
28
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.'
29
+ You can control turbo-stream partials directly from the controller. It also handles
30
+ redirection: turbo_power is included.'
31
31
  email:
32
32
  - christian@sedlmair.ch
33
33
  executables: []