simple_form_bs5_file_input 0.1.2 → 0.1.4
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/Gemfile.lock +91 -109
- data/LICENSE +1 -1
- data/README.md +11 -0
- data/assets/javascripts/simple_form_bs5_file_input.js +11 -2
- data/assets/stylesheets/simple_form_bs5_file_input.sass +2 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/fr.yml +1 -0
- data/lib/has_one_attached_deletable.rb +24 -7
- data/lib/simple_form_bs5_file_input/single_deletable_file_input.rb +12 -3
- data/lib/simple_form_bs5_file_input/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c6de03deab13bcd2b04cafd400703a4930b41f052252a0a04b26a1ab4d711bee
|
|
4
|
+
data.tar.gz: e982a48904f91e03a99f9606932e2d19ac74a72b9683dd8e253f76a7661df681
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3add824407e780a435a807fb89c9893856ba1e8fb761c65c2e2447b16b94e2fa138936c7041a39c034566fbae9cd31efca28086ad1841a52ab5db9c6b5205633
|
|
7
|
+
data.tar.gz: 444e0fa76d961e58ef0c1a911e468c5945057aefbc9929622620d646e85b15153e4adebbd41aeb10b71b482bc679c60a847ea947ba22760663761d4485978fd4
|
data/Gemfile.lock
CHANGED
|
@@ -1,77 +1,78 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
simple_form_bs5_file_input (0.1.
|
|
4
|
+
simple_form_bs5_file_input (0.1.4)
|
|
5
5
|
rails
|
|
6
6
|
simple_form
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actioncable (7.1.
|
|
12
|
-
actionpack (= 7.1.
|
|
13
|
-
activesupport (= 7.1.
|
|
11
|
+
actioncable (7.1.3.2)
|
|
12
|
+
actionpack (= 7.1.3.2)
|
|
13
|
+
activesupport (= 7.1.3.2)
|
|
14
14
|
nio4r (~> 2.0)
|
|
15
15
|
websocket-driver (>= 0.6.1)
|
|
16
16
|
zeitwerk (~> 2.6)
|
|
17
|
-
actionmailbox (7.1.
|
|
18
|
-
actionpack (= 7.1.
|
|
19
|
-
activejob (= 7.1.
|
|
20
|
-
activerecord (= 7.1.
|
|
21
|
-
activestorage (= 7.1.
|
|
22
|
-
activesupport (= 7.1.
|
|
17
|
+
actionmailbox (7.1.3.2)
|
|
18
|
+
actionpack (= 7.1.3.2)
|
|
19
|
+
activejob (= 7.1.3.2)
|
|
20
|
+
activerecord (= 7.1.3.2)
|
|
21
|
+
activestorage (= 7.1.3.2)
|
|
22
|
+
activesupport (= 7.1.3.2)
|
|
23
23
|
mail (>= 2.7.1)
|
|
24
24
|
net-imap
|
|
25
25
|
net-pop
|
|
26
26
|
net-smtp
|
|
27
|
-
actionmailer (7.1.
|
|
28
|
-
actionpack (= 7.1.
|
|
29
|
-
actionview (= 7.1.
|
|
30
|
-
activejob (= 7.1.
|
|
31
|
-
activesupport (= 7.1.
|
|
27
|
+
actionmailer (7.1.3.2)
|
|
28
|
+
actionpack (= 7.1.3.2)
|
|
29
|
+
actionview (= 7.1.3.2)
|
|
30
|
+
activejob (= 7.1.3.2)
|
|
31
|
+
activesupport (= 7.1.3.2)
|
|
32
32
|
mail (~> 2.5, >= 2.5.4)
|
|
33
33
|
net-imap
|
|
34
34
|
net-pop
|
|
35
35
|
net-smtp
|
|
36
36
|
rails-dom-testing (~> 2.2)
|
|
37
|
-
actionpack (7.1.
|
|
38
|
-
actionview (= 7.1.
|
|
39
|
-
activesupport (= 7.1.
|
|
37
|
+
actionpack (7.1.3.2)
|
|
38
|
+
actionview (= 7.1.3.2)
|
|
39
|
+
activesupport (= 7.1.3.2)
|
|
40
40
|
nokogiri (>= 1.8.5)
|
|
41
|
+
racc
|
|
41
42
|
rack (>= 2.2.4)
|
|
42
43
|
rack-session (>= 1.0.1)
|
|
43
44
|
rack-test (>= 0.6.3)
|
|
44
45
|
rails-dom-testing (~> 2.2)
|
|
45
46
|
rails-html-sanitizer (~> 1.6)
|
|
46
|
-
actiontext (7.1.
|
|
47
|
-
actionpack (= 7.1.
|
|
48
|
-
activerecord (= 7.1.
|
|
49
|
-
activestorage (= 7.1.
|
|
50
|
-
activesupport (= 7.1.
|
|
47
|
+
actiontext (7.1.3.2)
|
|
48
|
+
actionpack (= 7.1.3.2)
|
|
49
|
+
activerecord (= 7.1.3.2)
|
|
50
|
+
activestorage (= 7.1.3.2)
|
|
51
|
+
activesupport (= 7.1.3.2)
|
|
51
52
|
globalid (>= 0.6.0)
|
|
52
53
|
nokogiri (>= 1.8.5)
|
|
53
|
-
actionview (7.1.
|
|
54
|
-
activesupport (= 7.1.
|
|
54
|
+
actionview (7.1.3.2)
|
|
55
|
+
activesupport (= 7.1.3.2)
|
|
55
56
|
builder (~> 3.1)
|
|
56
57
|
erubi (~> 1.11)
|
|
57
58
|
rails-dom-testing (~> 2.2)
|
|
58
59
|
rails-html-sanitizer (~> 1.6)
|
|
59
|
-
activejob (7.1.
|
|
60
|
-
activesupport (= 7.1.
|
|
60
|
+
activejob (7.1.3.2)
|
|
61
|
+
activesupport (= 7.1.3.2)
|
|
61
62
|
globalid (>= 0.3.6)
|
|
62
|
-
activemodel (7.1.
|
|
63
|
-
activesupport (= 7.1.
|
|
64
|
-
activerecord (7.1.
|
|
65
|
-
activemodel (= 7.1.
|
|
66
|
-
activesupport (= 7.1.
|
|
63
|
+
activemodel (7.1.3.2)
|
|
64
|
+
activesupport (= 7.1.3.2)
|
|
65
|
+
activerecord (7.1.3.2)
|
|
66
|
+
activemodel (= 7.1.3.2)
|
|
67
|
+
activesupport (= 7.1.3.2)
|
|
67
68
|
timeout (>= 0.4.0)
|
|
68
|
-
activestorage (7.1.
|
|
69
|
-
actionpack (= 7.1.
|
|
70
|
-
activejob (= 7.1.
|
|
71
|
-
activerecord (= 7.1.
|
|
72
|
-
activesupport (= 7.1.
|
|
69
|
+
activestorage (7.1.3.2)
|
|
70
|
+
actionpack (= 7.1.3.2)
|
|
71
|
+
activejob (= 7.1.3.2)
|
|
72
|
+
activerecord (= 7.1.3.2)
|
|
73
|
+
activesupport (= 7.1.3.2)
|
|
73
74
|
marcel (~> 1.0)
|
|
74
|
-
activesupport (7.1.
|
|
75
|
+
activesupport (7.1.3.2)
|
|
75
76
|
base64
|
|
76
77
|
bigdecimal
|
|
77
78
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
@@ -81,49 +82,47 @@ GEM
|
|
|
81
82
|
minitest (>= 5.1)
|
|
82
83
|
mutex_m
|
|
83
84
|
tzinfo (~> 2.0)
|
|
84
|
-
autoprefixer-rails (10.4.
|
|
85
|
+
autoprefixer-rails (10.4.16.0)
|
|
85
86
|
execjs (~> 2)
|
|
86
|
-
base64 (0.
|
|
87
|
-
bcrypt (3.1.
|
|
88
|
-
bigdecimal (3.1.
|
|
89
|
-
bootsnap (1.
|
|
87
|
+
base64 (0.2.0)
|
|
88
|
+
bcrypt (3.1.20)
|
|
89
|
+
bigdecimal (3.1.7)
|
|
90
|
+
bootsnap (1.18.3)
|
|
90
91
|
msgpack (~> 1.2)
|
|
91
|
-
bootstrap (5.3.
|
|
92
|
+
bootstrap (5.3.2)
|
|
92
93
|
autoprefixer-rails (>= 9.1.0)
|
|
93
94
|
popper_js (>= 2.11.8, < 3)
|
|
94
|
-
sassc-rails (>= 2.0.0)
|
|
95
95
|
builder (3.2.4)
|
|
96
|
-
concurrent-ruby (1.2.
|
|
96
|
+
concurrent-ruby (1.2.3)
|
|
97
97
|
connection_pool (2.4.1)
|
|
98
98
|
crass (1.0.6)
|
|
99
|
-
date (3.3.
|
|
99
|
+
date (3.3.4)
|
|
100
100
|
devise (4.9.3)
|
|
101
101
|
bcrypt (~> 3.0)
|
|
102
102
|
orm_adapter (~> 0.1)
|
|
103
103
|
railties (>= 4.1.0)
|
|
104
104
|
responders
|
|
105
105
|
warden (~> 1.2.3)
|
|
106
|
-
drb (2.
|
|
107
|
-
ruby2_keywords
|
|
106
|
+
drb (2.2.1)
|
|
108
107
|
erubi (1.12.0)
|
|
109
108
|
execjs (2.9.1)
|
|
110
109
|
ffi (1.16.3)
|
|
111
110
|
globalid (1.2.1)
|
|
112
111
|
activesupport (>= 6.1)
|
|
113
|
-
i18n (1.14.
|
|
112
|
+
i18n (1.14.4)
|
|
114
113
|
concurrent-ruby (~> 1.0)
|
|
115
|
-
io-console (0.
|
|
116
|
-
irb (1.
|
|
114
|
+
io-console (0.7.2)
|
|
115
|
+
irb (1.12.0)
|
|
117
116
|
rdoc
|
|
118
|
-
reline (>= 0.
|
|
117
|
+
reline (>= 0.4.2)
|
|
119
118
|
jquery-rails (4.6.0)
|
|
120
119
|
rails-dom-testing (>= 1, < 3)
|
|
121
120
|
railties (>= 4.2.0)
|
|
122
121
|
thor (>= 0.14, < 2.0)
|
|
123
|
-
listen (3.
|
|
122
|
+
listen (3.9.0)
|
|
124
123
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
|
125
124
|
rb-inotify (~> 0.9, >= 0.9.10)
|
|
126
|
-
loofah (2.
|
|
125
|
+
loofah (2.22.0)
|
|
127
126
|
crass (~> 1.0.2)
|
|
128
127
|
nokogiri (>= 1.12.0)
|
|
129
128
|
mail (2.8.1)
|
|
@@ -131,32 +130,32 @@ GEM
|
|
|
131
130
|
net-imap
|
|
132
131
|
net-pop
|
|
133
132
|
net-smtp
|
|
134
|
-
marcel (1.0.
|
|
133
|
+
marcel (1.0.4)
|
|
135
134
|
mini_mime (1.1.5)
|
|
136
|
-
mini_portile2 (2.8.
|
|
137
|
-
minitest (5.
|
|
135
|
+
mini_portile2 (2.8.5)
|
|
136
|
+
minitest (5.22.3)
|
|
138
137
|
msgpack (1.7.2)
|
|
139
|
-
mutex_m (0.
|
|
140
|
-
net-imap (0.4.
|
|
138
|
+
mutex_m (0.2.0)
|
|
139
|
+
net-imap (0.4.10)
|
|
141
140
|
date
|
|
142
141
|
net-protocol
|
|
143
142
|
net-pop (0.1.2)
|
|
144
143
|
net-protocol
|
|
145
|
-
net-protocol (0.2.
|
|
144
|
+
net-protocol (0.2.2)
|
|
146
145
|
timeout
|
|
147
|
-
net-smtp (0.4.0)
|
|
146
|
+
net-smtp (0.4.0.1)
|
|
148
147
|
net-protocol
|
|
149
|
-
nio4r (2.
|
|
150
|
-
nokogiri (1.
|
|
148
|
+
nio4r (2.7.0)
|
|
149
|
+
nokogiri (1.16.2)
|
|
151
150
|
mini_portile2 (~> 2.8.2)
|
|
152
151
|
racc (~> 1.4)
|
|
153
152
|
orm_adapter (0.5.0)
|
|
154
|
-
pg (1.5.
|
|
153
|
+
pg (1.5.6)
|
|
155
154
|
popper_js (2.11.8)
|
|
156
|
-
psych (5.1.
|
|
155
|
+
psych (5.1.2)
|
|
157
156
|
stringio
|
|
158
|
-
racc (1.7.
|
|
159
|
-
rack (3.0.
|
|
157
|
+
racc (1.7.3)
|
|
158
|
+
rack (3.0.9.1)
|
|
160
159
|
rack-session (2.0.0)
|
|
161
160
|
rack (>= 3.0.0)
|
|
162
161
|
rack-test (2.1.0)
|
|
@@ -164,20 +163,20 @@ GEM
|
|
|
164
163
|
rackup (2.1.0)
|
|
165
164
|
rack (>= 3)
|
|
166
165
|
webrick (~> 1.8)
|
|
167
|
-
rails (7.1.
|
|
168
|
-
actioncable (= 7.1.
|
|
169
|
-
actionmailbox (= 7.1.
|
|
170
|
-
actionmailer (= 7.1.
|
|
171
|
-
actionpack (= 7.1.
|
|
172
|
-
actiontext (= 7.1.
|
|
173
|
-
actionview (= 7.1.
|
|
174
|
-
activejob (= 7.1.
|
|
175
|
-
activemodel (= 7.1.
|
|
176
|
-
activerecord (= 7.1.
|
|
177
|
-
activestorage (= 7.1.
|
|
178
|
-
activesupport (= 7.1.
|
|
166
|
+
rails (7.1.3.2)
|
|
167
|
+
actioncable (= 7.1.3.2)
|
|
168
|
+
actionmailbox (= 7.1.3.2)
|
|
169
|
+
actionmailer (= 7.1.3.2)
|
|
170
|
+
actionpack (= 7.1.3.2)
|
|
171
|
+
actiontext (= 7.1.3.2)
|
|
172
|
+
actionview (= 7.1.3.2)
|
|
173
|
+
activejob (= 7.1.3.2)
|
|
174
|
+
activemodel (= 7.1.3.2)
|
|
175
|
+
activerecord (= 7.1.3.2)
|
|
176
|
+
activestorage (= 7.1.3.2)
|
|
177
|
+
activesupport (= 7.1.3.2)
|
|
179
178
|
bundler (>= 1.15.0)
|
|
180
|
-
railties (= 7.1.
|
|
179
|
+
railties (= 7.1.3.2)
|
|
181
180
|
rails-dom-testing (2.2.0)
|
|
182
181
|
activesupport (>= 5.0.0)
|
|
183
182
|
minitest
|
|
@@ -185,50 +184,33 @@ GEM
|
|
|
185
184
|
rails-html-sanitizer (1.6.0)
|
|
186
185
|
loofah (~> 2.21)
|
|
187
186
|
nokogiri (~> 1.14)
|
|
188
|
-
railties (7.1.
|
|
189
|
-
actionpack (= 7.1.
|
|
190
|
-
activesupport (= 7.1.
|
|
187
|
+
railties (7.1.3.2)
|
|
188
|
+
actionpack (= 7.1.3.2)
|
|
189
|
+
activesupport (= 7.1.3.2)
|
|
191
190
|
irb
|
|
192
191
|
rackup (>= 1.0.0)
|
|
193
192
|
rake (>= 12.2)
|
|
194
193
|
thor (~> 1.0, >= 1.2.2)
|
|
195
194
|
zeitwerk (~> 2.6)
|
|
196
|
-
rake (13.0
|
|
195
|
+
rake (13.1.0)
|
|
197
196
|
rb-fsevent (0.11.2)
|
|
198
197
|
rb-inotify (0.10.1)
|
|
199
198
|
ffi (~> 1.0)
|
|
200
|
-
rdoc (6.
|
|
199
|
+
rdoc (6.6.2)
|
|
201
200
|
psych (>= 4.0.0)
|
|
202
|
-
reline (0.3
|
|
201
|
+
reline (0.4.3)
|
|
203
202
|
io-console (~> 0.5)
|
|
204
203
|
responders (3.1.1)
|
|
205
204
|
actionpack (>= 5.2)
|
|
206
205
|
railties (>= 5.2)
|
|
207
|
-
ruby2_keywords (0.0.5)
|
|
208
|
-
sassc (2.4.0)
|
|
209
|
-
ffi (~> 1.9)
|
|
210
|
-
sassc-rails (2.1.2)
|
|
211
|
-
railties (>= 4.0.0)
|
|
212
|
-
sassc (>= 2.0)
|
|
213
|
-
sprockets (> 3.0)
|
|
214
|
-
sprockets-rails
|
|
215
|
-
tilt
|
|
216
206
|
simple_form (5.3.0)
|
|
217
207
|
actionpack (>= 5.2)
|
|
218
208
|
activemodel (>= 5.2)
|
|
219
|
-
|
|
220
|
-
concurrent-ruby (~> 1.0)
|
|
221
|
-
rack (>= 2.2.4, < 4)
|
|
222
|
-
sprockets-rails (3.4.2)
|
|
223
|
-
actionpack (>= 5.2)
|
|
224
|
-
activesupport (>= 5.2)
|
|
225
|
-
sprockets (>= 3.0.0)
|
|
226
|
-
sqlite3 (1.6.7)
|
|
209
|
+
sqlite3 (1.7.2)
|
|
227
210
|
mini_portile2 (~> 2.8.0)
|
|
228
|
-
stringio (3.0
|
|
229
|
-
thor (1.
|
|
230
|
-
|
|
231
|
-
timeout (0.4.0)
|
|
211
|
+
stringio (3.1.0)
|
|
212
|
+
thor (1.3.1)
|
|
213
|
+
timeout (0.4.1)
|
|
232
214
|
tzinfo (2.0.6)
|
|
233
215
|
concurrent-ruby (~> 1.0)
|
|
234
216
|
warden (1.2.9)
|
|
@@ -237,7 +219,7 @@ GEM
|
|
|
237
219
|
websocket-driver (0.7.6)
|
|
238
220
|
websocket-extensions (>= 0.1.0)
|
|
239
221
|
websocket-extensions (0.1.5)
|
|
240
|
-
zeitwerk (2.6.
|
|
222
|
+
zeitwerk (2.6.13)
|
|
241
223
|
|
|
242
224
|
PLATFORMS
|
|
243
225
|
ruby
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -139,6 +139,17 @@ end
|
|
|
139
139
|
|
|
140
140
|
**Simple Form Bootstrap 5 File Input** uses the I18n API to manage the texts displayed. Feel free to overwrite the keys or add languages.
|
|
141
141
|
|
|
142
|
+
## Notes
|
|
143
|
+
|
|
144
|
+
### Callbacks
|
|
145
|
+
|
|
146
|
+
When the resize feature is activated **Simple Form Bootstrap 5 File Input** uses an `after_commit` hook to resize the image. The model linked to the attachment will then be touched.
|
|
147
|
+
It might cause a problem because messing with others `after_commit` hooks. For example it messes with the Devise `confirmable` module, where the confirmation email is also send on after_commit.
|
|
148
|
+
Before Rails 7.1 after_commit is the only hook executed backward. So if you add after_commit :function1, then after_commit :function2, function2 will be executed BEFORE function1.
|
|
149
|
+
After Rails 7.1 after_commit follows the regular order, so function1 will be executed before function2.
|
|
150
|
+
So for Devise Confirmable, it must be declared AFTER the `has_one_attached_deletable` declaration if Rails version < 7.1, and declared BEFORE the `has_one_attached_deletable` declaration if Rails version >= 7.1
|
|
151
|
+
|
|
152
|
+
|
|
142
153
|
## Information
|
|
143
154
|
|
|
144
155
|
### Supported Ruby / Rails versions
|
|
@@ -78,7 +78,7 @@ window.inputSingleDeletableFile = {
|
|
|
78
78
|
image = $modal.attr('data-image-result'),
|
|
79
79
|
ratio = $imgContainer.attr('data-ratio');
|
|
80
80
|
|
|
81
|
-
$imgContainer.html('<img class="js-" src="' + image + '">');
|
|
81
|
+
$imgContainer.html('<img class="js-image" src="' + image + '">');
|
|
82
82
|
|
|
83
83
|
$image = $('img', $imgContainer);
|
|
84
84
|
$image.css('opacity', 0);
|
|
@@ -100,6 +100,14 @@ window.inputSingleDeletableFile = {
|
|
|
100
100
|
}, 100);
|
|
101
101
|
},
|
|
102
102
|
|
|
103
|
+
onResizeModalRotate: function (e) {
|
|
104
|
+
'use strict';
|
|
105
|
+
var $scope = $(e.target).parents('.js-sdfi-deletable-file'),
|
|
106
|
+
$imgContainer = $('.js-sdfi-sdfi-deletable-file__resize-image', $scope),
|
|
107
|
+
$image = $('.js-image', $imgContainer);
|
|
108
|
+
$image.cropper('rotate', 90);
|
|
109
|
+
},
|
|
110
|
+
|
|
103
111
|
onResizeModalCancel: function (e) {
|
|
104
112
|
'use strict';
|
|
105
113
|
var $scope = $(e.target).parents('.js-sdfi-deletable-file');
|
|
@@ -147,8 +155,9 @@ window.inputSingleDeletableFile = {
|
|
|
147
155
|
});
|
|
148
156
|
$('.js-sdfi-deletable-file__delete-btn', $(field)).on('click', this.onFileDelete);
|
|
149
157
|
$('input[type="file"]', $(field)).on('change', this.onFileSelected);
|
|
150
|
-
|
|
158
|
+
|
|
151
159
|
$('.js-sdfi-deletable-file__resize', field).on('shown.bs.modal', this.onResizeModalShown);
|
|
160
|
+
$('.js-sdfi-deletable-file__resize-rotate', field).on('click', this.onResizeModalRotate);
|
|
152
161
|
$('.js-sdfi-deletable-file__resize-cancel', field).on('click', this.onResizeModalCancel);
|
|
153
162
|
$('.js-sdfi-deletable-file__resize-validate', field).on('click', this.onResizeModalValidate);
|
|
154
163
|
}
|
data/config/locales/en.yml
CHANGED
data/config/locales/fr.yml
CHANGED
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
class ActiveRecord::Base
|
|
2
2
|
def self.has_one_attached_deletable(name, **options, &block)
|
|
3
|
+
|
|
3
4
|
class_eval do
|
|
4
5
|
attr_accessor :"#{name}_delete"
|
|
5
6
|
attr_accessor :"#{name}_infos"
|
|
6
7
|
|
|
7
8
|
before_validation { send(name).purge_later if send("#{name}_attachment").present? && send("#{name}_delete") == 'true' }
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
# From Rails 7.1, after_commit callbacks run in the same order they were defined.
|
|
11
|
+
# Prior to this version, they ran in reverse order.
|
|
12
|
+
after_commit_callbacks_run_in_order = Rails
|
|
13
|
+
.application
|
|
14
|
+
.config
|
|
15
|
+
.active_record
|
|
16
|
+
.try(:run_after_transaction_callbacks_in_order_defined)
|
|
17
|
+
if after_commit_callbacks_run_in_order
|
|
18
|
+
has_one_attached name, **options, &block
|
|
19
|
+
after_commit :"resize_#{name}", unless: Proc.new { |u| u.send("#{name}_infos").blank? }
|
|
20
|
+
else
|
|
21
|
+
after_commit :"resize_#{name}", unless: Proc.new { |u| u.send("#{name}_infos").blank? }
|
|
22
|
+
has_one_attached name, **options, &block
|
|
23
|
+
end
|
|
9
24
|
|
|
10
25
|
define_method :"#{name}_delete=" do |value|
|
|
11
26
|
instance_variable_set :"@#{name}_delete", value
|
|
@@ -21,12 +36,16 @@ class ActiveRecord::Base
|
|
|
21
36
|
|
|
22
37
|
# From Rails 6, ImageProcessing uses an 'auto-orient' by default to interpret the EXIF Orientation metadata.
|
|
23
38
|
# We declare it in the transformations hash for Rails 5
|
|
24
|
-
transformations = {
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
transformations = { :'auto-orient' => true }
|
|
40
|
+
# Handle rotation
|
|
41
|
+
transformations[:rotate] = params['rotate'] if params['rotate'].present?
|
|
42
|
+
# Handle cropping
|
|
43
|
+
transformations[:crop] = "#{params['width'].round}x#{params['height'].round}+#{params['x'].round}+#{params['y'].round}"
|
|
44
|
+
# Finalize by repaging
|
|
45
|
+
transformations.merge!({
|
|
27
46
|
repage: true,
|
|
28
47
|
:'+' => true
|
|
29
|
-
}
|
|
48
|
+
})
|
|
30
49
|
|
|
31
50
|
variant = Rails::VERSION::MAJOR >= 6 ? send(name).variant(**transformations)
|
|
32
51
|
: send(name).variant(combine_options: transformations)
|
|
@@ -48,7 +67,5 @@ class ActiveRecord::Base
|
|
|
48
67
|
end
|
|
49
68
|
end
|
|
50
69
|
end
|
|
51
|
-
|
|
52
|
-
has_one_attached name, **options, &block
|
|
53
70
|
end
|
|
54
71
|
end
|
|
@@ -92,12 +92,17 @@ class SingleDeletableFileInput < SimpleForm::Inputs::Base
|
|
|
92
92
|
</div>
|
|
93
93
|
</div>
|
|
94
94
|
<div class="modal-footer">
|
|
95
|
-
<button type="button" class="btn btn-sm
|
|
96
|
-
<
|
|
95
|
+
<button type="button" class="btn btn-sm js-sdfi-deletable-file__resize-rotate" aria-label="%s">
|
|
96
|
+
<i class="bi bi-arrow-clockwise"></i>
|
|
97
|
+
</button>
|
|
98
|
+
<div>
|
|
99
|
+
<button type="button" class="btn btn-sm btn-secondary js-sdfi-deletable-file__resize-cancel" data-bs-dismiss="modal">%s</button>
|
|
100
|
+
<button type="button" class="btn btn-sm btn-primary js-sdfi-deletable-file__resize-validate">%s</button>
|
|
101
|
+
</div>
|
|
97
102
|
</div>
|
|
98
103
|
</div>
|
|
99
104
|
</div>
|
|
100
|
-
</div>', modal_title, close_btn_text, resize_ratio, close_btn_text, validate_btn_text)
|
|
105
|
+
</div>', modal_title, close_btn_text, resize_ratio, rotate_btn_text, close_btn_text, validate_btn_text)
|
|
101
106
|
end
|
|
102
107
|
end
|
|
103
108
|
|
|
@@ -141,6 +146,10 @@ class SingleDeletableFileInput < SimpleForm::Inputs::Base
|
|
|
141
146
|
I18n.t('simple_form_bs5_file_input.modal_close')
|
|
142
147
|
end
|
|
143
148
|
|
|
149
|
+
def rotate_btn_text
|
|
150
|
+
I18n.t('simple_form_bs5_file_input.modal_rotate')
|
|
151
|
+
end
|
|
152
|
+
|
|
144
153
|
def validate_btn_text
|
|
145
154
|
I18n.t('simple_form_bs5_file_input.modal_validate')
|
|
146
155
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: simple_form_bs5_file_input
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Pierre-andré Boissinot
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-03-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
110
|
version: '0'
|
|
111
111
|
requirements: []
|
|
112
|
-
rubygems_version: 3.
|
|
112
|
+
rubygems_version: 3.5.6
|
|
113
113
|
signing_key:
|
|
114
114
|
specification_version: 4
|
|
115
115
|
summary: Simple Form BS5 File Input
|