effective_bootstrap 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/app/helpers/effective_form_builder_helper.rb +18 -0
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0034d69f81cdb19da4484ae2f177d94ea598b14
|
4
|
+
data.tar.gz: c17d3ffb3930beb71d36119d3a55e8350dd39f51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdb5114081df013c88f85b1842c84edece3be14a231d0290672d99aa8e95654ce43d65d65ac5dccea9eae634eb19ed81301fb4159667834e8b2330fca2cfd559
|
7
|
+
data.tar.gz: 4649f5e1200d95c3dbff37c083d4ae7acd9329f47b5669444dba6149e7d571b3e901e7527e986154d543a588fcac67d77fa0264692d8bffb7e192543a91af278
|
data/README.md
CHANGED
@@ -162,7 +162,7 @@ There are three sets of options hashes that you can pass into any form input:
|
|
162
162
|
|
163
163
|
- `wrapper: { class: 'something' }` are applied to the wrapping div tag.
|
164
164
|
- `input_html: { class: 'something' }` are applied to the input, select or textarea tag itself.
|
165
|
-
- `input_js: { key: value}` are passed to any custom form input will be used to initialize the Javascript library. For example:
|
165
|
+
- `input_js: { key: value }` are passed to any custom form input will be used to initialize the Javascript library. For example:
|
166
166
|
|
167
167
|
```ruby
|
168
168
|
= effective_form_with(model: @user) do |f|
|
@@ -315,12 +315,12 @@ will internally translate the collection into:
|
|
315
315
|
[['User 1', 'User_1'], ['User 2', 'User_2'], ['Member 100', 'Member_100']]
|
316
316
|
```
|
317
317
|
|
318
|
-
and instead of posting to the server with the parameter `:primary_contact`, it will instead post `{:
|
318
|
+
and instead of posting to the server with the parameter `:primary_contact`, it will instead post `{primary_contact_id: 2, primary_contact_type: 'User'}`.
|
319
319
|
|
320
320
|
Using both `polymorphic: true` and `grouped: true` is recommended. In this case the expected collection is as follows:
|
321
321
|
|
322
322
|
```ruby
|
323
|
-
= f.input :primary_contact, {'Users'
|
323
|
+
= f.input :primary_contact, {'Users': User.all, 'Members': Member.all}, polymorphic: true, grouped: true
|
324
324
|
```
|
325
325
|
|
326
326
|
### Options
|
@@ -343,13 +343,13 @@ The default options used to initialize this form input are as follows:
|
|
343
343
|
To limit the number of items that can be selected in a multiple select box:
|
344
344
|
|
345
345
|
```ruby
|
346
|
-
:
|
346
|
+
maximumSelectionLength: 2
|
347
347
|
```
|
348
348
|
|
349
349
|
To hide the search box entirely:
|
350
350
|
|
351
351
|
```ruby
|
352
|
-
:
|
352
|
+
minimumResultsForSearch: 'Infinity'
|
353
353
|
```
|
354
354
|
|
355
355
|
For a full list of options, please refer to: https://select2.github.io/options.html
|
@@ -360,8 +360,8 @@ The following `input_js: options` are not part of the standard select2 API, and
|
|
360
360
|
To add a css class to the select2 container or dropdown:
|
361
361
|
|
362
362
|
```ruby
|
363
|
-
:
|
364
|
-
:
|
363
|
+
containerClass: 'custom-container-class'
|
364
|
+
dropdownClass: 'custom-dropdown-class'
|
365
365
|
```
|
366
366
|
|
367
367
|
to display a glyphicon infront of each option value:
|
@@ -3,6 +3,19 @@ module EffectiveFormBuilderHelper
|
|
3
3
|
options[:class] = [options[:class], 'needs-validation', ('form-inline' if options[:layout] == :inline)].compact.join(' ')
|
4
4
|
options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this);')
|
5
5
|
|
6
|
+
# Compute the default ID
|
7
|
+
subject = Array(options[:scope] || options[:model]).last
|
8
|
+
|
9
|
+
html_id = if subject.kind_of?(Symbol)
|
10
|
+
subject
|
11
|
+
elsif subject.respond_to?(:new_record?) && subject.new_record?
|
12
|
+
"new_#{subject.class.name.underscore}"
|
13
|
+
elsif subject.respond_to?(:persisted?) && subject.persisted?
|
14
|
+
"edit_#{subject.class.name.underscore}_#{subject.to_param}"
|
15
|
+
else
|
16
|
+
raise 'Unexpected subject. Expected :scope or :model to be a symbol or ActiveRecord object'
|
17
|
+
end
|
18
|
+
|
6
19
|
remote_index = options.except(:model).hash.abs
|
7
20
|
|
8
21
|
if options.delete(:remote) == true
|
@@ -15,8 +28,13 @@ module EffectiveFormBuilderHelper
|
|
15
28
|
options[:html]['data-remote'] = true
|
16
29
|
options[:html]['data-remote-index'] = remote_index
|
17
30
|
end
|
31
|
+
|
32
|
+
html_id = "#{html_id}_#{remote_index}"
|
18
33
|
end
|
19
34
|
|
35
|
+
# Assign default ID
|
36
|
+
options[:id] ||= options[:html].delete(:id) || html_id
|
37
|
+
|
20
38
|
without_error_proc do
|
21
39
|
form_with(**options.merge(builder: Effective::FormBuilder), &block)
|
22
40
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|