simple_form_localized_input 0.0.1 → 1.0.0

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: fb7065b19696dd0f1fc6e50f8a6efae963f4ed48
4
- data.tar.gz: a8637ea82106761fc158c15489a5b1cc654b2bd4
3
+ metadata.gz: 6a993b9ab984adcefc71611db08fc9cae39c0a67
4
+ data.tar.gz: fd8dbd80d812f5f1eb4d9e9bbca2a6371c447cff
5
5
  SHA512:
6
- metadata.gz: 0170634a864749040e863a03f1e0a2400b3a0986b231c2a546770269af0bd42ffbee2302ca8259ee2cc154155aeb929f90a05188ffef98e6c0b4ee8755b7fc23
7
- data.tar.gz: b1022fd54d5f61e769a2d015409d9ce9e5dab1858415c9aff53b7af74b0c35ee88298ee7917ff1a975d819fab7e150a9c6143e8537dd8cfcde0e5cc52f39813b
6
+ metadata.gz: cfd228d0ff476e6664ad3f650dc332fb6b85b8f5f1e68a837ab130c4d6f06b927e1a9ae255507dcfaa975d6f5f16c91ca4c7eec77c18736487c42986ebdf6c1d
7
+ data.tar.gz: c7f32e24d3888654ec6a32ccb3cd30a5f8153d38f3c6ca82488fd6c81867c062e35c7e8801051319fa46ea66c9ed10aa764dd3a0e97580178ee0b0739f77210d
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Simple Form Localized Input
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/simple_form_localized_input.svg)](http://badge.fury.io/rb/simple_form_localized_input)
4
+
3
5
  [Simple Form](https://github.com/plataformatec/simple_form) custom input which renders a field for multiple locales in one form. Designed to be used with [Mongoid](https://github.com/mongoid/mongoid).
4
6
 
5
7
  ## Installation
@@ -18,6 +20,15 @@ Or install it yourself as:
18
20
 
19
21
  ## Usage
20
22
 
23
+ In your model:
24
+
25
+ ```Ruby
26
+ class MyModel
27
+ include Mongoid::Document
28
+ field :title, type: String, localize: true
29
+ end
30
+ ```
31
+
21
32
  In your simple form:
22
33
 
23
34
  ```Ruby
@@ -28,7 +39,7 @@ This works with inputs of various types, and you can pass options to an input as
28
39
 
29
40
  ## Contributing
30
41
 
31
- 1. Fork it ( https://github.com/[my-github-username]/simple_form_localized_input/fork )
42
+ 1. Fork it ( https://github.com/tomasc/simple_form_localized_input/fork )
32
43
  2. Create your feature branch (`git checkout -b my-new-feature`)
33
44
  3. Commit your changes (`git commit -am 'Add some feature'`)
34
45
  4. Push to the branch (`git push origin my-new-feature`)
@@ -1,2 +1,2 @@
1
- require 'simple_form_localized_input/simple_form_localized_input'
2
- require 'simple_form_localized_input/version'
1
+ require 'simple_form_localized_input/form_builder'
2
+ require 'simple_form_localized_input/version'
@@ -0,0 +1,28 @@
1
+ require 'simple_form'
2
+
3
+ module SimpleFormLocalizedInput
4
+ module FormBuilder
5
+
6
+ def self.included(base)
7
+ base.class_eval do
8
+ def localized_input attribute_name, options={}
9
+ simple_fields_for "#{attribute_name}_translations", OpenStruct.new(object.send("#{attribute_name}_translations")) do |f|
10
+ ::I18n.available_locales.collect do |loc|
11
+ f.input loc.to_sym, options.merge(
12
+ {
13
+ collection: (options[:collection_translations] ? options[:collection_translations][loc.to_s] : options[:collection]),
14
+ label: [object.class.human_attribute_name(attribute_name), "(#{loc})"].reject(&:blank?).join(' ')
15
+ }
16
+ )
17
+ end.join.html_safe
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ # ---------------------------------------------------------------------
24
+
25
+ end
26
+ end
27
+
28
+ SimpleForm::FormBuilder.send :include, SimpleFormLocalizedInput::FormBuilder
@@ -1,3 +1,3 @@
1
1
  module SimpleFormLocalizedInput
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_form_localized_input
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2015-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simple_form
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mongoid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '4.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.6'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.6'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Custom input for Simple Form that renders Mongoid fields for multiple
@@ -74,13 +74,13 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
- - .gitignore
77
+ - ".gitignore"
78
78
  - Gemfile
79
79
  - LICENSE
80
80
  - README.md
81
81
  - Rakefile
82
82
  - lib/simple_form_localized_input.rb
83
- - lib/simple_form_localized_input/simple_form_localized_input.rb
83
+ - lib/simple_form_localized_input/form_builder.rb
84
84
  - lib/simple_form_localized_input/version.rb
85
85
  - simple_form_localized_input.gemspec
86
86
  homepage: https://github.com/tomasc/simple_form_localized_input
@@ -93,19 +93,18 @@ require_paths:
93
93
  - lib
94
94
  required_ruby_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
- - - '>='
96
+ - - ">="
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  requirements: []
105
105
  rubyforge_project:
106
- rubygems_version: 2.1.10
106
+ rubygems_version: 2.4.8
107
107
  signing_key:
108
108
  specification_version: 4
109
109
  summary: Custom input for Simple Form that renders Mongoid fields for multiple locales.
110
110
  test_files: []
111
- has_rdoc:
@@ -1,22 +0,0 @@
1
- module SimpleFormLocalizedInput
2
- class Builder < SimpleForm::FormBuilder
3
-
4
- # ---------------------------------------------------------------------
5
-
6
- def localized_input attribute_name, options={}
7
- simple_fields_for "#{attribute_name}_translations", OpenStruct.new(object.send("#{attribute_name}_translations")) do |f|
8
- I18n.available_locales.collect do |loc|
9
- f.input loc.to_sym, options.merge(
10
- {
11
- collection: (options[:collection_translations] ? options[:collection_translations][loc.to_s] : options[:collection]),
12
- label: [object.class.human_attribute_name(attribute_name), "(#{loc})"].reject(&:blank?).join(' ')
13
- }
14
- )
15
- end.join.html_safe
16
- end
17
- end
18
-
19
- # ---------------------------------------------------------------------
20
-
21
- end
22
- end