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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 375f1f134953913fed15dd35f4d955efd89e7ae5
4
- data.tar.gz: 3ade7ebdc2b7d71eb3542942f5eaff19b291e00c
3
+ metadata.gz: 0b20db9741d49dbba717dccb759e8b9ae7bdf3b9
4
+ data.tar.gz: 9bb2c5154ca44a3e38841e3e155062ecc187506a
5
5
  SHA512:
6
- metadata.gz: c7d17d0ebe6e759bcb8e57184eb9e1480660b1f850b445fa0857e0b38bb0d4e2de8b5b11517160b602b0b13eefc94a91ea7c5bdc5f83dc18132b4970c26b128e
7
- data.tar.gz: 988b7000d3fba5e5ef36fb2238ccf22fa1dd3f078d7eb9a17b9031ffdb4015164e1ee730f2d1a10e80d73747998469ebabaddce11e9d20f8152cd51ff299bec4
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
- ## Bootstrap3 DateTimePicker
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
- ## Bootstrap3 DatePicker
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
@@ -1,2 +1,3 @@
1
1
  //= require ./effective_date_time_picker/input
2
2
  //= require ./effective_date_picker/input
3
+ //= require ./effective_select/input
@@ -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()
@@ -0,0 +1,2 @@
1
+ //= require ./select2
2
+ //= require ./initialize