effective_bootstrap 1.26.2 → 1.26.4
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/app/assets/javascripts/effective_bootstrap/form.js.coffee +10 -3
- data/app/assets/javascripts/effective_bootstrap/logic.js.coffee +11 -3
- data/app/assets/javascripts/effective_clipboard/initialize.js.coffee +11 -2
- data/app/assets/javascripts/effective_datetime/navigation.js.coffee +1 -1
- data/app/assets/javascripts/effective_has_many/initialize.js.coffee +15 -5
- data/app/helpers/effective_form_builder_helper.rb +1 -1
- data/app/models/effective/form_inputs/file_field.rb +1 -1
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ca3151713ddf3fe2ba10d003040a7337e4af6fc606d20e1228e6d8f397bc7ed8
|
|
4
|
+
data.tar.gz: 8f51c987255a11ed33121e9c891a4615b2f05d449c32245e3a6fe3023645529f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2b4a0afdb255cb6c3e2111aee0a2ace632aa7a5c36ad716d25b2ad0d31ece912033876f30d02e3e161bb0640011cb8914e4394923dbabf1c168a25e1e5f477bb
|
|
7
|
+
data.tar.gz: 96385c23409c64e43152fd35e2ce4eb957b9e315a86029816f36f8c810a245901f9d4886e1f0ab9cd27200ebb205478a811c34b20e3479af6db51fbc6349677b
|
|
@@ -6,7 +6,7 @@ this.EffectiveForm ||= new class
|
|
|
6
6
|
remote_form_flash: '' # Array of Arrays
|
|
7
7
|
remote_form_redirect: '' # String containing the redirect path (optional)
|
|
8
8
|
|
|
9
|
-
validate: (form) ->
|
|
9
|
+
validate: (form, event) ->
|
|
10
10
|
$form = $(form)
|
|
11
11
|
valid = form.checkValidity() && @allChecksValid($form)
|
|
12
12
|
|
|
@@ -14,13 +14,15 @@ this.EffectiveForm ||= new class
|
|
|
14
14
|
@reset($form) if $form.hasClass('was-validated')
|
|
15
15
|
|
|
16
16
|
if valid then @submitting($form) else @invalidate($form)
|
|
17
|
+
event?.stopImmediatePropagation() unless valid # Keep Rails UJS from disabling an invalid form.
|
|
17
18
|
valid
|
|
18
19
|
|
|
19
20
|
allChecksValid: ($form) ->
|
|
20
21
|
valid = true
|
|
21
22
|
|
|
22
23
|
$form.find('.effective-checks-required').each ->
|
|
23
|
-
|
|
24
|
+
$checks = $(@).find('input[type=checkbox]:enabled')
|
|
25
|
+
valid = false if $checks.length > 0 && $checks.filter(':checked').length == 0
|
|
24
26
|
|
|
25
27
|
valid
|
|
26
28
|
|
|
@@ -43,7 +45,10 @@ this.EffectiveForm ||= new class
|
|
|
43
45
|
$(@).addClass(if $(@).find('input:invalid').length > 0 then 'is-invalid' else 'is-valid')
|
|
44
46
|
|
|
45
47
|
$form.find('.effective-checks-required').each ->
|
|
46
|
-
|
|
48
|
+
$checks = $(@).find('input[type=checkbox]:enabled')
|
|
49
|
+
if $checks.length == 0
|
|
50
|
+
$(@).removeClass('is-valid is-invalid')
|
|
51
|
+
else if $checks.filter(':checked').length > 0
|
|
47
52
|
$(@).addClass('is-valid').removeClass('is-invalid')
|
|
48
53
|
else
|
|
49
54
|
$(@).addClass('is-invalid').removeClass('is-valid')
|
|
@@ -51,6 +56,7 @@ this.EffectiveForm ||= new class
|
|
|
51
56
|
@flash($form, 'danger')
|
|
52
57
|
|
|
53
58
|
disable: ($form) ->
|
|
59
|
+
if window.Rails then Rails.disableElement($form[0]) else $.rails?.disableFormElements($form)
|
|
54
60
|
$form.find('[type=submit]').prop('disabled', true)
|
|
55
61
|
|
|
56
62
|
reset: ($form) ->
|
|
@@ -64,6 +70,7 @@ this.EffectiveForm ||= new class
|
|
|
64
70
|
$form.find('.is-invalid').removeClass('is-invalid')
|
|
65
71
|
$form.find('.is-valid').removeClass('is-valid')
|
|
66
72
|
|
|
73
|
+
if window.Rails then Rails.enableElement($form[0]) else $.rails?.enableFormElements($form)
|
|
67
74
|
$form.find('[type=submit]').removeAttr('disabled')
|
|
68
75
|
$form
|
|
69
76
|
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
elementSelector = 'input,textarea,select,button,div.form-has-many'
|
|
2
2
|
|
|
3
|
+
enableFields = ($element) ->
|
|
4
|
+
$element.find(elementSelector).not($element.find('.effective-form-logic:hidden').find(elementSelector)).each ->
|
|
5
|
+
$input = $(this)
|
|
6
|
+
return if $input.closest('.marked-for-destruction').length > 0 && !$input.is("input[type=hidden][name$='[id]'],input[type=hidden][name$='[_destroy]']")
|
|
7
|
+
return if $input.is('.effective-file-remove-input') && !$input.closest('.effective-file-attachment--pending-removal').length
|
|
8
|
+
$input.removeAttr('disabled')
|
|
9
|
+
|
|
10
|
+
|
|
3
11
|
# When multiple show_if blocks contain radio buttons with the same name, the browser only keeps the last one checked.
|
|
4
12
|
# If that radio is in a # hidden/disabled block, the visible block's radio won't be checked.
|
|
5
13
|
# This syncs the checked state from disabled radios to their enabled counterparts.
|
|
@@ -34,7 +42,7 @@ syncDisabledRadioButtons = ($container) ->
|
|
|
34
42
|
$element.find(elementSelector).prop('disabled', true)
|
|
35
43
|
else
|
|
36
44
|
$element.fadeIn()
|
|
37
|
-
|
|
45
|
+
enableFields($element)
|
|
38
46
|
$element.find('textarea.effective_article_editor').each (i, editor) -> ArticleEditor('#' + $(editor).attr('id')).enable()
|
|
39
47
|
|
|
40
48
|
# Maybe disable it now
|
|
@@ -65,7 +73,7 @@ syncDisabledRadioButtons = ($container) ->
|
|
|
65
73
|
|
|
66
74
|
if matches
|
|
67
75
|
$element.fadeIn()
|
|
68
|
-
|
|
76
|
+
enableFields($element)
|
|
69
77
|
$element.find('textarea.effective_article_editor').each (i, editor) -> ArticleEditor('#' + $(editor).attr('id')).enable()
|
|
70
78
|
else
|
|
71
79
|
$element.hide()
|
|
@@ -101,7 +109,7 @@ syncDisabledRadioButtons = ($container) ->
|
|
|
101
109
|
|
|
102
110
|
if found
|
|
103
111
|
$element.fadeIn()
|
|
104
|
-
|
|
112
|
+
enableFields($element)
|
|
105
113
|
$element.find('textarea.effective_article_editor').each (i, editor) -> ArticleEditor('#' + $(editor).attr('id')).enable()
|
|
106
114
|
|
|
107
115
|
else
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
+
clipboard = null
|
|
2
|
+
|
|
3
|
+
destroy = ->
|
|
4
|
+
clipboard?.destroy()
|
|
5
|
+
clipboard = null
|
|
6
|
+
$('.btn-clipboard-copy.initialized').off('click.effective-clipboard').removeClass('initialized').each ->
|
|
7
|
+
$(@).html($(@).data('clipboard-label'))
|
|
8
|
+
|
|
1
9
|
initialize = ->
|
|
10
|
+
destroy()
|
|
2
11
|
$buttons = $('.btn-clipboard-copy:not(.initialized)')
|
|
3
12
|
return if $buttons.length == 0
|
|
4
13
|
|
|
@@ -10,10 +19,10 @@ initialize = ->
|
|
|
10
19
|
$obj = $(event.trigger).text('Copied!').focus().blur()
|
|
11
20
|
setTimeout((-> $obj.html($obj.data('clipboard-label'))), 1500)
|
|
12
21
|
|
|
13
|
-
$buttons.on 'click', (event) -> event.preventDefault()
|
|
22
|
+
$buttons.on 'click.effective-clipboard', (event) -> event.preventDefault()
|
|
14
23
|
|
|
15
24
|
$buttons.addClass('initialized')
|
|
16
25
|
|
|
17
26
|
$ -> initialize()
|
|
18
27
|
$(document).on 'turbolinks:load turbo:load', -> initialize()
|
|
19
|
-
$(document).on 'turbolinks:before-cache turbo:before-cache', ->
|
|
28
|
+
$(document).on 'turbolinks:before-cache turbo:before-cache', -> destroy()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
$(document).on 'turbolinks:before-cache turbo:before-cache', ->
|
|
2
2
|
$('input.initialized.effective_date_time_picker').each (i, element) ->
|
|
3
3
|
$input = $(element)
|
|
4
|
-
$input.datetimepicker('destroy') if $input.data('
|
|
4
|
+
$input.datetimepicker('destroy') if $input.data('DateTimePicker')
|
|
5
5
|
$input.removeClass('initialized')
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
disableRemovedFields = ($fields) ->
|
|
2
|
+
# Rails still needs the record ID and destruction flag to delete persisted rows.
|
|
3
|
+
$fields.find('input,textarea,select,button').not("input[type=hidden][name$='[id]'],input[type=hidden][name$='[_destroy]']").prop('disabled', true)
|
|
4
|
+
|
|
1
5
|
assignPositions = (target) ->
|
|
2
6
|
$hasMany = $(target)
|
|
3
7
|
return unless $hasMany.length > 0
|
|
@@ -16,6 +20,8 @@ assignPositions = (target) ->
|
|
|
16
20
|
true
|
|
17
21
|
|
|
18
22
|
(this.EffectiveBootstrap || {}).effective_has_many = ($element, options) ->
|
|
23
|
+
disableRemovedFields($element.find('.has-many-fields.marked-for-destruction'))
|
|
24
|
+
|
|
19
25
|
if options.sortable
|
|
20
26
|
# https://github.com/SortableJS/Sortable
|
|
21
27
|
$element.sortable({
|
|
@@ -64,13 +70,15 @@ $(document).on 'click', '[data-effective-form-has-many-insert]', (event) ->
|
|
|
64
70
|
$(document).on 'click', '[data-effective-form-has-many-remove-disabled]', (event) ->
|
|
65
71
|
event.preventDefault()
|
|
66
72
|
|
|
67
|
-
$(document).on 'click', '[data-effective-form-has-many-remove]', (event) ->
|
|
68
|
-
event.preventDefault()
|
|
69
|
-
|
|
73
|
+
$(document).on 'click confirm:complete', '[data-effective-form-has-many-remove]', (event, answer) ->
|
|
70
74
|
$obj = $(event.currentTarget)
|
|
71
75
|
|
|
72
|
-
if
|
|
73
|
-
|
|
76
|
+
if event.type == 'click'
|
|
77
|
+
event.preventDefault()
|
|
78
|
+
# Let Rails finish confirmation before disabling the row, including this button.
|
|
79
|
+
return if $obj.data('confirm') && (window.Rails || $.rails)
|
|
80
|
+
else
|
|
81
|
+
return unless answer || event.originalEvent?.detail?[0]
|
|
74
82
|
|
|
75
83
|
$hasMany = $obj.closest('.form-has-many')
|
|
76
84
|
return unless $hasMany.length > 0
|
|
@@ -78,6 +86,8 @@ $(document).on 'click', '[data-effective-form-has-many-remove]', (event) ->
|
|
|
78
86
|
$input = $obj.siblings("input[name$='[_destroy]']").first()
|
|
79
87
|
$fields = $obj.closest('.has-many-fields').first()
|
|
80
88
|
|
|
89
|
+
disableRemovedFields($fields)
|
|
90
|
+
|
|
81
91
|
if $input.length > 0
|
|
82
92
|
$input.val('true')
|
|
83
93
|
$fields.addClass('marked-for-destruction').fadeOut('fast')
|
|
@@ -18,7 +18,7 @@ module EffectiveFormBuilderHelper
|
|
|
18
18
|
"new_#{class_name}"
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this)')
|
|
21
|
+
options[:html] = (options[:html] || {}).merge(novalidate: true, onsubmit: 'return EffectiveForm.validate(this, event)')
|
|
22
22
|
options[:html]['data-turbo'] = false
|
|
23
23
|
options[:local] = true unless options.key?(:local)
|
|
24
24
|
|
|
@@ -52,7 +52,7 @@ module Effective
|
|
|
52
52
|
if multiple?
|
|
53
53
|
@builder.hidden_field(name, multiple: true, id: (tag_id + "_#{index}"), value: attachment.signed_id)
|
|
54
54
|
else
|
|
55
|
-
@builder.hidden_field(name, id: tag_id, value: attachment.signed_id)
|
|
55
|
+
@builder.hidden_field(name, id: "#{tag_id}_attachment", value: attachment.signed_id)
|
|
56
56
|
end
|
|
57
57
|
end.join.html_safe
|
|
58
58
|
end
|