effective_bootstrap 0.11.20 → 0.11.21
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/models/effective/form_inputs/file_field.rb +46 -3
- 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: 8f7d3d759a80f960a770651a200dd08795822a5c8e1d57b240d2c56af494e81e
|
4
|
+
data.tar.gz: 107c0dc7bdf0529edefa778fe8c56701030eb156ff0d07766424f68c6935f064
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d3e32a038a89be7ddf2e9970653dd0d8e6b2565d9daeca2cc6e0a8b6d660ca6f1bfee617ff1788a9512a6969cc1f9cdca2b15f31d30606d515c32790c14b8d2
|
7
|
+
data.tar.gz: '0323491a386671c02bc3787a585a5af61c4c11cba2d568ffffe5e029357f2ec51ef9ca28feb2129cda3cd62af288aef6ab1a6b0866ca4351e11700746ed8927e'
|
@@ -7,9 +7,9 @@ module Effective
|
|
7
7
|
def build_input(&block)
|
8
8
|
case attachments_style
|
9
9
|
when :card
|
10
|
-
build_existing_attachments + build_attachments +
|
10
|
+
build_existing_attachments + build_attachments + build_uploads_and_purge(super)
|
11
11
|
when :table, :ck_assets
|
12
|
-
|
12
|
+
build_existing_attachments + build_uploads_and_purge(super) + build_attachments
|
13
13
|
else
|
14
14
|
raise('unsupported attachments_style, try :card or :table')
|
15
15
|
end
|
@@ -31,11 +31,27 @@ module Effective
|
|
31
31
|
@multiple = options.key?(:multiple) ? options.delete(:multiple) : (name.to_s.pluralize == name.to_s)
|
32
32
|
end
|
33
33
|
|
34
|
+
def append?
|
35
|
+
return @append unless @append.nil?
|
36
|
+
@append = options[:input].key?(:append) ? options[:input].delete(:append) : false
|
37
|
+
end
|
38
|
+
|
34
39
|
def required_presence?(obj, name)
|
35
|
-
super(obj, name) &&
|
40
|
+
super(obj, name) && attachments_blank?
|
36
41
|
end
|
37
42
|
|
43
|
+
def attachments_present?
|
44
|
+
Array(object.public_send(name)).length > 0
|
45
|
+
end
|
46
|
+
|
47
|
+
def attachments_blank?
|
48
|
+
Array(object.public_send(name)).length == 0
|
49
|
+
end
|
50
|
+
|
51
|
+
# This has the affect of appending files to the has_many. Which usually isnt what we want
|
38
52
|
def build_existing_attachments
|
53
|
+
return ''.html_safe unless append?
|
54
|
+
|
39
55
|
attachments = Array(object.send(name))
|
40
56
|
|
41
57
|
attachments.map.with_index do |attachment, index|
|
@@ -127,7 +143,17 @@ module Effective
|
|
127
143
|
end.html_safe
|
128
144
|
end
|
129
145
|
end
|
146
|
+
end
|
130
147
|
|
148
|
+
def build_uploads_and_purge(super_file_field)
|
149
|
+
if purge? && attachments_present?
|
150
|
+
content_tag(:div, class: 'd-flex align-items-center') do
|
151
|
+
content_tag(:div, (build_uploads + super_file_field), class: 'flex-grow-1 mr-3') +
|
152
|
+
content_tag(:div, build_purge)
|
153
|
+
end
|
154
|
+
else
|
155
|
+
build_uploads + super_file_field
|
156
|
+
end
|
131
157
|
end
|
132
158
|
|
133
159
|
def build_uploads
|
@@ -141,6 +167,23 @@ module Effective
|
|
141
167
|
end
|
142
168
|
end
|
143
169
|
|
170
|
+
def build_purge
|
171
|
+
return ''.html_safe unless purge?
|
172
|
+
|
173
|
+
label = (multiple? ? 'Delete files on save' : 'Delete file on save')
|
174
|
+
@builder.check_box('_purge_attached', multiple: true, label: label, id: "#{tag_id}_purge_attached", checked_value: name)
|
175
|
+
end
|
176
|
+
|
177
|
+
def purge?
|
178
|
+
return @purge unless @purge.nil?
|
179
|
+
@purge = options[:input].key?(:purge) ? (options[:input].delete(:purge) && purgable?) : purgable?
|
180
|
+
end
|
181
|
+
|
182
|
+
def purgable?
|
183
|
+
return false unless object.class.try(:has_many_purgable?)
|
184
|
+
object.has_many_purgable_names.include?(name.to_sym)
|
185
|
+
end
|
186
|
+
|
144
187
|
def click_submit?
|
145
188
|
return @click_submit unless @click_submit.nil?
|
146
189
|
@click_submit ||= (options.delete(:click_submit) || false)
|
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.11.
|
4
|
+
version: 0.11.21
|
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: 2023-01-
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|