simple_form_extension 1.4.8 → 1.4.9
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/.gitignore +1 -0
- data/lib/simple_form_extension/inputs/file_input.rb +13 -6
- data/lib/simple_form_extension/inputs/image_input.rb +22 -4
- data/lib/simple_form_extension/version.rb +1 -1
- metadata +3 -8
- data/lib/simple_form_extension/.DS_Store +0 -0
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/simple_form_extension/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0338091f5342355cd9faac5bf9fbdf3e274e982
|
4
|
+
data.tar.gz: c15a1a437cca0be6afd7550f22912fa8f828fac4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab595dfbdf82e7e5667fbe2ad2ef08cafcf4202efca56fc85cefe7fa9b605a42cd353138d604565bf099609946b7ce46da61a916f4f3ea43fcd189a4e52ac58f
|
7
|
+
data.tar.gz: 48243d079d49b90c8cc7b48ba9ca1c644c5aba7a126307e1922bae5c46cc454ef5be582df34d5f15f393eed12d774d300da27f116de9dff8fc148222e43ba92c
|
data/.gitignore
CHANGED
@@ -37,9 +37,7 @@ module SimpleFormExtension
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def existing_file_tag
|
40
|
-
return '' unless
|
41
|
-
|
42
|
-
url = object.send(attribute_name).url
|
40
|
+
return '' unless file_exists?
|
43
41
|
|
44
42
|
content_tag(:div, class: 'input-group help-block existing-file', data: { provides: 'existing-file'}) do
|
45
43
|
content_tag(:span, class: 'input-group-addon') do
|
@@ -47,7 +45,7 @@ module SimpleFormExtension
|
|
47
45
|
end +
|
48
46
|
|
49
47
|
content_tag(:div, class: 'btn-group') do
|
50
|
-
content_tag(:a, class: 'btn btn-default ', href:
|
48
|
+
content_tag(:a, class: 'btn btn-default ', href: file_url, target: '_blank', data: { toggle: 'existing-file' }) do
|
51
49
|
content_tag(:i, '', class: 'fa fa-file') +
|
52
50
|
" ".html_safe +
|
53
51
|
object.send(:"#{ attribute_name }_file_name").html_safe
|
@@ -71,8 +69,17 @@ module SimpleFormExtension
|
|
71
69
|
options[:remove_method] || :"remove_#{ attribute_name }"
|
72
70
|
end
|
73
71
|
|
74
|
-
def
|
75
|
-
@
|
72
|
+
def file_exists?
|
73
|
+
@file_exists ||= object.try(:"#{ attribute_name }?") ||
|
74
|
+
object.try(attribute_name).try(:attached?)
|
75
|
+
end
|
76
|
+
|
77
|
+
def file_url
|
78
|
+
if object.try(:"#{ attribute_name }?")
|
79
|
+
object.send(attribute_name)
|
80
|
+
elsif object.try(attribute_name).try(:attached?)
|
81
|
+
object.try(attribute_name)
|
82
|
+
end
|
76
83
|
end
|
77
84
|
end
|
78
85
|
end
|
@@ -34,9 +34,8 @@ module SimpleFormExtension
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def existing_image_tag
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
# If an existing paperclip image is found
|
38
|
+
if image_exists?
|
40
39
|
container_style = 'position: relative; height: 100%; width: 100%; min-height: 50px;min-width: 58px; display: block;'
|
41
40
|
|
42
41
|
content_tag(:div, style: container_style, data: { provides: 'existing-file' }) do
|
@@ -48,6 +47,25 @@ module SimpleFormExtension
|
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
50
|
+
# Returns true if a paperclip or active_storage attachment already exists
|
51
|
+
# for that model field
|
52
|
+
#
|
53
|
+
def image_exists?
|
54
|
+
object.try(:"#{ attribute_name }?") ||
|
55
|
+
object.try(attribute_name).try(:attached?)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Returns the paperclip or active_storage attachment url to show in the
|
59
|
+
# preview thumbnail
|
60
|
+
#
|
61
|
+
def image_url
|
62
|
+
if object.try(:"#{ attribute_name }?")
|
63
|
+
object.send(attribute_name).url(image_style)
|
64
|
+
elsif object.try(attribute_name).try(:attached?)
|
65
|
+
object.try(attribute_name).variant(resize: "400x150>")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
51
69
|
def remove_image_button
|
52
70
|
return unless object.respond_to?(:"#{ remove_attachment_method }=")
|
53
71
|
|
@@ -64,7 +82,7 @@ module SimpleFormExtension
|
|
64
82
|
end
|
65
83
|
|
66
84
|
def image_style
|
67
|
-
styles =
|
85
|
+
styles = object.send(attribute_name).styles.map(&:first)
|
68
86
|
# Check if there's a :thumb or :thumbnail style in attachment definition
|
69
87
|
thumb = styles.find { |s| %w(thumb thumbnail).include?(s.to_s) }
|
70
88
|
# Return the potentially smallest size !
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glyph-fr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -114,7 +114,6 @@ files:
|
|
114
114
|
- lib/generators/simple_form_extension/templates/config/locales/simple_form_extension.fr.yml
|
115
115
|
- lib/generators/simple_form_extension/templates/config/locales/simple_form_extension.it.yml
|
116
116
|
- lib/simple_form_extension.rb
|
117
|
-
- lib/simple_form_extension/.DS_Store
|
118
117
|
- lib/simple_form_extension/components.rb
|
119
118
|
- lib/simple_form_extension/components/icons.rb
|
120
119
|
- lib/simple_form_extension/components/popovers.rb
|
@@ -136,20 +135,16 @@ files:
|
|
136
135
|
- lib/simple_form_extension/translations.rb
|
137
136
|
- lib/simple_form_extension/version.rb
|
138
137
|
- simple_form_extension.gemspec
|
139
|
-
- vendor/.DS_Store
|
140
|
-
- vendor/assets/.DS_Store
|
141
138
|
- vendor/assets/images/simple_form_extension/bootstrap-colorpicker/alpha-horizontal.png
|
142
139
|
- vendor/assets/images/simple_form_extension/bootstrap-colorpicker/alpha.png
|
143
140
|
- vendor/assets/images/simple_form_extension/bootstrap-colorpicker/hue-horizontal.png
|
144
141
|
- vendor/assets/images/simple_form_extension/bootstrap-colorpicker/hue.png
|
145
142
|
- vendor/assets/images/simple_form_extension/bootstrap-colorpicker/saturation.png
|
146
|
-
- vendor/assets/javascripts/.DS_Store
|
147
143
|
- vendor/assets/javascripts/bootstrap-colorpicker.js
|
148
144
|
- vendor/assets/javascripts/bootstrap-slider.js
|
149
145
|
- vendor/assets/javascripts/jasny-bootstrap.js
|
150
146
|
- vendor/assets/javascripts/jquery.datetimepicker.js
|
151
147
|
- vendor/assets/javascripts/simple_form_extension.coffee
|
152
|
-
- vendor/assets/javascripts/simple_form_extension/.DS_Store
|
153
148
|
- vendor/assets/javascripts/simple_form_extension/colorpicker.coffee
|
154
149
|
- vendor/assets/javascripts/simple_form_extension/datetimepicker.coffee
|
155
150
|
- vendor/assets/javascripts/simple_form_extension/fileinput.coffee
|
@@ -183,7 +178,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
178
|
version: '0'
|
184
179
|
requirements: []
|
185
180
|
rubyforge_project:
|
186
|
-
rubygems_version: 2.6.
|
181
|
+
rubygems_version: 2.6.11
|
187
182
|
signing_key:
|
188
183
|
specification_version: 4
|
189
184
|
summary: This gems adds custom common input types to simple form.
|
Binary file
|
data/vendor/.DS_Store
DELETED
Binary file
|
data/vendor/assets/.DS_Store
DELETED
Binary file
|
Binary file
|
Binary file
|