shoelace-rails 0.6.0 → 0.6.2
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 +4 -4
- data/CHANGELOG.md +18 -2
- data/app/helpers/shoelace/form_helper.rb +4 -4
- data/lib/shoelace/rails/version.rb +1 -1
- data/test/helpers/translation_test.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ead8cbfce57323de6e03b0b4dc638eac355b3a9e7495747a17aaf79682e81ed
|
4
|
+
data.tar.gz: 9c84316ec90e6a29fb270b3d0c56d9dbc93b947c51aab3fa3c07bac5620f4399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511f5b435164a36c9fe094ebdc905d05c3759cf469ec9559b9fd437171291b3b0b07361ecc674d120ed5b59b0683044582f1d5726c50f05df0e57ff972a185fc
|
7
|
+
data.tar.gz: 74f6c3f146f2aea79e9cce672c36840c4f416adf6ea14748dbfdf63ca0c92bbb1ad9041407df6ca91c93fd0334e6cb12e2e038fcb18d3eb13cdd970413459262
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,24 @@
|
|
1
|
-
## v0.6.
|
1
|
+
## v0.6.2
|
2
|
+
|
3
|
+
#### 🐞Bug Fixes
|
4
|
+
|
5
|
+
- Fixes a bug where form builders fail to render when it falls back to humanize the given method name
|
6
|
+
|
7
|
+
## [v0.6.1](https://github.com/yuki24/shoelace-rails/tree/v0.6.1)
|
8
|
+
|
9
|
+
_<sup>released at 2024-03-13 03:05:20 UTC</sup>_
|
10
|
+
|
11
|
+
#### 🐞Bug Fixes
|
12
|
+
|
13
|
+
- Fixes a bug where form builders fail to render with a string `:as` option
|
14
|
+
|
15
|
+
## [v0.6.0](https://github.com/yuki24/shoelace-rails/tree/v0.6.0)
|
16
|
+
|
17
|
+
_<sup>released at 2024-03-13 02:54:02 UTC</sup>_
|
2
18
|
|
3
19
|
#### ⭐️ Features
|
4
20
|
|
5
|
-
- Add the ability to use translations with form helpers
|
21
|
+
- Add the ability to use translations with form helpers ([<tt>626f271</tt>](https://github.com/yuki24/shoelace-rails/commit/626f271ca710dd48040907ff6a99e3bba6c5d57c))
|
6
22
|
|
7
23
|
## [v0.5.0](https://github.com/yuki24/shoelace-rails/tree/v0.5.0)
|
8
24
|
|
@@ -57,7 +57,7 @@ module Shoelace
|
|
57
57
|
options = @options.stringify_keys
|
58
58
|
options["value"] = options.fetch("value") { value_before_type_cast }
|
59
59
|
add_default_name_and_id(options)
|
60
|
-
label = options.delete('label').presence || @method_name.humanize
|
60
|
+
label = options.delete('label').presence || @method_name.to_s.humanize
|
61
61
|
|
62
62
|
@template_object.content_tag('sl-switch', label, options, &block)
|
63
63
|
end
|
@@ -124,7 +124,7 @@ module Shoelace
|
|
124
124
|
options = @options.stringify_keys
|
125
125
|
options["value"] = @checked_value
|
126
126
|
options["checked"] = true if input_checked?(options)
|
127
|
-
label = options.delete("label") || @method_name.humanize
|
127
|
+
label = options.delete("label") || @method_name.to_s.humanize
|
128
128
|
|
129
129
|
if options["multiple"]
|
130
130
|
add_default_name_and_id_for_value(@checked_value, options)
|
@@ -183,7 +183,7 @@ module Shoelace
|
|
183
183
|
html_options = @html_options.stringify_keys
|
184
184
|
html_options["value"] = value
|
185
185
|
add_default_name_and_id(html_options)
|
186
|
-
html_options["label"] = @options[:label].presence || @method_name.humanize
|
186
|
+
html_options["label"] = @options[:label].presence || @method_name.to_s.humanize
|
187
187
|
|
188
188
|
@template_object.content_tag('sl-radio-group', html_options) { super(&block) }
|
189
189
|
end
|
@@ -270,7 +270,7 @@ module Shoelace
|
|
270
270
|
private
|
271
271
|
|
272
272
|
def label_text(method, tag_value = nil)
|
273
|
-
::ActionView::Helpers::Tags::Label::LabelBuilder.new(@template, object_name, method, object, tag_value).translation
|
273
|
+
::ActionView::Helpers::Tags::Label::LabelBuilder.new(@template, object_name.to_s, method.to_s, object, tag_value).translation
|
274
274
|
end
|
275
275
|
end
|
276
276
|
|
@@ -34,6 +34,24 @@ class TranslationTest < ActionView::TestCase
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
test "Form helpers should cast symbol object names to String" do
|
38
|
+
sl_form_for(User.new, as: :user, url: "/") do |form|
|
39
|
+
assert_dom_equal <<~HTML, form.text_field(:name)
|
40
|
+
<sl-input label="Full Name" type="text" name="user[name]" id="user_name"></sl-input>
|
41
|
+
HTML
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
test "Form helpers should fall back to the humanize method when there is no matching translation" do
|
46
|
+
I18n.backend.reload!
|
47
|
+
|
48
|
+
sl_form_for(OpenStruct.new, as: :user, url: "/") do |form|
|
49
|
+
assert_dom_equal <<~HTML, form.text_field(:name_eq)
|
50
|
+
<sl-input label="Name eq" type="text" name="user[name_eq]" id="user_name_eq"></sl-input>
|
51
|
+
HTML
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
37
55
|
test "#color_field should respect label translations" do
|
38
56
|
sl_form_for(User.new, url: "/") do |form|
|
39
57
|
assert_dom_equal <<~HTML, form.color_field(:name)
|