simple_form_localized_input 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38e238539e753672ccd4affe7d069ce2ed9308b6
|
4
|
+
data.tar.gz: 2a75204938310a24d390d7e88a4b4ff0983289af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1c65a3e08e79119d53ad6141bcddea89088fea54da081bcc3d4536d5162806097cba2008afcd39bfeff8bce287f7e5bbd8af3a898d35cccfc77be5759811157
|
7
|
+
data.tar.gz: c183470ac22f475779f35dc96c6efdec30504833c2b75ce21820acbdc71eba6cb3b5ffa4a3b3a9f2d63874c69f9f82670721819e85187eb3311180cafbe62845
|
@@ -2,26 +2,26 @@ require 'simple_form'
|
|
2
2
|
|
3
3
|
module SimpleFormLocalizedInput
|
4
4
|
module FormBuilder
|
5
|
+
include SimpleForm::Helpers::Validators
|
5
6
|
|
6
7
|
def self.included(base)
|
7
8
|
base.class_eval do
|
8
|
-
def localized_input
|
9
|
-
|
9
|
+
def localized_input(attribute_name, options = {})
|
10
|
+
field_name = [attribute_name, 'translations'].join('_')
|
11
|
+
field_value = OpenStruct.new(object.send(field_name))
|
12
|
+
|
13
|
+
simple_fields_for(field_name, field_value) do |fields|
|
10
14
|
::I18n.available_locales.collect do |loc|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
)
|
15
|
+
collection = options[:collection_translations] ? options[:collection_translations][loc.to_s] : options[:collection]
|
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) }
|
18
|
+
|
19
|
+
fields.input(loc.to_sym, options.merge(collection: collection, label: label, required: required))
|
17
20
|
end.join.html_safe
|
18
21
|
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
22
|
-
|
23
|
-
# ---------------------------------------------------------------------
|
24
|
-
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -4,23 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'simple_form_localized_input/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'simple_form_localized_input'
|
8
8
|
spec.version = SimpleFormLocalizedInput::VERSION
|
9
9
|
spec.authors = ["Tomáš Celizna"]
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
10
|
+
spec.email = ['tomas.celizna@gmail.com']
|
11
|
+
spec.summary = 'Custom input for Simple Form that renders Mongoid fields for multiple locales.'
|
12
|
+
spec.description = 'Custom input for Simple Form that renders Mongoid fields for multiple locales.'
|
13
|
+
spec.homepage = 'https://github.com/tomasc/simple_form_localized_input'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency 'simple_form', '>= 3.0.2'
|
22
|
+
spec.add_dependency 'mongoid', '>= 4.0', '< 6.0'
|
23
23
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
26
|
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.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomáš Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|