effective_form_inputs 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +88 -3
- data/app/assets/javascripts/effective_form_inputs.js +1 -0
- data/app/assets/javascripts/effective_select/initialize.js.coffee +12 -0
- data/app/assets/javascripts/effective_select/input.js +2 -0
- data/app/assets/javascripts/effective_select/select2.js +5403 -0
- data/app/assets/stylesheets/effective_form_inputs.scss +1 -0
- data/app/assets/stylesheets/effective_select/bootstrap-theme.css +564 -0
- data/app/assets/stylesheets/effective_select/input.scss +3 -0
- data/app/assets/stylesheets/effective_select/overrides.scss +3 -0
- data/app/assets/stylesheets/effective_select/select2.css +431 -0
- data/app/models/effective/form_builder_inputs.rb +7 -0
- data/app/models/inputs/effective_select/input.rb +30 -0
- data/app/models/inputs/effective_select_input.rb +24 -0
- data/app/views/effective/style_guide/_form_default.html.haml +2 -1
- data/lib/effective_form_inputs/engine.rb +4 -2
- data/lib/effective_form_inputs/version.rb +1 -1
- data/lib/effective_form_inputs.rb +1 -1
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b20db9741d49dbba717dccb759e8b9ae7bdf3b9
|
4
|
+
data.tar.gz: 9bb2c5154ca44a3e38841e3e155062ecc187506a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 495e6b9cc1f4730b3c013bf82d9f41fc20eeceef1c0b6ee7aede0ab030886613b7f42b445b8b8eed2924eadfa262a3573c4f5faeff015db8f46c0357f942b981
|
7
|
+
data.tar.gz: f66163842a292ab829de08dd79c5c428b3e9827f75d5291705602cf16f500e04bd3f05256dedc0e9d5610c34a221365ae4dca830518de12814f471b1a6402fa3
|
data/README.md
CHANGED
@@ -45,7 +45,7 @@ and add the following to your application.css:
|
|
45
45
|
All of the included form inputs will now be available with no additional installation tasks.
|
46
46
|
|
47
47
|
|
48
|
-
##
|
48
|
+
## Effective Date Time Picker
|
49
49
|
|
50
50
|
This custom form input is based on the following awesome project:
|
51
51
|
|
@@ -97,7 +97,7 @@ For a full list of options, please refer to:
|
|
97
97
|
http://eonasdan.github.io/bootstrap-datetimepicker/Options/
|
98
98
|
|
99
99
|
|
100
|
-
##
|
100
|
+
## Effective Date Picker
|
101
101
|
|
102
102
|
This custom form input is based on the following awesome project:
|
103
103
|
|
@@ -149,7 +149,7 @@ For a full list of options, please refer to:
|
|
149
149
|
http://eonasdan.github.io/bootstrap-datetimepicker/Options/
|
150
150
|
|
151
151
|
|
152
|
-
## Static Control
|
152
|
+
## Effective Static Control
|
153
153
|
|
154
154
|
A bootstrap3 Static control input
|
155
155
|
|
@@ -180,6 +180,91 @@ and as a SimpleForm input:
|
|
180
180
|
There are no options for this form input
|
181
181
|
|
182
182
|
|
183
|
+
|
184
|
+
## Effective Select
|
185
|
+
|
186
|
+
This custom form input is based on the following awesome project:
|
187
|
+
|
188
|
+
Select2 (https://select2.github.io/)
|
189
|
+
|
190
|
+
|
191
|
+
### Installation
|
192
|
+
|
193
|
+
If you've already installed the 'All Form Inputs' assets (see above), there are no additional installation steps.
|
194
|
+
|
195
|
+
To install this form input individually, add the following to your application.js:
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
//= require effective_select/input
|
199
|
+
```
|
200
|
+
|
201
|
+
and add the following to your application.css:
|
202
|
+
|
203
|
+
```ruby
|
204
|
+
*= require effective_select/input
|
205
|
+
```
|
206
|
+
|
207
|
+
### Usage
|
208
|
+
|
209
|
+
As a Rails Form Helper input:
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
= form_for @user do |f|
|
213
|
+
= f.effective_select :category, 10.times.map { |x| "Category #{x}"}
|
214
|
+
= f.effective_select :categories, 10.times.map { |x| "Category #{x}"}, :multiple => true
|
215
|
+
= f.effective_select :categories, 10.times.map { |x| "Category #{x}"}, :multiple => true, :tags => true
|
216
|
+
```
|
217
|
+
|
218
|
+
and as a SimpleForm input:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
= simple_form_for @user do |f|
|
222
|
+
= f.input :category, :as => :effective_select, :collection => 10.times.map { |x| "Category #{x}"}
|
223
|
+
= f.input :categories, :as => :effective_select, :collection => 10.times.map { |x| "Category #{x}"}, :multiple => true
|
224
|
+
= f.input :categores, :as => :effective_select, :collection => 10.times.map { |x| "Category #{x}"}, :multiple => true, :tags => true
|
225
|
+
```
|
226
|
+
|
227
|
+
### Modes
|
228
|
+
|
229
|
+
The standard mode is equivelant to `:multiple => false` and is a replacement for the default single select box.
|
230
|
+
|
231
|
+
Passing `:multiple => true` will allow multiple selections to be made.
|
232
|
+
|
233
|
+
Passing `:multiple => true, :tags => true` will allow multiple selections to be made, and new value options to be created. This will allow you to select one or more tags and create tags in the same form control.
|
234
|
+
|
235
|
+
|
236
|
+
### Options
|
237
|
+
|
238
|
+
The default options used to initialize this form input are as follows:
|
239
|
+
|
240
|
+
```ruby
|
241
|
+
:allowClear => !(options[:multiple]) # Only display the Clear 'x' on a single selection box
|
242
|
+
```
|
243
|
+
|
244
|
+
### Interesting Available Options
|
245
|
+
|
246
|
+
To limit the number of items that can be selected in a multiple select box:
|
247
|
+
|
248
|
+
```ruby
|
249
|
+
:maximumSelectionLength => 2
|
250
|
+
```
|
251
|
+
|
252
|
+
To hide the search box:
|
253
|
+
|
254
|
+
```ruby
|
255
|
+
:minimumResultsForSearch => 'Infinity'
|
256
|
+
```
|
257
|
+
|
258
|
+
For a full list of options, please refer to:
|
259
|
+
|
260
|
+
https://select2.github.io/options.html
|
261
|
+
|
262
|
+
|
263
|
+
### AJAX Support
|
264
|
+
|
265
|
+
There is currently no support for using AJAX to load remote data. This feature is supported by the underlying select2 library and will be implemented here at a future point.
|
266
|
+
|
267
|
+
|
183
268
|
## Passing Options to JavaScript
|
184
269
|
|
185
270
|
All appropriate options passed to any effective_form_input will be used to initialize the Javascript library
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# https://select2.github.io/examples.html
|
2
|
+
|
3
|
+
initialize = ->
|
4
|
+
$('select.effective_select:not(.initialized)').each (i, element) ->
|
5
|
+
element = $(element)
|
6
|
+
options = element.data('input-js-options') || {}
|
7
|
+
|
8
|
+
element.addClass('initialized').select2(options)
|
9
|
+
|
10
|
+
$ -> initialize()
|
11
|
+
$(document).on 'page:change', -> initialize()
|
12
|
+
$(document).on 'cocoon:after-insert', -> initialize()
|