render_turbo_stream 0.1.13 → 0.1.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: 9de1041648648938b0c80d1c55e0e4b891528efbe92d1a80e063db1408d33934
4
- data.tar.gz: 11078d44a6e593b4409a4110e2bb99574f1b09bf487c890a929902d5a43550fe
3
+ metadata.gz: c53012e599712119f8dce38d60478187e1c472e35dc72667b57ce2c4fd6ff6af
4
+ data.tar.gz: 7151a27c089c6cc312b4dcd3dd3e3b89d3fc9c775c9d484f04e82fae68d32e48
5
5
  SHA512:
6
- metadata.gz: 801afcaa11485be7be69514166552910ede01a3a00d26899780935e29d53c9201f4d502ad214065935fd2b0f0699b9f5ccb71e6d78baf03495f8dd80c2e154a9
7
- data.tar.gz: d3aee9bd2741bf7c6596fa5e8156aed73260ed47a9487b5a26e75b798f5eeb0108be1dac23a683e0055ae3edb28d47a3054531c41836a4008f9eb9cf351cca54
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.13"
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.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian