effective_bootstrap 0.7.4 → 0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/app/assets/images/icons/microsoft.svg +1 -0
- data/app/assets/javascripts/effective_bootstrap/confirm.js.coffee.erb +10 -5
- data/app/helpers/effective_bootstrap_helper.rb +6 -4
- 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 +5 -3
- 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 +2 -1
- 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 +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd2b4a321ad92d428321ae94d2b26875a047f209c3b3842ca4f4be921b76071d
|
4
|
+
data.tar.gz: fe91e9b1898dfb4286470bacf83b7ab09f12b091aa1218109d432c330f991493
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99b921f38e9cc727b520012cb0b4621c127c51dde6491ee69ad297060368af741df1a9b8df83141ff8a84007ffab0f8484e66c53bf03ae0796b1bc1782b6d4bf
|
7
|
+
data.tar.gz: 03422e1c8f7ab703916ce5a0473266d23560e4ad485306acf01aecb387ca4b94a390b3d87b0f6cd7b282a74a4a634755c0f39889c4f198992512efbbd973e67b
|
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.
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Microsoft Azure icon</title><path d="M5.483 21.3H24L14.025 4.013l-3.038 8.347 5.836 6.938L5.483 21.3zM13.23 2.7L6.105 8.677 0 19.253h5.505v.014L13.23 2.7z"/></svg>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
# These next three methods hijack jquery_ujs data-confirm and do it our own way with a double click confirm
|
1
|
+
# These next three methods hijack rails/ujs and jquery_ujs data-confirm and do it our own way with a double click confirm
|
2
2
|
|
3
|
-
if <%= !!EffectiveBootstrap.use_custom_data_confirm %> && $.rails
|
3
|
+
if <%= !!EffectiveBootstrap.use_custom_data_confirm %> && (window.Rails || $.rails)
|
4
4
|
$(document).on 'confirm', (event) ->
|
5
5
|
$obj = $(event.target)
|
6
6
|
|
@@ -18,6 +18,11 @@ if <%= !!EffectiveBootstrap.use_custom_data_confirm %> && $.rails
|
|
18
18
|
, 4000)
|
19
19
|
false # don't show the confirmation dialog
|
20
20
|
|
21
|
-
$.rails.confirm = (message) -> true
|
22
|
-
$.rails.effective_bootstrap_custom_data_confirm = true
|
23
|
-
|
21
|
+
(window.Rails || $.rails).confirm = (message) -> true
|
22
|
+
(window.Rails || $.rails).effective_bootstrap_custom_data_confirm = true
|
23
|
+
|
24
|
+
$(document).on 'confirm:complete', (event) -> $(event.target).data('confirmed')
|
25
|
+
|
26
|
+
$(document).on 'click', 'a.dropdown-item[data-confirm]', (event) ->
|
27
|
+
event.preventDefault()
|
28
|
+
false
|
@@ -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
|
@@ -154,11 +154,13 @@ module EffectiveBootstrapHelper
|
|
154
154
|
end
|
155
155
|
|
156
156
|
# Works with dots ao and dropdown do
|
157
|
-
def dropdown_divider
|
157
|
+
def dropdown_divider(options = {})
|
158
|
+
options[:class] = [options[:class], 'dropdown-divider'].compact.join(' ')
|
159
|
+
|
158
160
|
unless @_dropdown_link_tos
|
159
|
-
content_tag(:div, '',
|
161
|
+
content_tag(:div, '', options)
|
160
162
|
else
|
161
|
-
@_dropdown_link_tos << content_tag(:div, '',
|
163
|
+
@_dropdown_link_tos << content_tag(:div, '', options)
|
162
164
|
nil
|
163
165
|
end
|
164
166
|
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
|
-
|
@@ -7,7 +7,7 @@ module Effective
|
|
7
7
|
EXCLUSIVE_CLASS_SUFFIXES = ['-primary', '-secondary', '-success', '-danger', '-warning', '-info', '-light', '-dark']
|
8
8
|
|
9
9
|
delegate :object, to: :@builder
|
10
|
-
delegate :capture, :content_tag, :link_to, :icon, :asset_path, to: :@template
|
10
|
+
delegate :capture, :content_tag, :image_tag, :link_to, :icon, :asset_path, to: :@template
|
11
11
|
|
12
12
|
# So this takes in the options for an entire form group.
|
13
13
|
def initialize(name, options, builder:, html_options: nil)
|
@@ -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?
|
@@ -15,6 +15,7 @@ module Effective
|
|
15
15
|
|
16
16
|
def input_html_options
|
17
17
|
{
|
18
|
+
id: tag_id,
|
18
19
|
class: 'form-control form-control-file btn-outline-secondary',
|
19
20
|
multiple: multiple?,
|
20
21
|
direct_upload: true,
|
@@ -93,7 +94,7 @@ module Effective
|
|
93
94
|
content_tag(:div, class: 'card mb-3') do
|
94
95
|
if attachment.image?
|
95
96
|
content_tag(:div, class: 'card-body') do
|
96
|
-
|
97
|
+
image_tag(url, alt: attachment.filename.to_s, class: 'img-fluid') +
|
97
98
|
link_to(attachment.filename, url, class: 'card-link')
|
98
99
|
end
|
99
100
|
else
|
@@ -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.4
|
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-
|
11
|
+
date: 2020-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -262,6 +262,7 @@ files:
|
|
262
262
|
- app/assets/images/icons/message-square.svg
|
263
263
|
- app/assets/images/icons/mic-off.svg
|
264
264
|
- app/assets/images/icons/mic.svg
|
265
|
+
- app/assets/images/icons/microsoft.svg
|
265
266
|
- app/assets/images/icons/minimize-2.svg
|
266
267
|
- app/assets/images/icons/minimize.svg
|
267
268
|
- app/assets/images/icons/minus-circle.svg
|
@@ -609,6 +610,7 @@ files:
|
|
609
610
|
- app/models/effective/form_inputs/file_field.rb
|
610
611
|
- app/models/effective/form_inputs/float_field.rb
|
611
612
|
- app/models/effective/form_inputs/form_group.rb
|
613
|
+
- app/models/effective/form_inputs/hidden_field.rb
|
612
614
|
- app/models/effective/form_inputs/integer_field.rb
|
613
615
|
- app/models/effective/form_inputs/number_field.rb
|
614
616
|
- app/models/effective/form_inputs/number_text_field.rb
|