effective_bootstrap 1.21.18 → 1.22.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/app/assets/javascripts/effective_file/initialize.js.coffee +16 -0
- data/app/assets/stylesheets/effective_file/input.scss +7 -0
- data/app/models/effective/form_inputs/file_field.rb +24 -25
- data/app/models/effective/table_builder.rb +1 -1
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c321d5d268e543127c41df4c6f31ea499b43021d1c1127b91a11445aa780f307
|
|
4
|
+
data.tar.gz: 7941d92194800d275b26872e16b93754ab385957864eee73671e471e1460cac4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9aaac1a47471607309798d803a61b7a248a327c3c528d905ae36cce254f2f2e27b3590b0b0fdb77ec75c3879d5f54ff68f3b946addf523d9dbed21d4904bd289
|
|
7
|
+
data.tar.gz: fb2a659ea5312021b4924ab455b5d92be4a0f2d74f7549558bf47b3ee85e92c76c28a52319da59d3263c7a5a6b06ee10b2f977f327fba14b7a8745bf4b22a43a
|
|
@@ -67,3 +67,19 @@ $(document).on 'drop', '.effective-file-drop-zone', (event) ->
|
|
|
67
67
|
$input[0].files = dt.files
|
|
68
68
|
|
|
69
69
|
$input.trigger('change')
|
|
70
|
+
|
|
71
|
+
# Per-file Remove / Undo toggle on existing attachments
|
|
72
|
+
$(document).on 'click', '.effective-file-remove', (event) ->
|
|
73
|
+
event.preventDefault()
|
|
74
|
+
$button = $(event.currentTarget)
|
|
75
|
+
$attachment = $button.closest('.effective-file-attachment')
|
|
76
|
+
$input = $attachment.find('.effective-file-remove-input')
|
|
77
|
+
|
|
78
|
+
if $input.prop('disabled')
|
|
79
|
+
$input.prop('disabled', false)
|
|
80
|
+
$attachment.addClass('effective-file-attachment--pending-removal')
|
|
81
|
+
$button.text('Undo').removeClass('btn-outline-danger').addClass('btn-outline-secondary')
|
|
82
|
+
else
|
|
83
|
+
$input.prop('disabled', true)
|
|
84
|
+
$attachment.removeClass('effective-file-attachment--pending-removal')
|
|
85
|
+
$button.text('Remove').removeClass('btn-outline-secondary').addClass('btn-outline-danger')
|
|
@@ -73,17 +73,19 @@ module Effective
|
|
|
73
73
|
end
|
|
74
74
|
|
|
75
75
|
def build_table_attachments(attachments)
|
|
76
|
-
content_tag(:table, class: 'table table-hover effective_file_attachments') do
|
|
76
|
+
content_tag(:table, class: 'table table-hover effective_file_attachments mt-2') do
|
|
77
77
|
content_tag(:thead) do
|
|
78
78
|
content_tag(:tr) do
|
|
79
|
-
content_tag(:th, '
|
|
79
|
+
content_tag(:th, '') +
|
|
80
80
|
content_tag(:th, 'Title') +
|
|
81
81
|
content_tag(:th, 'Size') +
|
|
82
82
|
content_tag(:th, '')
|
|
83
83
|
end
|
|
84
84
|
end +
|
|
85
85
|
content_tag(:tbody) do
|
|
86
|
-
attachments.map
|
|
86
|
+
attachments.map do |attachment|
|
|
87
|
+
content_tag(:tr, build_table_attachment(attachment), class: 'effective-file-attachment', data: { signed_id: attachment.signed_id })
|
|
88
|
+
end.join.html_safe
|
|
87
89
|
end
|
|
88
90
|
end
|
|
89
91
|
end
|
|
@@ -96,7 +98,7 @@ module Effective
|
|
|
96
98
|
|
|
97
99
|
image_tag = content_tag(:img, '', class: '', src: url, alt: attachment.filename.to_s) if attachment.image?
|
|
98
100
|
link_tag = link_to(attachment.filename, url)
|
|
99
|
-
size_tag =
|
|
101
|
+
size_tag = @template.number_to_human_size(attachment.byte_size)
|
|
100
102
|
|
|
101
103
|
content_tag(:td, image_tag) +
|
|
102
104
|
content_tag(:td, link_tag) +
|
|
@@ -105,6 +107,8 @@ module Effective
|
|
|
105
107
|
content_tag(:td) do
|
|
106
108
|
if attachments_style == :ck_assets
|
|
107
109
|
link_to('Attach', url, class: 'btn btn-primary', 'data-insert-ck-asset': true, alt: attachment.filename.to_s)
|
|
110
|
+
else
|
|
111
|
+
build_attachment_remove(attachment)
|
|
108
112
|
end
|
|
109
113
|
end
|
|
110
114
|
end
|
|
@@ -119,9 +123,9 @@ module Effective
|
|
|
119
123
|
|
|
120
124
|
return unless url
|
|
121
125
|
|
|
122
|
-
content_tag(:div, class: 'col-lg-4') do
|
|
126
|
+
content_tag(:div, class: 'col-lg-4 effective-file-attachment', data: { signed_id: attachment.signed_id }) do
|
|
123
127
|
content_tag(:div, class: 'card mb-3') do
|
|
124
|
-
if attachment.image?
|
|
128
|
+
body = if attachment.image?
|
|
125
129
|
content_tag(:div, class: 'card-body text-center') do
|
|
126
130
|
content_tag(:div, image_tag(url, alt: attachment.filename.to_s, class: 'img-fluid mb-2')) +
|
|
127
131
|
content_tag(:div, link_to(attachment.filename, url, class: 'card-link'))
|
|
@@ -129,29 +133,18 @@ module Effective
|
|
|
129
133
|
else
|
|
130
134
|
content_tag(:div, class: 'card-body') do
|
|
131
135
|
content_tag(:p, class: 'card-text') do
|
|
132
|
-
link_to(attachment.filename, url, class: 'card-link
|
|
133
|
-
('<br />' +
|
|
134
|
-
@template.number_to_human_size(attachment.byte_size
|
|
135
|
-
)).html_safe
|
|
136
|
+
link_to(attachment.filename, url, class: 'card-link') + '<br>'.html_safe + @template.number_to_human_size(attachment.byte_size)
|
|
136
137
|
end
|
|
137
138
|
end
|
|
139
|
+
end
|
|
138
140
|
|
|
139
|
-
|
|
141
|
+
body + build_attachment_remove(attachment, footer: true)
|
|
140
142
|
end
|
|
141
143
|
end
|
|
142
144
|
end
|
|
143
145
|
|
|
144
146
|
def build_uploads_and_purge(super_file_field)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if purge? && attachments_present?
|
|
148
|
-
content_tag(:div) do
|
|
149
|
-
content_tag(:div, (build_uploads + wrapped_input), class: 'mb-3') +
|
|
150
|
-
content_tag(:div, build_purge)
|
|
151
|
-
end
|
|
152
|
-
else
|
|
153
|
-
build_uploads + wrapped_input
|
|
154
|
-
end
|
|
147
|
+
build_uploads + content_tag(:div, super_file_field, class: 'effective-file-drop-zone')
|
|
155
148
|
end
|
|
156
149
|
|
|
157
150
|
def build_uploads
|
|
@@ -165,11 +158,17 @@ module Effective
|
|
|
165
158
|
end
|
|
166
159
|
end
|
|
167
160
|
|
|
168
|
-
def
|
|
169
|
-
return ''.html_safe
|
|
161
|
+
def build_attachment_remove(attachment, footer: false)
|
|
162
|
+
return ''.html_safe if disabled? || !purge?
|
|
163
|
+
|
|
164
|
+
hidden = @template.hidden_field_tag("#{@builder.object_name}[_purge][]", attachment.signed_id, disabled: true, class: 'effective-file-remove-input', id: nil)
|
|
165
|
+
button = @template.content_tag(:button, 'Remove', type: 'button', class: 'btn btn-sm btn-outline-danger effective-file-remove')
|
|
170
166
|
|
|
171
|
-
|
|
172
|
-
|
|
167
|
+
if footer
|
|
168
|
+
content_tag(:div, hidden + button, class: 'card-footer bg-transparent text-right')
|
|
169
|
+
else
|
|
170
|
+
hidden + button
|
|
171
|
+
end
|
|
173
172
|
end
|
|
174
173
|
|
|
175
174
|
def purge?
|
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: 1.
|
|
4
|
+
version: 1.22.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: 2026-
|
|
11
|
+
date: 2026-04-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|