effective_bootstrap 0.11.19 → 0.11.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/form_inputs/file_field.rb +48 -4
- 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
|
@@ -27,14 +27,31 @@ module Effective
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def multiple?
|
30
|
-
|
30
|
+
return @multiple unless @multiple.nil?
|
31
|
+
@multiple = options.key?(:multiple) ? options.delete(:multiple) : (name.to_s.pluralize == name.to_s)
|
32
|
+
end
|
33
|
+
|
34
|
+
def append?
|
35
|
+
return @append unless @append.nil?
|
36
|
+
@append = options[:input].key?(:append) ? options[:input].delete(:append) : false
|
31
37
|
end
|
32
38
|
|
33
39
|
def required_presence?(obj, name)
|
34
|
-
super(obj, name) &&
|
40
|
+
super(obj, name) && attachments_blank?
|
35
41
|
end
|
36
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
|
37
52
|
def build_existing_attachments
|
53
|
+
return ''.html_safe unless append?
|
54
|
+
|
38
55
|
attachments = Array(object.send(name))
|
39
56
|
|
40
57
|
attachments.map.with_index do |attachment, index|
|
@@ -126,7 +143,17 @@ module Effective
|
|
126
143
|
end.html_safe
|
127
144
|
end
|
128
145
|
end
|
146
|
+
end
|
129
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
|
130
157
|
end
|
131
158
|
|
132
159
|
def build_uploads
|
@@ -140,6 +167,23 @@ module Effective
|
|
140
167
|
end
|
141
168
|
end
|
142
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
|
+
|
143
187
|
def click_submit?
|
144
188
|
return @click_submit unless @click_submit.nil?
|
145
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
|