simple_form_bs5_file_input 0.0.7 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +158 -118
- data/assets/javascripts/simple_form_bs5_file_input.js +18 -11
- data/lib/has_one_attached_deletable.rb +2 -2
- data/lib/simple_form_bs5_file_input/version.rb +1 -1
- metadata +2 -5
- data/pkg/simple_form_bs5_file_input-0.0.1.gem +0 -0
- data/pkg/simple_form_bs5_file_input-0.0.2.gem +0 -0
- data/pkg/simple_form_bs5_file_input-0.0.3.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fcf36f702c77c1551143f7db895119ff9e97556f97a931e55900e3432f402d0
|
4
|
+
data.tar.gz: d0bf284ad4ff6fddd906bd6818f38a8917d46739a2b097a2479cdaede1f0c719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4efe42b607e0e4a17fabe348ab84e3d95389a155889d56cec6001b76fa322411409e1999d097c4c5a941d487d1006d4905bb13fb7bb4717f65d935882af87031
|
7
|
+
data.tar.gz: 78afdfc7bb77b27c7a6ccec1b7a6756f897e7256e8019b60eaed69ea037e798f41b68a3451ae8d42b7cbabc470f0edbecefeb5d31c2123b6d664ec2ddfb73e85
|
data/Gemfile.lock
CHANGED
@@ -1,173 +1,210 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
simple_form_bs5_file_input (0.
|
4
|
+
simple_form_bs5_file_input (0.1.1)
|
5
5
|
rails
|
6
6
|
simple_form
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (7.
|
12
|
-
actionpack (= 7.
|
13
|
-
activesupport (= 7.
|
11
|
+
actioncable (7.1.1)
|
12
|
+
actionpack (= 7.1.1)
|
13
|
+
activesupport (= 7.1.1)
|
14
14
|
nio4r (~> 2.0)
|
15
15
|
websocket-driver (>= 0.6.1)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
zeitwerk (~> 2.6)
|
17
|
+
actionmailbox (7.1.1)
|
18
|
+
actionpack (= 7.1.1)
|
19
|
+
activejob (= 7.1.1)
|
20
|
+
activerecord (= 7.1.1)
|
21
|
+
activestorage (= 7.1.1)
|
22
|
+
activesupport (= 7.1.1)
|
22
23
|
mail (>= 2.7.1)
|
23
24
|
net-imap
|
24
25
|
net-pop
|
25
26
|
net-smtp
|
26
|
-
actionmailer (7.
|
27
|
-
actionpack (= 7.
|
28
|
-
actionview (= 7.
|
29
|
-
activejob (= 7.
|
30
|
-
activesupport (= 7.
|
27
|
+
actionmailer (7.1.1)
|
28
|
+
actionpack (= 7.1.1)
|
29
|
+
actionview (= 7.1.1)
|
30
|
+
activejob (= 7.1.1)
|
31
|
+
activesupport (= 7.1.1)
|
31
32
|
mail (~> 2.5, >= 2.5.4)
|
32
33
|
net-imap
|
33
34
|
net-pop
|
34
35
|
net-smtp
|
35
|
-
rails-dom-testing (~> 2.
|
36
|
-
actionpack (7.
|
37
|
-
actionview (= 7.
|
38
|
-
activesupport (= 7.
|
39
|
-
|
36
|
+
rails-dom-testing (~> 2.2)
|
37
|
+
actionpack (7.1.1)
|
38
|
+
actionview (= 7.1.1)
|
39
|
+
activesupport (= 7.1.1)
|
40
|
+
nokogiri (>= 1.8.5)
|
41
|
+
rack (>= 2.2.4)
|
42
|
+
rack-session (>= 1.0.1)
|
40
43
|
rack-test (>= 0.6.3)
|
41
|
-
rails-dom-testing (~> 2.
|
42
|
-
rails-html-sanitizer (~> 1.
|
43
|
-
actiontext (7.
|
44
|
-
actionpack (= 7.
|
45
|
-
activerecord (= 7.
|
46
|
-
activestorage (= 7.
|
47
|
-
activesupport (= 7.
|
44
|
+
rails-dom-testing (~> 2.2)
|
45
|
+
rails-html-sanitizer (~> 1.6)
|
46
|
+
actiontext (7.1.1)
|
47
|
+
actionpack (= 7.1.1)
|
48
|
+
activerecord (= 7.1.1)
|
49
|
+
activestorage (= 7.1.1)
|
50
|
+
activesupport (= 7.1.1)
|
48
51
|
globalid (>= 0.6.0)
|
49
52
|
nokogiri (>= 1.8.5)
|
50
|
-
actionview (7.
|
51
|
-
activesupport (= 7.
|
53
|
+
actionview (7.1.1)
|
54
|
+
activesupport (= 7.1.1)
|
52
55
|
builder (~> 3.1)
|
53
|
-
erubi (~> 1.
|
54
|
-
rails-dom-testing (~> 2.
|
55
|
-
rails-html-sanitizer (~> 1.
|
56
|
-
activejob (7.
|
57
|
-
activesupport (= 7.
|
56
|
+
erubi (~> 1.11)
|
57
|
+
rails-dom-testing (~> 2.2)
|
58
|
+
rails-html-sanitizer (~> 1.6)
|
59
|
+
activejob (7.1.1)
|
60
|
+
activesupport (= 7.1.1)
|
58
61
|
globalid (>= 0.3.6)
|
59
|
-
activemodel (7.
|
60
|
-
activesupport (= 7.
|
61
|
-
activerecord (7.
|
62
|
-
activemodel (= 7.
|
63
|
-
activesupport (= 7.
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
62
|
+
activemodel (7.1.1)
|
63
|
+
activesupport (= 7.1.1)
|
64
|
+
activerecord (7.1.1)
|
65
|
+
activemodel (= 7.1.1)
|
66
|
+
activesupport (= 7.1.1)
|
67
|
+
timeout (>= 0.4.0)
|
68
|
+
activestorage (7.1.1)
|
69
|
+
actionpack (= 7.1.1)
|
70
|
+
activejob (= 7.1.1)
|
71
|
+
activerecord (= 7.1.1)
|
72
|
+
activesupport (= 7.1.1)
|
69
73
|
marcel (~> 1.0)
|
70
|
-
|
71
|
-
|
74
|
+
activesupport (7.1.1)
|
75
|
+
base64
|
76
|
+
bigdecimal
|
72
77
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
78
|
+
connection_pool (>= 2.2.5)
|
79
|
+
drb
|
73
80
|
i18n (>= 1.6, < 2)
|
74
81
|
minitest (>= 5.1)
|
82
|
+
mutex_m
|
75
83
|
tzinfo (~> 2.0)
|
76
|
-
autoprefixer-rails (10.4.
|
84
|
+
autoprefixer-rails (10.4.15.0)
|
77
85
|
execjs (~> 2)
|
78
|
-
|
79
|
-
|
86
|
+
base64 (0.1.1)
|
87
|
+
bcrypt (3.1.19)
|
88
|
+
bigdecimal (3.1.4)
|
89
|
+
bootsnap (1.16.0)
|
80
90
|
msgpack (~> 1.2)
|
81
|
-
bootstrap (5.1
|
91
|
+
bootstrap (5.3.1)
|
82
92
|
autoprefixer-rails (>= 9.1.0)
|
83
|
-
popper_js (>= 2.
|
93
|
+
popper_js (>= 2.11.8, < 3)
|
84
94
|
sassc-rails (>= 2.0.0)
|
85
95
|
builder (3.2.4)
|
86
|
-
concurrent-ruby (1.
|
96
|
+
concurrent-ruby (1.2.2)
|
97
|
+
connection_pool (2.4.1)
|
87
98
|
crass (1.0.6)
|
88
|
-
|
99
|
+
date (3.3.3)
|
100
|
+
devise (4.9.3)
|
89
101
|
bcrypt (~> 3.0)
|
90
102
|
orm_adapter (~> 0.1)
|
91
103
|
railties (>= 4.1.0)
|
92
104
|
responders
|
93
105
|
warden (~> 1.2.3)
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
106
|
+
drb (2.1.1)
|
107
|
+
ruby2_keywords
|
108
|
+
erubi (1.12.0)
|
109
|
+
execjs (2.9.1)
|
110
|
+
ffi (1.16.3)
|
111
|
+
globalid (1.2.1)
|
112
|
+
activesupport (>= 6.1)
|
113
|
+
i18n (1.14.1)
|
100
114
|
concurrent-ruby (~> 1.0)
|
101
|
-
|
115
|
+
io-console (0.6.0)
|
116
|
+
irb (1.8.1)
|
117
|
+
rdoc
|
118
|
+
reline (>= 0.3.8)
|
119
|
+
jquery-rails (4.6.0)
|
102
120
|
rails-dom-testing (>= 1, < 3)
|
103
121
|
railties (>= 4.2.0)
|
104
122
|
thor (>= 0.14, < 2.0)
|
105
|
-
listen (3.
|
123
|
+
listen (3.8.0)
|
106
124
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
107
125
|
rb-inotify (~> 0.9, >= 0.9.10)
|
108
|
-
loofah (2.
|
126
|
+
loofah (2.21.4)
|
109
127
|
crass (~> 1.0.2)
|
110
|
-
nokogiri (>= 1.
|
111
|
-
mail (2.
|
128
|
+
nokogiri (>= 1.12.0)
|
129
|
+
mail (2.8.1)
|
112
130
|
mini_mime (>= 0.1.1)
|
131
|
+
net-imap
|
132
|
+
net-pop
|
133
|
+
net-smtp
|
113
134
|
marcel (1.0.2)
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
net-imap (0.
|
135
|
+
mini_mime (1.1.5)
|
136
|
+
mini_portile2 (2.8.4)
|
137
|
+
minitest (5.20.0)
|
138
|
+
msgpack (1.7.2)
|
139
|
+
mutex_m (0.1.2)
|
140
|
+
net-imap (0.4.1)
|
141
|
+
date
|
120
142
|
net-protocol
|
121
143
|
net-pop (0.1.2)
|
122
144
|
net-protocol
|
123
|
-
net-protocol (0.1
|
145
|
+
net-protocol (0.2.1)
|
124
146
|
timeout
|
125
|
-
net-smtp (0.
|
147
|
+
net-smtp (0.4.0)
|
126
148
|
net-protocol
|
127
|
-
nio4r (2.5.
|
128
|
-
nokogiri (1.
|
129
|
-
mini_portile2 (~> 2.8.
|
149
|
+
nio4r (2.5.9)
|
150
|
+
nokogiri (1.15.4)
|
151
|
+
mini_portile2 (~> 2.8.2)
|
130
152
|
racc (~> 1.4)
|
131
153
|
orm_adapter (0.5.0)
|
132
|
-
pg (1.
|
133
|
-
popper_js (2.
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
154
|
+
pg (1.5.4)
|
155
|
+
popper_js (2.11.8)
|
156
|
+
psych (5.1.1)
|
157
|
+
stringio
|
158
|
+
racc (1.7.1)
|
159
|
+
rack (3.0.8)
|
160
|
+
rack-session (2.0.0)
|
161
|
+
rack (>= 3.0.0)
|
162
|
+
rack-test (2.1.0)
|
163
|
+
rack (>= 1.3)
|
164
|
+
rackup (2.1.0)
|
165
|
+
rack (>= 3)
|
166
|
+
webrick (~> 1.8)
|
167
|
+
rails (7.1.1)
|
168
|
+
actioncable (= 7.1.1)
|
169
|
+
actionmailbox (= 7.1.1)
|
170
|
+
actionmailer (= 7.1.1)
|
171
|
+
actionpack (= 7.1.1)
|
172
|
+
actiontext (= 7.1.1)
|
173
|
+
actionview (= 7.1.1)
|
174
|
+
activejob (= 7.1.1)
|
175
|
+
activemodel (= 7.1.1)
|
176
|
+
activerecord (= 7.1.1)
|
177
|
+
activestorage (= 7.1.1)
|
178
|
+
activesupport (= 7.1.1)
|
150
179
|
bundler (>= 1.15.0)
|
151
|
-
railties (= 7.
|
152
|
-
rails-dom-testing (2.0
|
153
|
-
activesupport (>=
|
180
|
+
railties (= 7.1.1)
|
181
|
+
rails-dom-testing (2.2.0)
|
182
|
+
activesupport (>= 5.0.0)
|
183
|
+
minitest
|
154
184
|
nokogiri (>= 1.6)
|
155
|
-
rails-html-sanitizer (1.
|
156
|
-
loofah (~> 2.
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
185
|
+
rails-html-sanitizer (1.6.0)
|
186
|
+
loofah (~> 2.21)
|
187
|
+
nokogiri (~> 1.14)
|
188
|
+
railties (7.1.1)
|
189
|
+
actionpack (= 7.1.1)
|
190
|
+
activesupport (= 7.1.1)
|
191
|
+
irb
|
192
|
+
rackup (>= 1.0.0)
|
161
193
|
rake (>= 12.2)
|
162
|
-
thor (~> 1.0)
|
163
|
-
zeitwerk (~> 2.
|
194
|
+
thor (~> 1.0, >= 1.2.2)
|
195
|
+
zeitwerk (~> 2.6)
|
164
196
|
rake (13.0.6)
|
165
|
-
rb-fsevent (0.11.
|
197
|
+
rb-fsevent (0.11.2)
|
166
198
|
rb-inotify (0.10.1)
|
167
199
|
ffi (~> 1.0)
|
168
|
-
|
169
|
-
|
170
|
-
|
200
|
+
rdoc (6.5.0)
|
201
|
+
psych (>= 4.0.0)
|
202
|
+
reline (0.3.9)
|
203
|
+
io-console (~> 0.5)
|
204
|
+
responders (3.1.1)
|
205
|
+
actionpack (>= 5.2)
|
206
|
+
railties (>= 5.2)
|
207
|
+
ruby2_keywords (0.0.5)
|
171
208
|
sassc (2.4.0)
|
172
209
|
ffi (~> 1.9)
|
173
210
|
sassc-rails (2.1.2)
|
@@ -176,28 +213,31 @@ GEM
|
|
176
213
|
sprockets (> 3.0)
|
177
214
|
sprockets-rails
|
178
215
|
tilt
|
179
|
-
simple_form (5.
|
216
|
+
simple_form (5.3.0)
|
180
217
|
actionpack (>= 5.2)
|
181
218
|
activemodel (>= 5.2)
|
182
|
-
sprockets (4.
|
219
|
+
sprockets (4.2.1)
|
183
220
|
concurrent-ruby (~> 1.0)
|
184
|
-
rack (
|
221
|
+
rack (>= 2.2.4, < 4)
|
185
222
|
sprockets-rails (3.4.2)
|
186
223
|
actionpack (>= 5.2)
|
187
224
|
activesupport (>= 5.2)
|
188
225
|
sprockets (>= 3.0.0)
|
189
|
-
sqlite3 (1.
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
226
|
+
sqlite3 (1.6.7)
|
227
|
+
mini_portile2 (~> 2.8.0)
|
228
|
+
stringio (3.0.8)
|
229
|
+
thor (1.2.2)
|
230
|
+
tilt (2.3.0)
|
231
|
+
timeout (0.4.0)
|
232
|
+
tzinfo (2.0.6)
|
194
233
|
concurrent-ruby (~> 1.0)
|
195
234
|
warden (1.2.9)
|
196
235
|
rack (>= 2.0.9)
|
197
|
-
|
236
|
+
webrick (1.8.1)
|
237
|
+
websocket-driver (0.7.6)
|
198
238
|
websocket-extensions (>= 0.1.0)
|
199
239
|
websocket-extensions (0.1.5)
|
200
|
-
zeitwerk (2.
|
240
|
+
zeitwerk (2.6.12)
|
201
241
|
|
202
242
|
PLATFORMS
|
203
243
|
ruby
|
@@ -17,6 +17,8 @@ window.inputSingleDeletableFile = {
|
|
17
17
|
$resizeModal = $('.js-sdfi-deletable-file__resize', $scope),
|
18
18
|
files = this.files,
|
19
19
|
file,
|
20
|
+
isResizable,
|
21
|
+
isPreviewable,
|
20
22
|
hasPreview = $('.js-sdfi-deletable-file__preview', $scope).length > 0,
|
21
23
|
hasResize = $resizeModal.length > 0,
|
22
24
|
modal,
|
@@ -28,19 +30,14 @@ window.inputSingleDeletableFile = {
|
|
28
30
|
}
|
29
31
|
|
30
32
|
file = files[0];
|
33
|
+
isResizable = (/^image\/(png|jpeg)+$/).test(file.type);
|
34
|
+
isPreviewable = (/^image\/[a-z+]+$/).test(file.type);
|
31
35
|
|
32
|
-
if (
|
33
|
-
// name display is delayed if we need to resize
|
34
|
-
$scope.addClass('sdfi-deletable-file--with-file');
|
35
|
-
$('.js-sdfi-deletable-file__label', $scope).html(file.name);
|
36
|
-
$('.js-sdfi-deletable-file__delete-field', $scope).val('');
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
if (/^image\/[a-z+]+$/.test(file.type) && (hasResize || hasPreview)) {
|
36
|
+
if (isResizable && hasResize || isPreviewable && hasPreview) {
|
41
37
|
reader = new FileReader();
|
42
38
|
reader.readAsDataURL(file);
|
43
|
-
if (hasResize) {
|
39
|
+
if (isResizable && hasResize) {
|
40
|
+
// Resizable images
|
44
41
|
reader.onload = function () {
|
45
42
|
modal = new bootstrap.Modal($resizeModal, {
|
46
43
|
backdrop: 'static',
|
@@ -50,13 +47,23 @@ window.inputSingleDeletableFile = {
|
|
50
47
|
$resizeModal.attr('data-filename', file.name);
|
51
48
|
modal.show();
|
52
49
|
};
|
53
|
-
} else
|
50
|
+
} else {
|
51
|
+
// Previewable images
|
52
|
+
$scope.addClass('sdfi-deletable-file--with-file');
|
53
|
+
$('.js-sdfi-deletable-file__label', $scope).html(file.name);
|
54
|
+
$('.js-sdfi-deletable-file__delete-field', $scope).val('');
|
54
55
|
size = $('.js-sdfi-deletable-file__preview', $scope).attr('data-size')
|
55
56
|
.split('x');
|
56
57
|
reader.onload = function (e) {
|
57
58
|
$('.js-sdfi-deletable-file__preview', $scope).html('<img src="' + e.target.result + '" width="' + size[0] + '" height="auto" class="img-fluid img-thumbnail">');
|
58
59
|
};
|
59
60
|
}
|
61
|
+
} else {
|
62
|
+
// Non-resizable and non-previewable files
|
63
|
+
$scope.addClass('sdfi-deletable-file--with-file');
|
64
|
+
$('.js-sdfi-deletable-file__label', $scope).html(file.name);
|
65
|
+
$('.js-sdfi-deletable-file__delete-field', $scope).val('');
|
66
|
+
$('.js-sdfi-deletable-file__preview', $scope).html('');
|
60
67
|
}
|
61
68
|
},
|
62
69
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class ActiveRecord::Base
|
2
|
-
def self.has_one_attached_deletable(name, **options)
|
2
|
+
def self.has_one_attached_deletable(name, **options, &block)
|
3
3
|
class_eval do
|
4
4
|
attr_accessor :"#{name}_delete"
|
5
5
|
attr_accessor :"#{name}_infos"
|
@@ -49,6 +49,6 @@ class ActiveRecord::Base
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
has_one_attached name, **options
|
52
|
+
has_one_attached name, **options, &block
|
53
53
|
end
|
54
54
|
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.
|
4
|
+
version: 0.1.1
|
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: 2023-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -89,9 +89,6 @@ files:
|
|
89
89
|
- lib/simple_form_bs5_file_input.rb
|
90
90
|
- lib/simple_form_bs5_file_input/single_deletable_file_input.rb
|
91
91
|
- lib/simple_form_bs5_file_input/version.rb
|
92
|
-
- pkg/simple_form_bs5_file_input-0.0.1.gem
|
93
|
-
- pkg/simple_form_bs5_file_input-0.0.2.gem
|
94
|
-
- pkg/simple_form_bs5_file_input-0.0.3.gem
|
95
92
|
- simple_form_bs5_file_input.gemspec
|
96
93
|
homepage: https://github.com/noesya/simple_form_bs5_file_input
|
97
94
|
licenses:
|
Binary file
|
Binary file
|
Binary file
|