simple_form_localized_input 1.0.6 → 1.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/simple_form_localized_input/form_builder.rb +18 -4
- data/lib/simple_form_localized_input/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4f06f9b3bc8a0486acb4b858349de9b5793479ae62d86acf9116ecc87c09f2f
|
4
|
+
data.tar.gz: 844d7474f3e2ca281118e89c7592596d99346af7fa3feeb48d9376bea5ceac61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5f3eb296d531f7671581505fdf68933c9fd133e8043848e5a70d0e46f9f74de96e9bfea26177b22c78fe0458abd62dc30ddc2a5c019d624b7a114bf522db9a8
|
7
|
+
data.tar.gz: 8e1b602ea9adb65622de02008fc96587f5509d0a4bc14225dbdb8773d779ddf3a31a9c1e3fba2ca4541bb85e07fd8f9f8660ed72e4716486d44b4a63590d32a3
|
data/CHANGELOG.md
CHANGED
@@ -14,16 +14,30 @@ module SimpleFormLocalizedInput
|
|
14
14
|
::I18n.available_locales.collect do |loc|
|
15
15
|
collection = options[:collection_translations] ? options[:collection_translations][loc.to_s] : options[:collection]
|
16
16
|
label = [object.class.human_attribute_name(attribute_name), "(#{loc})"].reject(&:blank?).join(' ')
|
17
|
-
required = object.class.validators_on(attribute_name).any?
|
17
|
+
required = object.class.validators_on(attribute_name).any? do |v|
|
18
|
+
v.kind == :presence &&
|
19
|
+
valid_validator?(v) &&
|
20
|
+
valid_localized_presence_validator?(v, loc)
|
21
|
+
end
|
18
22
|
|
19
23
|
fields.input(loc.to_sym, options.merge(collection: collection, label: label, required: required))
|
20
24
|
end.join.html_safe
|
21
|
-
end +
|
22
|
-
|
25
|
+
end + error(attribute_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def valid_localized_presence_validator?(validator, locale)
|
31
|
+
in_option = validator.options.fetch(:in, nil)
|
32
|
+
with_option = validator.options.fetch(:with, nil)
|
33
|
+
return true unless in_option.present? || with_option.present?
|
34
|
+
|
35
|
+
with_option = ::I18n.default_locale if with_option == :default_locale
|
36
|
+
Array(in_option || with_option).map(&:to_s).include?(locale.to_s)
|
23
37
|
end
|
24
38
|
end
|
25
39
|
end
|
26
40
|
end
|
27
41
|
end
|
28
42
|
|
29
|
-
SimpleForm::FormBuilder.send
|
43
|
+
SimpleForm::FormBuilder.send(:include, SimpleFormLocalizedInput::FormBuilder)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form_localized_input
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
version: '0'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.7.
|
147
|
+
rubygems_version: 2.7.6
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: Custom input for Simple Form that renders Mongoid fields for multiple locales.
|