simple_form_localized_input 1.0.6 → 1.0.7

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: d180d37d8bacb98f09fa3c36c8528a2b959bb39581de67ef3c1713242bcdbe92
4
- data.tar.gz: eade120d5c9be5ad3c1d53c484d0f6592e8f6104452ffd8b42576772be986e6c
3
+ metadata.gz: e4f06f9b3bc8a0486acb4b858349de9b5793479ae62d86acf9116ecc87c09f2f
4
+ data.tar.gz: 844d7474f3e2ca281118e89c7592596d99346af7fa3feeb48d9376bea5ceac61
5
5
  SHA512:
6
- metadata.gz: 3afe79a300bc234ffdd8b8f241aa6c3fcca017714d47509f369ba100b4cbce27621ed5b2d04dd489b7cf842d5bf0a93200c157a9c089b3a51df554689075e9d3
7
- data.tar.gz: '083e16c915fdd290fa0e4d4c7107583020dbafc7317aa6e2084373531b43b0b59e48e5bc64840ab63bc9ddaacd36f2fec193950c29f71cafcc6d012b789c03b3'
6
+ metadata.gz: a5f3eb296d531f7671581505fdf68933c9fd133e8043848e5a70d0e46f9f74de96e9bfea26177b22c78fe0458abd62dc30ddc2a5c019d624b7a114bf522db9a8
7
+ data.tar.gz: 8e1b602ea9adb65622de02008fc96587f5509d0a4bc14225dbdb8773d779ddf3a31a9c1e3fba2ca4541bb85e07fd8f9f8660ed72e4716486d44b4a63590d32a3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.0.7
4
+
5
+ * add support for `LocalizedPresenceValidator`
6
+
3
7
  ## 1.0.6
4
8
 
5
9
  * Mongoid 7
@@ -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? { |v| v.kind == :presence && valid_validator?(v) }
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
- error(attribute_name)
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 :include, SimpleFormLocalizedInput::FormBuilder
43
+ SimpleForm::FormBuilder.send(:include, SimpleFormLocalizedInput::FormBuilder)
@@ -1,3 +1,3 @@
1
1
  module SimpleFormLocalizedInput
2
- VERSION = '1.0.6'.freeze
2
+ VERSION = '1.0.7'.freeze
3
3
  end
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.6
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-05-03 00:00:00.000000000 Z
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.3
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.