effective_bootstrap 0.7.4 → 0.8.0
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 +2 -0
- data/app/helpers/effective_bootstrap_helper.rb +1 -1
- data/app/helpers/effective_form_builder_helper.rb +16 -13
- data/app/models/effective/form_builder.rb +5 -1
- data/app/models/effective/form_input.rb +4 -2
- data/app/models/effective/form_inputs/clear.rb +1 -1
- data/app/models/effective/form_inputs/collection_input.rb +1 -1
- data/app/models/effective/form_inputs/date_field.rb +2 -1
- data/app/models/effective/form_inputs/datetime_field.rb +2 -1
- data/app/models/effective/form_inputs/delete.rb +5 -1
- data/app/models/effective/form_inputs/email_cc_field.rb +1 -1
- data/app/models/effective/form_inputs/email_field.rb +1 -1
- data/app/models/effective/form_inputs/error_field.rb +1 -1
- data/app/models/effective/form_inputs/file_field.rb +1 -0
- data/app/models/effective/form_inputs/float_field.rb +6 -1
- data/app/models/effective/form_inputs/hidden_field.rb +11 -0
- data/app/models/effective/form_inputs/integer_field.rb +1 -1
- data/app/models/effective/form_inputs/number_text_field.rb +1 -1
- data/app/models/effective/form_inputs/password_field.rb +1 -1
- data/app/models/effective/form_inputs/percent_field.rb +1 -1
- data/app/models/effective/form_inputs/phone_field.rb +1 -1
- data/app/models/effective/form_inputs/price_field.rb +1 -1
- data/app/models/effective/form_inputs/select.rb +3 -3
- data/app/models/effective/form_inputs/static_field.rb +1 -1
- data/app/models/effective/form_inputs/text_area.rb +1 -1
- data/app/models/effective/form_inputs/time_field.rb +2 -1
- data/app/models/effective/form_inputs/url_field.rb +1 -1
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d221a2264a9a64787ad5a179b836fc0c6fbc1cb7b3ea3a968af87eeb708a4b14
|
4
|
+
data.tar.gz: 33f8635737e17de6393c39a899293e8696ef4d5e2726d3cf9d1fcc29bfec890c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0704a3f0bc5866589d8117dd10955978e20c36a5938fcd674a5f148868af9a9fa90d4a93b95df8944771a7b147473517fe98838330fa4fd6c469acd48e2f06c7
|
7
|
+
data.tar.gz: cd48f3bd938979dfb1dbbec28d0a0285fd101b2140b7301feb07d5a44fd0d5da2761f08e85b4148f2c615ef4ccc429a455e38e54efd80f1d7a17973242a72a55
|
data/README.md
CHANGED
@@ -229,6 +229,8 @@ As well, you can specify `layout: :vertical`, `layout: :horizontal`, or `layout:
|
|
229
229
|
|
230
230
|
The default is `layout: :vertical`.
|
231
231
|
|
232
|
+
If you would like each form and its fields to have unique ids, use `unique_ids: true`.
|
233
|
+
|
232
234
|
All standard form fields have been implemented as per [Rails 5.1 FormHelper](http://api.rubyonrails.org/v5.1/classes/ActionView/Helpers/FormHelper.html)
|
233
235
|
|
234
236
|
When working as a `remote: true` form, you can also pass `flash_success: true|false` and `flash_error: true|false` to control the flash behaviour. By default, the errors will be displayed, and the success will be hidden.
|
@@ -121,7 +121,7 @@ module EffectiveBootstrapHelper
|
|
121
121
|
def dots(options = nil, &block)
|
122
122
|
(options ||= {})[:class] = "dropdown dropdown-dots #{options.delete(:class)}".strip
|
123
123
|
|
124
|
-
content_tag(:
|
124
|
+
content_tag(:div, options) do
|
125
125
|
content_tag(:button, class: "btn btn-dots dropdown-toggle #{options.delete(:button_class)}", 'aria-expanded': true, 'aria-haspopup': true, 'data-toggle': 'dropdown', type: 'button') do
|
126
126
|
end + content_tag(:div, capture(&block), class: 'dropdown-menu')
|
127
127
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module EffectiveFormBuilderHelper
|
2
2
|
def effective_form_with(**options, &block)
|
3
|
-
|
4
3
|
# Compute the default ID
|
5
4
|
subject = Array(options[:scope] || options[:model]).last
|
6
5
|
class_name = subject.class.name.underscore
|
6
|
+
unique_id = options.except(:model).hash.abs
|
7
7
|
|
8
8
|
html_id = if subject.kind_of?(Symbol)
|
9
9
|
subject.to_s
|
@@ -14,9 +14,6 @@ module EffectiveFormBuilderHelper
|
|
14
14
|
end
|
15
15
|
|
16
16
|
options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this)')
|
17
|
-
|
18
|
-
remote_index = options.except(:model).hash.abs
|
19
|
-
|
20
17
|
options[:local] = true unless options.key?(:local)
|
21
18
|
|
22
19
|
if respond_to?(:inline_datatable?) && inline_datatable?
|
@@ -33,21 +30,27 @@ module EffectiveFormBuilderHelper
|
|
33
30
|
('hide-flash-danger' if options[:remote] && options.key?(:flash_error) && !options[:flash_error])
|
34
31
|
].compact.join(' ')
|
35
32
|
|
36
|
-
if options
|
37
|
-
@
|
38
|
-
|
33
|
+
if options[:remote] || options[:unique_ids]
|
34
|
+
@_effective_unique_id ||= {}
|
35
|
+
|
36
|
+
if @_effective_unique_id.key?(unique_id)
|
37
|
+
unique_id = unique_id + @_effective_unique_id.length
|
38
|
+
end
|
39
39
|
|
40
|
+
options[:unique_id] = unique_id
|
41
|
+
html_id = "#{html_id}_#{unique_id}"
|
42
|
+
|
43
|
+
@_effective_unique_id[unique_id] = true
|
44
|
+
end
|
45
|
+
|
46
|
+
if options.delete(:remote) == true
|
40
47
|
if options[:html][:data].kind_of?(Hash)
|
41
48
|
options[:html][:data][:remote] = true
|
42
|
-
options[:html][:data]['data-remote-index'] =
|
49
|
+
options[:html][:data]['data-remote-index'] = unique_id
|
43
50
|
else
|
44
51
|
options[:html]['data-remote'] = true
|
45
|
-
options[:html]['data-remote-index'] =
|
52
|
+
options[:html]['data-remote-index'] = unique_id
|
46
53
|
end
|
47
|
-
|
48
|
-
html_id = "#{html_id}_#{remote_index}"
|
49
|
-
|
50
|
-
@_effective_remote_index[remote_index] = true
|
51
54
|
end
|
52
55
|
|
53
56
|
# Assign default ID
|
@@ -20,6 +20,7 @@ module Effective
|
|
20
20
|
alias_method :super_number_field, :number_field
|
21
21
|
alias_method :super_text_field, :text_field
|
22
22
|
alias_method :super_text_area, :text_area
|
23
|
+
alias_method :super_hidden_field, :hidden_field
|
23
24
|
|
24
25
|
def clear(name = 'Clear', options = {})
|
25
26
|
(options = name; name = 'Clear') if name.kind_of?(Hash)
|
@@ -85,6 +86,10 @@ module Effective
|
|
85
86
|
Effective::FormInputs::FormGroup.new(name, options, builder: self).to_html(&block)
|
86
87
|
end
|
87
88
|
|
89
|
+
def hidden_field(name = nil, options = {})
|
90
|
+
Effective::FormInputs::HiddenField.new(name, options, builder: self).to_html
|
91
|
+
end
|
92
|
+
|
88
93
|
def integer_field(name, options = {})
|
89
94
|
Effective::FormInputs::IntegerField.new(name, options, builder: self).to_html
|
90
95
|
end
|
@@ -196,4 +201,3 @@ module Effective
|
|
196
201
|
|
197
202
|
end
|
198
203
|
end
|
199
|
-
|
@@ -24,7 +24,7 @@ module Effective
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def input_html_options
|
27
|
-
{ class: 'form-control' }
|
27
|
+
{ class: 'form-control', id: tag_id }
|
28
28
|
end
|
29
29
|
|
30
30
|
def input_js_options
|
@@ -408,7 +408,7 @@ module Effective
|
|
408
408
|
|
409
409
|
# https://github.com/rails/rails/blob/master/actionview/lib/action_view/helpers/tags/base.rb#L120
|
410
410
|
def tag_id(index = nil)
|
411
|
-
case
|
411
|
+
id = case
|
412
412
|
when @builder.object_name.empty?
|
413
413
|
sanitized_method_name.dup
|
414
414
|
when index
|
@@ -416,6 +416,8 @@ module Effective
|
|
416
416
|
else
|
417
417
|
"#{sanitized_object_name}_#{sanitized_method_name}"
|
418
418
|
end.downcase.parameterize
|
419
|
+
|
420
|
+
@builder.options[:unique_ids] ? "#{id}_#{@builder.options[:unique_id]}" : id
|
419
421
|
end
|
420
422
|
|
421
423
|
def sanitized_object_name
|
@@ -36,7 +36,7 @@ module Effective
|
|
36
36
|
|
37
37
|
@collection_options = {
|
38
38
|
checked: [checked, selected, polymorphic_value, value].find { |value| value != nil },
|
39
|
-
selected: [selected, checked, polymorphic_value, value].find { |value| value != nil },
|
39
|
+
selected: ([selected, checked, polymorphic_value, value].find { |value| value != nil } unless kind_of?(Effective::FormInputs::Radios)),
|
40
40
|
include_blank: include_blank
|
41
41
|
}.compact
|
42
42
|
end
|
@@ -14,7 +14,11 @@ module Effective
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def input_html_options
|
17
|
-
{
|
17
|
+
{
|
18
|
+
class: 'btn btn-warning',
|
19
|
+
id: tag_id,
|
20
|
+
data: { method: :delete, remote: true, confirm: "Really delete<br>#{object}?".html_safe }
|
21
|
+
}
|
18
22
|
end
|
19
23
|
|
20
24
|
def border?
|
@@ -7,7 +7,12 @@ module Effective
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def input_html_options
|
10
|
-
{
|
10
|
+
{
|
11
|
+
class: 'form-control effective_float',
|
12
|
+
autocomplete: 'off',
|
13
|
+
step: '0.01',
|
14
|
+
id: tag_id
|
15
|
+
}
|
11
16
|
end
|
12
17
|
|
13
18
|
# This has gotta be a valid pattern
|
@@ -6,7 +6,7 @@ module Effective
|
|
6
6
|
DEFAULT_CELL_MASK = '(999) 999-9999'
|
7
7
|
|
8
8
|
def input_html_options
|
9
|
-
{ class: 'form-control effective_phone', placeholder: '(555) 555-5555' }
|
9
|
+
{ class: 'form-control effective_phone', placeholder: '(555) 555-5555', id: tag_id }
|
10
10
|
end
|
11
11
|
|
12
12
|
def input_js_options
|
@@ -57,7 +57,7 @@ module Effective
|
|
57
57
|
('disable-open-on-focus' if disable_open_on_focus?),
|
58
58
|
].compact.join(' ')
|
59
59
|
|
60
|
-
{ class: classes, multiple: (true if multiple?), include_blank: (true if include_blank?),
|
60
|
+
{ class: classes, multiple: (true if multiple?), include_blank: (true if include_blank?), id: tag_id }.compact
|
61
61
|
end
|
62
62
|
|
63
63
|
def assign_options_collection!
|
@@ -142,7 +142,7 @@ module Effective
|
|
142
142
|
def no_results
|
143
143
|
return @no_results unless @no_results.nil?
|
144
144
|
|
145
|
-
@no_results = options.delete(:no_results)
|
145
|
+
@no_results = options.delete(:no_results)
|
146
146
|
|
147
147
|
if freeform?
|
148
148
|
@no_results ||= 'No results. To create a new one, press ENTER after typing your own free form response.'
|
@@ -160,7 +160,7 @@ module Effective
|
|
160
160
|
obj = options.delete(:placeholder)
|
161
161
|
|
162
162
|
@placeholder = case obj
|
163
|
-
when nil then
|
163
|
+
when nil then
|
164
164
|
(freeform? ? 'Choose or enter' : 'Please choose')
|
165
165
|
when false then ''
|
166
166
|
else obj
|
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.
|
4
|
+
version: 0.8.0
|
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: 2020-08-
|
11
|
+
date: 2020-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -609,6 +609,7 @@ files:
|
|
609
609
|
- app/models/effective/form_inputs/file_field.rb
|
610
610
|
- app/models/effective/form_inputs/float_field.rb
|
611
611
|
- app/models/effective/form_inputs/form_group.rb
|
612
|
+
- app/models/effective/form_inputs/hidden_field.rb
|
612
613
|
- app/models/effective/form_inputs/integer_field.rb
|
613
614
|
- app/models/effective/form_inputs/number_field.rb
|
614
615
|
- app/models/effective/form_inputs/number_text_field.rb
|