simple_form_bs5_file_input 0.1.5 → 0.2.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 76ba13ef60f2f906d584bb3ab3de58a0aac7988dcf5217e85b117eeb0bf50ea4
|
|
4
|
+
data.tar.gz: aa98b74d4577a3e45952c0071fa8609653ed41d38650ebaca58f578af30364f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6c96e619a6a5dd7a43c6be6b45916fecee5adeaa119e86133877a0182656dc392558636c859966ade7076ea2542a4d220187c112d3b214176f8f4ea062e6cf90
|
|
7
|
+
data.tar.gz: f36e2e36f3af1dec08f19fd89a2fdf59409107ba47cb3e1e36430f2a7f729a34004468e46302bbc3c61b697e61112a23b0be8f84c8b9248128b184785bd459ee
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simple_form_bs5_file_input (0.
|
|
4
|
+
simple_form_bs5_file_input (0.2.0)
|
|
5
5
|
rails
|
|
6
6
|
simple_form
|
|
7
7
|
|
|
@@ -136,16 +136,16 @@ GEM
|
|
|
136
136
|
minitest (5.22.3)
|
|
137
137
|
msgpack (1.7.2)
|
|
138
138
|
mutex_m (0.2.0)
|
|
139
|
-
net-imap (0.
|
|
139
|
+
net-imap (0.5.0)
|
|
140
140
|
date
|
|
141
141
|
net-protocol
|
|
142
142
|
net-pop (0.1.2)
|
|
143
143
|
net-protocol
|
|
144
144
|
net-protocol (0.2.2)
|
|
145
145
|
timeout
|
|
146
|
-
net-smtp (0.
|
|
146
|
+
net-smtp (0.5.0)
|
|
147
147
|
net-protocol
|
|
148
|
-
nio4r (2.7.
|
|
148
|
+
nio4r (2.7.3)
|
|
149
149
|
nokogiri (1.16.2)
|
|
150
150
|
mini_portile2 (~> 2.8.2)
|
|
151
151
|
racc (~> 1.4)
|
|
@@ -236,4 +236,4 @@ DEPENDENCIES
|
|
|
236
236
|
sqlite3
|
|
237
237
|
|
|
238
238
|
BUNDLED WITH
|
|
239
|
-
2.
|
|
239
|
+
2.5.22
|
|
@@ -34,18 +34,31 @@ class ActiveRecord::Base
|
|
|
34
34
|
# reset the infos to prevent multiple resize if multiple save
|
|
35
35
|
instance_variable_set :"@#{name}_infos", nil
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
left = params['x'].round
|
|
38
|
+
top = params['y'].round
|
|
39
|
+
width = params['width'].round
|
|
40
|
+
height = params['height'].round
|
|
41
|
+
rotation = params['rotate']
|
|
42
|
+
transformations = {}
|
|
43
|
+
byebug
|
|
44
|
+
if ActiveStorage.variant_processor == :mini_magick
|
|
45
|
+
# From Rails 6, ImageProcessing with MiniMagick uses an 'auto-orient' by default to interpret the EXIF Orientation metadata.
|
|
46
|
+
transformations[:'auto-orient'] = true
|
|
47
|
+
# Handle rotation
|
|
48
|
+
transformations[:rotate] = rotation if rotation.present?
|
|
49
|
+
# Handle cropping
|
|
50
|
+
transformations[:crop] = "#{width}x#{height}+#{left}+#{top}"
|
|
51
|
+
# Finalize by repaging
|
|
52
|
+
transformations.merge!({
|
|
53
|
+
repage: true,
|
|
54
|
+
:'+' => true
|
|
55
|
+
})
|
|
56
|
+
elsif ActiveStorage.variant_processor == :vips
|
|
57
|
+
# Handle rotation
|
|
58
|
+
transformations[:rotate] = rotation if rotation.present?
|
|
59
|
+
# Handle cropping
|
|
60
|
+
transformations[:crop] = [left, top, width, height]
|
|
61
|
+
end
|
|
49
62
|
|
|
50
63
|
variant = Rails::VERSION::MAJOR >= 6 ? send(name).variant(**transformations)
|
|
51
64
|
: send(name).variant(combine_options: transformations)
|
|
@@ -22,11 +22,17 @@ class SingleDeletableFileInput < SimpleForm::Inputs::Base
|
|
|
22
22
|
%s
|
|
23
23
|
%s
|
|
24
24
|
</div>
|
|
25
|
-
',
|
|
25
|
+
', input_wrapper_classes(wrapper_options), input_field(wrapper_options), field_classes(wrapper_options), change_file_text, field_id, existing_file_name_or_default_text, input_infos_name, input_infos_value, input_delete_name, input_delete_value, preview_div, resize_div)
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def
|
|
29
|
-
|
|
28
|
+
def input_wrapper_classes(wrapper_options)
|
|
29
|
+
classes = []
|
|
30
|
+
classes << 'sdfi-deletable-file--with-file' if should_display_file?
|
|
31
|
+
error_class = wrapper_options[:error_class]
|
|
32
|
+
classes << error_class if error_class.present? && has_errors?
|
|
33
|
+
valid_class = wrapper_options[:valid_class]
|
|
34
|
+
classes << valid_class if valid_class.present? && valid?
|
|
35
|
+
classes.join(' ')
|
|
30
36
|
end
|
|
31
37
|
|
|
32
38
|
def input_field(wrapper_options)
|
|
@@ -129,7 +135,7 @@ class SingleDeletableFileInput < SimpleForm::Inputs::Base
|
|
|
129
135
|
return unless should_display_file?
|
|
130
136
|
# Fichier invariable, pas de chocolat non plus
|
|
131
137
|
return unless file_attachment&.variable?
|
|
132
|
-
variant = file_attachment.variant(
|
|
138
|
+
variant = file_attachment.variant(resize_to_fit: [preview_image_width, nil])
|
|
133
139
|
path = url_helpers.polymorphic_url variant, only_path: true
|
|
134
140
|
image_tag path, class: 'img-fluid img-thumbnail', width: preview_image_width
|
|
135
141
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form_bs5_file_input
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pierre-andré Boissinot
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -94,7 +93,6 @@ homepage: https://github.com/noesya/simple_form_bs5_file_input
|
|
|
94
93
|
licenses:
|
|
95
94
|
- MIT
|
|
96
95
|
metadata: {}
|
|
97
|
-
post_install_message:
|
|
98
96
|
rdoc_options: []
|
|
99
97
|
require_paths:
|
|
100
98
|
- lib
|
|
@@ -109,8 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
107
|
- !ruby/object:Gem::Version
|
|
110
108
|
version: '0'
|
|
111
109
|
requirements: []
|
|
112
|
-
rubygems_version: 3.
|
|
113
|
-
signing_key:
|
|
110
|
+
rubygems_version: 3.6.9
|
|
114
111
|
specification_version: 4
|
|
115
112
|
summary: Simple Form BS5 File Input
|
|
116
113
|
test_files: []
|