simple_form_auto_select2 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ffe697ce639a9508875c0df9fed05f3869566397
4
+ data.tar.gz: 8a8241ffebd3f4d83080c8f311a38a0f072dcae7
5
+ SHA512:
6
+ metadata.gz: 35151725eeff8c74571e33de2d84626d3badd55084d49ac1d3575d17c457640e18f0b8d481eb1c9514f5fc812d2033e18243ba9c399e9a9a46f13bc5c99d0d2d
7
+ data.tar.gz: ae2e9efd2eded98a231042e0b0b104fc7fc36400ee1b9e8f69642dd7c5ceae95573bf5d34d0ac2d5678314d7958be897df18060b76320be4bcc2445f7cc0f2b4
data/.gitignore ADDED
@@ -0,0 +1,31 @@
1
+ *.rbc
2
+ capybara-*.html
3
+ .rspec
4
+ /log
5
+ /tmp
6
+ /db/*.sqlite3
7
+ /public/system
8
+ /coverage/
9
+ /spec/tmp
10
+ **.orig
11
+ rerun.txt
12
+ pickle-email-*.html
13
+
14
+ # TODO Comment out these rules if you are OK with secrets being uploaded to the repo
15
+ config/initializers/secret_token.rb
16
+ config/secrets.yml
17
+
18
+ ## Environment normalisation:
19
+ /.bundle
20
+ /vendor/bundle
21
+
22
+ # these should all be checked in to normalise the environment:
23
+ # Gemfile.lock, .ruby-version, .ruby-gemset
24
+
25
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
26
+ .rvmrc
27
+
28
+ # if using bower-rails ignore default bower_components path bower.json files
29
+ /vendor/assets/bower_components
30
+ *.bowerrc
31
+ bower.json
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ simple_form_auto_select2
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="rbenv: 1.9.3-p0" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/simple_form_auto_select2.iml" filepath="$PROJECT_DIR$/.idea/simple_form_auto_select2.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
@@ -0,0 +1,50 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="CompassSettings">
4
+ <option name="compassSupportEnabled" value="true" />
5
+ </component>
6
+ <component name="FacetManager">
7
+ <facet type="gem" name="Ruby Gem">
8
+ <configuration>
9
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
10
+ <option name="GEM_APP_TEST_PATH" value="" />
11
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
12
+ </configuration>
13
+ </facet>
14
+ </component>
15
+ <component name="NewModuleRootManager">
16
+ <content url="file://$MODULE_DIR$" />
17
+ <orderEntry type="jdk" jdkName="rbenv: 2.2.0" jdkType="RUBY_SDK" />
18
+ <orderEntry type="sourceFolder" forTests="false" />
19
+ <orderEntry type="library" scope="PROVIDED" name="actionpack (v4.2.0, rbenv: 2.2.0) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="actionview (v4.2.0, rbenv: 2.2.0) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="activemodel (v4.2.0, rbenv: 2.2.0) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v4.2.0, rbenv: 2.2.0) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="auto_select2 (v0.3.2, rbenv: 2.2.0) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.2, rbenv: 2.2.0) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.8.2, rbenv: 2.2.0) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="coffee-rails (v4.1.0, rbenv: 2.2.0) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="coffee-script (v2.3.0, rbenv: 2.2.0) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="coffee-script-source (v1.9.0, rbenv: 2.2.0) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="erubis (v2.7.0, rbenv: 2.2.0) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="execjs (v2.3.0, rbenv: 2.2.0) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v0.7.0, rbenv: 2.2.0) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="json (v1.8.2, rbenv: 2.2.0) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="loofah (v2.0.1, rbenv: 2.2.0) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="mini_portile (v0.6.2, rbenv: 2.2.0) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.5.1, rbenv: 2.2.0) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.6.6.2, rbenv: 2.2.0) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="rack (v1.6.0, rbenv: 2.2.0) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="rack-test (v0.6.3, rbenv: 2.2.0) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="rails-deprecated_sanitizer (v1.0.3, rbenv: 2.2.0) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rails-dom-testing (v1.0.5, rbenv: 2.2.0) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rails-html-sanitizer (v1.0.1, rbenv: 2.2.0) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="railties (v4.2.0, rbenv: 2.2.0) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="select2-rails (v3.5.9.3, rbenv: 2.2.0) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="simple_form (v3.1.0, rbenv: 2.2.0) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="thor (v0.19.1, rbenv: 2.2.0) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="thread_safe (v0.3.4, rbenv: 2.2.0) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v1.2.2, rbenv: 2.2.0) [gem]" level="application" />
48
+ </component>
49
+ </module>
50
+
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple_form_auto_select2.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Tab Loid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # simple_form_auto_select2
@@ -0,0 +1,42 @@
1
+ class AjaxSelect2Input < SimpleForm::Inputs::StringInput
2
+ extend ActiveSupport::Autoload
3
+
4
+ def input_html_options
5
+ url_params = {}
6
+ url_params[:class_name] = options[:search_class] if options[:search_class].present?
7
+ url_params[:search_method] = options[:search_method] if options[:search_method].present?
8
+ url_params[:default_class_name] = options[:default_class_name] if options[:default_class_name].present?
9
+ url_params[:default_text_column] = options[:default_text_column] if options[:default_text_column].present?
10
+ url_params[:default_id_column] = options[:default_id_column] if options[:default_id_column].present?
11
+ url_params[:select2_options] = options[:select2_options] if options[:select2_options].present?
12
+ href = template.select2_autocompletes_path(url_params)
13
+ input_options = super
14
+ input_options[:data] = input_options[:data].to_h.merge({
15
+ s2_href: href,
16
+ s2_options: url_params[:select2_options].to_h.merge(multiple: multiple?)
17
+ })
18
+ css_classes = [input_options[:class], 'auto-ajax-select2', 'input-hol']
19
+ if multiple?
20
+ css_classes << 'multiple'
21
+ end
22
+ input_options[:class] = css_classes.compact
23
+ input_options
24
+ end
25
+
26
+ def multiple?
27
+ multiple_by_options? || multiple_by_association?
28
+ end
29
+
30
+ # def value
31
+ # val = object.send(association_primary_key)
32
+ # val.is_a?(Array) ? val.join(',') : val
33
+ # end
34
+
35
+ def multiple_by_association?
36
+ reflection && [ :has_many, :has_and_belongs_to_many ].include?(reflection.macro)
37
+ end
38
+
39
+ def multiple_by_options?
40
+ options[:multiple] || (options[:input_html] && options[:input_html][:multiple])
41
+ end
42
+ end
@@ -0,0 +1,9 @@
1
+ class Select2Input < SimpleForm::Inputs::CollectionSelectInput
2
+ extend ActiveSupport::Autoload
3
+
4
+ def input_html_options
5
+ input_options = super
6
+ input_options[:class] = [input_options[:class], 'auto-static-select2'].compact
7
+ input_options
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module SimpleFormAutoSelect2
2
+ class Engine < ::Rails::Engine
3
+ # Get rails to add app, lib, vendor to load path
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleFormAutoSelect2
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,6 @@
1
+ require 'simple_form_auto_select2/version'
2
+ require 'simple_form_auto_select2/engine'
3
+
4
+ module SimpleFormAutoSelect2
5
+ extend ActiveSupport::Autoload
6
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simple_form_auto_select2/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'simple_form_auto_select2'
8
+ spec.version = SimpleFormAutoSelect2::VERSION
9
+ spec.authors = ['Dmitriy Lisichkin']
10
+ spec.email = ['dima@sb42.ru']
11
+ spec.summary = %q{Provide select2 input class for simple_form}
12
+ spec.description = spec.summary
13
+ spec.homepage = 'https://github.com/tab10id/simple_form_auto_select2'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'railties', '>= 3.1'
22
+ spec.add_dependency 'select2-rails'
23
+ spec.add_dependency 'auto_select2', '>= 0.3.1'
24
+ spec.add_dependency 'simple_form'
25
+
26
+ spec.add_development_dependency 'bundler', '~> 1.5'
27
+ spec.add_development_dependency 'rake'
28
+ spec.add_development_dependency 'rails', '~> 3.2.12'
29
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_form_auto_select2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dmitriy Lisichkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: select2-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: auto_select2
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: 0.3.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.3.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: simple_form
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 3.2.12
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 3.2.12
111
+ description: Provide select2 input class for simple_form
112
+ email:
113
+ - dima@sb42.ru
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .idea/.name
120
+ - .idea/encodings.xml
121
+ - .idea/misc.xml
122
+ - .idea/modules.xml
123
+ - .idea/scopes/scope_settings.xml
124
+ - .idea/simple_form_auto_select2.iml
125
+ - .idea/vcs.xml
126
+ - Gemfile
127
+ - LICENSE
128
+ - README.md
129
+ - app/inputs/ajax_select2_input.rb
130
+ - app/inputs/select2_input.rb
131
+ - lib/simple_form_auto_select2.rb
132
+ - lib/simple_form_auto_select2/engine.rb
133
+ - lib/simple_form_auto_select2/version.rb
134
+ - simple_form_auto_select2.gemspec
135
+ homepage: https://github.com/tab10id/simple_form_auto_select2
136
+ licenses:
137
+ - MIT
138
+ metadata: {}
139
+ post_install_message:
140
+ rdoc_options: []
141
+ require_paths:
142
+ - lib
143
+ required_ruby_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - '>='
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ requirements: []
154
+ rubyforge_project:
155
+ rubygems_version: 2.0.2
156
+ signing_key:
157
+ specification_version: 4
158
+ summary: Provide select2 input class for simple_form
159
+ test_files: []
160
+ has_rdoc: