formtastic_auto_select2 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +26 -0
- data/app/inputs/ajax_select2_input.rb +58 -0
- data/app/inputs/select2_input.rb +11 -0
- data/formtastic_auto_select2.gemspec +29 -0
- data/lib/formtastic_auto_select2.rb +6 -0
- data/lib/formtastic_auto_select2/engine.rb +5 -0
- data/lib/formtastic_auto_select2/version.rb +3 -0
- metadata +153 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 198fa01b235bba231d9958a2d8a36de94e9a634c
|
4
|
+
data.tar.gz: c9f425386c2e84c00850e545e63617f89b5fa882
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 974617787ccf32093a98b2c97039779173ead40bfe093d5343ec51aa58e49378879b3bd5b71ebd650211a1ce0eb66c9d4af22e8d43c1744e333414946f76bc5e
|
7
|
+
data.tar.gz: 98df5924ce1585ca99dda43ac71e1fe47cd3ca4b949383fc457de6de8cf389606953b73c517fdc7ab91b99d98e51a94c065336193a27a1e8aa5d537a57776d51
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Created by .gitignore support plugin (hsz.mobi)
|
2
|
+
### Ruby template
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/test/tmp/
|
11
|
+
/test/version_tmp/
|
12
|
+
/tmp/
|
13
|
+
|
14
|
+
## Specific to RubyMotion:
|
15
|
+
.dat*
|
16
|
+
.repl_history
|
17
|
+
build/
|
18
|
+
|
19
|
+
## Documentation cache and generated files:
|
20
|
+
/.yardoc/
|
21
|
+
/_yardoc/
|
22
|
+
/doc/
|
23
|
+
/rdoc/
|
24
|
+
|
25
|
+
## Environment normalisation:
|
26
|
+
/.bundle/
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/Gemfile
ADDED
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,26 @@
|
|
1
|
+
# formtastic_auto_select2
|
2
|
+
|
3
|
+
Provide select2 input class for semantic_form
|
4
|
+
The `FormtasticAutoSelect2` based on [auto_select2](https://github.com/Loriowar/auto_select2) gem.
|
5
|
+
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/formtastic_auto_select2.png)](http://badge.fury.io/rb/formtastic_auto_select2)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'formtastic_auto_select2'
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### Static select2
|
17
|
+
|
18
|
+
f.input :project, as: :select2
|
19
|
+
|
20
|
+
### Ajax select2
|
21
|
+
|
22
|
+
f.input :user, as: :ajax_select2, placeholder: t(:select_user_from_list),
|
23
|
+
default_class_name: :user, default_text_column: [:id, :firstname, :lastname]
|
24
|
+
|
25
|
+
More info see in documentation of [auto_select2](https://github.com/Loriowar/auto_select2) gem
|
26
|
+
and in [auto_select2_tag_example](https://github.com/Loriowar/auto_select2_tag_example) project
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class AjaxSelect2Input < Formtastic::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 = {
|
14
|
+
value: value
|
15
|
+
}.merge(extra_input_html_options).merge(super)
|
16
|
+
input_options[:data] = {
|
17
|
+
href: href,
|
18
|
+
s2options: url_params[:select2_options].to_h.merge(multiple: multiple?)
|
19
|
+
}
|
20
|
+
css_classes = [input_options[:class], 'auto-ajax-select2', 'input-hol']
|
21
|
+
if multiple?
|
22
|
+
css_classes << 'multiple'
|
23
|
+
end
|
24
|
+
input_options[:class] = css_classes.compact.join(' ')
|
25
|
+
input_options
|
26
|
+
end
|
27
|
+
|
28
|
+
def extra_input_html_options
|
29
|
+
{
|
30
|
+
name: input_html_options_name
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def multiple?
|
35
|
+
multiple_by_options? || multiple_by_association?
|
36
|
+
end
|
37
|
+
|
38
|
+
def value
|
39
|
+
val = object.send(association_primary_key)
|
40
|
+
val.is_a?(Array) ? val.join(',') : val
|
41
|
+
end
|
42
|
+
|
43
|
+
def input_html_options_name
|
44
|
+
if builder.options.key?(:index)
|
45
|
+
"#{object_name}[#{builder.options[:index]}][#{association_primary_key}]"
|
46
|
+
else
|
47
|
+
"#{object_name}[#{association_primary_key}]"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def multiple_by_association?
|
52
|
+
reflection && [ :has_many, :has_and_belongs_to_many ].include?(reflection.macro)
|
53
|
+
end
|
54
|
+
|
55
|
+
def multiple_by_options?
|
56
|
+
options[:multiple] || (options[:input_html] && options[:input_html][:multiple])
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Select2Input < Formtastic::Inputs::SelectInput
|
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.join(' ')
|
7
|
+
input_options[:data] ||= {}
|
8
|
+
input_options[:data][:placeholder] ||= (options[:placeholder] || localized_label || humanized_method_name)
|
9
|
+
input_options
|
10
|
+
end
|
11
|
+
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 'formtastic_auto_select2/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'formtastic_auto_select2'
|
8
|
+
spec.version = FormtasticAutoSelect2::VERSION
|
9
|
+
spec.authors = ["Dmitriy Lisichkin"]
|
10
|
+
spec.email = ["dima@sb42.ru"]
|
11
|
+
spec.summary = %q{Provide select2 input class for semantic_form}
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = "https://github.com/tab10id/formtastic_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.2.1'
|
24
|
+
spec.add_dependency 'formtastic', '>= 0.0.1'
|
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,153 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: formtastic_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-01-16 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.2.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.2.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: formtastic
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.0.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.0.1
|
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 semantic_form
|
112
|
+
email:
|
113
|
+
- dima@sb42.ru
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE
|
121
|
+
- README.md
|
122
|
+
- app/inputs/ajax_select2_input.rb
|
123
|
+
- app/inputs/select2_input.rb
|
124
|
+
- formtastic_auto_select2.gemspec
|
125
|
+
- lib/formtastic_auto_select2.rb
|
126
|
+
- lib/formtastic_auto_select2/engine.rb
|
127
|
+
- lib/formtastic_auto_select2/version.rb
|
128
|
+
homepage: https://github.com/tab10id/formtastic_auto_select2
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.0.2
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: Provide select2 input class for semantic_form
|
152
|
+
test_files: []
|
153
|
+
has_rdoc:
|