effective_bootstrap 1.26.1 → 1.26.3
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 +8 -3
- data/app/assets/javascripts/effective_bootstrap/logic.js.coffee +14 -5
- 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 +8 -0
- data/app/helpers/effective_form_builder_helper.rb +1 -1
- data/app/models/effective/form_inputs/file_field.rb +1 -1
- data/app/models/effective/form_logics/show_if.rb +5 -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: af1499bdd3b77b6451a0a196fb9c62e6e4139c5369ef49aa56a42f72cdc4f360
|
|
4
|
+
data.tar.gz: f9b452dbc296dc48db3e29132481a1bb917f5691603ffb31948236e12ab1cc39
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cdc9f65d070e5f3539fa1670b8464e78cb32559c758e73ea944574f81e369c8dea237503ed63e0c880bc4023ca2f19d2dfd63813c14586b573937be7e838e06
|
|
7
|
+
data.tar.gz: e61dd1b4bdaaf2482e54412de96c78275828f84d8672570809264580610941736a48fca4c9c6e563b2505880c9ecc9ac3608bbf09c99ddf8bcafd724e1bbec3c
|
|
@@ -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')
|
|
@@ -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
|
|
@@ -48,11 +56,12 @@ syncDisabledRadioButtons = ($container) ->
|
|
|
48
56
|
else
|
|
49
57
|
$container = $element.closest('form,div.effective-datatables-filters')
|
|
50
58
|
|
|
51
|
-
$affects = $container.find("input[name='#{options.name}'],select[name='#{options.name}'],input[name='#{options.name}[]']")
|
|
59
|
+
$affects = $container.find("input[name='#{options.name}'],select[name='#{options.name}'],select[name='#{options.name}[]'],input[name='#{options.name}[]']")
|
|
52
60
|
|
|
53
61
|
$affects.on 'change dp.change', (event) ->
|
|
54
62
|
$target = $(event.target)
|
|
55
|
-
|
|
63
|
+
selected = $target.val()
|
|
64
|
+
matches = if Array.isArray(selected) then selected.indexOf(options.value) != -1 else selected == options.value
|
|
56
65
|
|
|
57
66
|
if $target.is("[type='checkbox']")
|
|
58
67
|
if $target.attr('name').indexOf('[]') == -1
|
|
@@ -64,7 +73,7 @@ syncDisabledRadioButtons = ($container) ->
|
|
|
64
73
|
|
|
65
74
|
if matches
|
|
66
75
|
$element.fadeIn()
|
|
67
|
-
|
|
76
|
+
enableFields($element)
|
|
68
77
|
$element.find('textarea.effective_article_editor').each (i, editor) -> ArticleEditor('#' + $(editor).attr('id')).enable()
|
|
69
78
|
else
|
|
70
79
|
$element.hide()
|
|
@@ -100,7 +109,7 @@ syncDisabledRadioButtons = ($container) ->
|
|
|
100
109
|
|
|
101
110
|
if found
|
|
102
111
|
$element.fadeIn()
|
|
103
|
-
|
|
112
|
+
enableFields($element)
|
|
104
113
|
$element.find('textarea.effective_article_editor').each (i, editor) -> ArticleEditor('#' + $(editor).attr('id')).enable()
|
|
105
114
|
|
|
106
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({
|
|
@@ -78,6 +84,8 @@ $(document).on 'click', '[data-effective-form-has-many-remove]', (event) ->
|
|
|
78
84
|
$input = $obj.siblings("input[name$='[_destroy]']").first()
|
|
79
85
|
$fields = $obj.closest('.has-many-fields').first()
|
|
80
86
|
|
|
87
|
+
disableRemovedFields($fields)
|
|
88
|
+
|
|
81
89
|
if $input.length > 0
|
|
82
90
|
$input.val('true')
|
|
83
91
|
$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
|
|
@@ -37,7 +37,11 @@ module Effective
|
|
|
37
37
|
first = object.try(args.first)
|
|
38
38
|
second = args.second
|
|
39
39
|
|
|
40
|
-
first == second ||
|
|
40
|
+
first == second ||
|
|
41
|
+
first.to_s == second.to_s ||
|
|
42
|
+
Array(first) == Array(second) ||
|
|
43
|
+
Array(first.to_s) == Array(second.to_s) ||
|
|
44
|
+
Array(first).any? { |value| value.to_s == second.to_s }
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
end
|