effective_bootstrap 1.14.12 → 1.14.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -0
- data/app/models/effective/form_input.rb +40 -16
- data/app/models/effective/table_builder.rb +3 -2
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c79b3e0f8e491e05ac28f6fe0630f669f3ced789b5137ed76fac5ba9e5bc2149
|
4
|
+
data.tar.gz: f50ff44c62e6b68098f5210361933ff1eb0fcb0c2d3c67c4cdd5296cb6b8fe37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52236956016cb32d8d35b3a4a22a88a5255696bc19a0f4b08e7e789fe3726e7fd84062b7d132e55a05b86ab30bf7bbeecc14f411113305a3543a2699d7a95a59
|
7
|
+
data.tar.gz: d116da97f759170fe2b718e429d1125ebfa339acb8863a4afd49a001746edd22e2c3bad37d5126154222382e4a16bb39d028c9d88410f70b89d8bf238f867d6c
|
data/README.md
CHANGED
@@ -697,6 +697,21 @@ The `f.save` is purely a input submit button.
|
|
697
697
|
= f.save 'Save 2'
|
698
698
|
```
|
699
699
|
|
700
|
+
## Internationalization
|
701
|
+
|
702
|
+
The form builder will use labels and hints based on your current localization, if present
|
703
|
+
|
704
|
+
To use these, just assign the activemodel attributes values to your strings
|
705
|
+
|
706
|
+
en:
|
707
|
+
activerecord:
|
708
|
+
models:
|
709
|
+
thing: 'Thing'
|
710
|
+
attributes:
|
711
|
+
thing:
|
712
|
+
title: 'Good Title'
|
713
|
+
title_hint: 'please make this title really good'
|
714
|
+
|
700
715
|
## Table Builder
|
701
716
|
|
702
717
|
Use `effective_table_with(resource)` to intelligently output a table of attributes for a resource.
|
@@ -766,6 +781,7 @@ You can specify `only:` and `except:` and use `f.content_for` to override a row
|
|
766
781
|
|
767
782
|
All values flow through to i18n and can be overriden, same as the form labels, in the locale .yml file.
|
768
783
|
|
784
|
+
|
769
785
|
## License
|
770
786
|
|
771
787
|
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
@@ -140,20 +140,7 @@ module Effective
|
|
140
140
|
return BLANK if options[:label] == false
|
141
141
|
return BLANK if name.kind_of?(NilClass)
|
142
142
|
|
143
|
-
text = options[:label].delete(:text)
|
144
|
-
name_to_s = name.to_s
|
145
|
-
|
146
|
-
text ||= (
|
147
|
-
if object && name_to_s.ends_with?('_id')
|
148
|
-
object.class.human_attribute_name(name_to_s.chomp('_id'))
|
149
|
-
elsif object && name_to_s.ends_with?('_ids')
|
150
|
-
object.class.human_attribute_name(name_to_s.chomp('_ids').pluralize)
|
151
|
-
elsif object
|
152
|
-
object.class.human_attribute_name(name)
|
153
|
-
else
|
154
|
-
BLANK
|
155
|
-
end
|
156
|
-
)
|
143
|
+
text = options[:label].delete(:text) || build_human_label()
|
157
144
|
|
158
145
|
if options[:input][:id]
|
159
146
|
options[:label][:for] = options[:input][:id]
|
@@ -162,19 +149,56 @@ module Effective
|
|
162
149
|
@builder.label(name, text.html_safe, options[:label])
|
163
150
|
end
|
164
151
|
|
152
|
+
def build_human_label
|
153
|
+
name = self.name.to_s
|
154
|
+
|
155
|
+
label = if object && name.ends_with?('_id')
|
156
|
+
object.class.human_attribute_name(name.chomp('_id'))
|
157
|
+
elsif object && name.ends_with?('_ids')
|
158
|
+
object.class.human_attribute_name(name.chomp('_ids').pluralize)
|
159
|
+
elsif object
|
160
|
+
object.class.human_attribute_name(name)
|
161
|
+
else
|
162
|
+
BLANK
|
163
|
+
end
|
164
|
+
|
165
|
+
label
|
166
|
+
end
|
167
|
+
|
165
168
|
def build_input(&block)
|
166
169
|
capture(&block)
|
167
170
|
end
|
168
171
|
|
169
172
|
def build_hint
|
170
|
-
return BLANK
|
173
|
+
return BLANK if options[:label] == false
|
174
|
+
return BLANK if name.kind_of?(NilClass)
|
171
175
|
|
172
176
|
tag = options[:hint].delete(:tag)
|
173
|
-
text = options[:hint].delete(:text)
|
177
|
+
text = options[:hint].delete(:text) || build_human_hint()
|
178
|
+
return BLANK unless text.present?
|
174
179
|
|
175
180
|
content_tag(tag, text.html_safe, options[:hint])
|
176
181
|
end
|
177
182
|
|
183
|
+
def build_human_hint
|
184
|
+
name = self.name.to_s
|
185
|
+
|
186
|
+
key = if object && name.ends_with?('_id')
|
187
|
+
"activerecord.attributes.#{object.model_name.i18n_key}.#{name.chomp('_id')}_hint"
|
188
|
+
elsif object && name.ends_with?('_ids')
|
189
|
+
"activerecord.attributes.#{object.model_name.i18n_key}.#{name.chomp('_ids').pluralize}_hint"
|
190
|
+
elsif object
|
191
|
+
"activerecord.attributes.#{object.model_name.i18n_key}.#{name}_hint"
|
192
|
+
end
|
193
|
+
|
194
|
+
return nil if key.blank?
|
195
|
+
|
196
|
+
hint = ::I18n.t(key)
|
197
|
+
return nil if hint.include?(key) # missing translation
|
198
|
+
|
199
|
+
hint
|
200
|
+
end
|
201
|
+
|
178
202
|
def build_feedback
|
179
203
|
return BLANK if options[:feedback] == false
|
180
204
|
|
@@ -35,6 +35,7 @@ module Effective
|
|
35
35
|
filtered = filter_parameters
|
36
36
|
|
37
37
|
content = rows.merge(content_fors)
|
38
|
+
|
38
39
|
content = content.slice(*only) if only.present?
|
39
40
|
content = content.except(*except) if except.present?
|
40
41
|
content = content.except(*filtered) if filtered.present?
|
@@ -168,11 +169,11 @@ module Effective
|
|
168
169
|
rows[name] = TableRows::PriceField.new(name, options, builder: self).to_html
|
169
170
|
end
|
170
171
|
|
171
|
-
def save(name, options = {})
|
172
|
+
def save(name = nil, options = {})
|
172
173
|
# Nothing to do
|
173
174
|
end
|
174
175
|
|
175
|
-
def submit(name, options = {}, &block)
|
176
|
+
def submit(name = nil, options = {}, &block)
|
176
177
|
# Nothing to do
|
177
178
|
end
|
178
179
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.14.
|
4
|
+
version: 1.14.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|