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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8d494c48e5c5e83b8eb9ceecddff74c2326585a270dad9af472b1a3c3dfcca0
4
- data.tar.gz: 0b4dfe0fc0d349880060d23d98ff402d2cb54b75a293a62264ada3b8f3f48762
3
+ metadata.gz: 2fcf36f702c77c1551143f7db895119ff9e97556f97a931e55900e3432f402d0
4
+ data.tar.gz: d0bf284ad4ff6fddd906bd6818f38a8917d46739a2b097a2479cdaede1f0c719
5
5
  SHA512:
6
- metadata.gz: d7a46f3bf31605f9232fcc9a29081471fdac8a89734212b165afdc965759708dbdcfd3a1f16ac23118e5105c0b7f260617f4d18a52990fdc6d1ce208a813aa26
7
- data.tar.gz: cb14c8ce8f5b21d73a02719ec51e935ae4b2e79e84c7e7eaeb106991623cb19add4237a39f67f1c936f6cddf0148cb135787dc8d6c876dc38ca4431a42f6616f
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.0.7)
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.0.3)
12
- actionpack (= 7.0.3)
13
- activesupport (= 7.0.3)
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
- actionmailbox (7.0.3)
17
- actionpack (= 7.0.3)
18
- activejob (= 7.0.3)
19
- activerecord (= 7.0.3)
20
- activestorage (= 7.0.3)
21
- activesupport (= 7.0.3)
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.0.3)
27
- actionpack (= 7.0.3)
28
- actionview (= 7.0.3)
29
- activejob (= 7.0.3)
30
- activesupport (= 7.0.3)
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.0)
36
- actionpack (7.0.3)
37
- actionview (= 7.0.3)
38
- activesupport (= 7.0.3)
39
- rack (~> 2.0, >= 2.2.0)
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.0)
42
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.3)
44
- actionpack (= 7.0.3)
45
- activerecord (= 7.0.3)
46
- activestorage (= 7.0.3)
47
- activesupport (= 7.0.3)
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.0.3)
51
- activesupport (= 7.0.3)
53
+ actionview (7.1.1)
54
+ activesupport (= 7.1.1)
52
55
  builder (~> 3.1)
53
- erubi (~> 1.4)
54
- rails-dom-testing (~> 2.0)
55
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.3)
57
- activesupport (= 7.0.3)
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.0.3)
60
- activesupport (= 7.0.3)
61
- activerecord (7.0.3)
62
- activemodel (= 7.0.3)
63
- activesupport (= 7.0.3)
64
- activestorage (7.0.3)
65
- actionpack (= 7.0.3)
66
- activejob (= 7.0.3)
67
- activerecord (= 7.0.3)
68
- activesupport (= 7.0.3)
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
- mini_mime (>= 1.1.0)
71
- activesupport (7.0.3)
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.7.0)
84
+ autoprefixer-rails (10.4.15.0)
77
85
  execjs (~> 2)
78
- bcrypt (3.1.18)
79
- bootsnap (1.11.1)
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.3)
91
+ bootstrap (5.3.1)
82
92
  autoprefixer-rails (>= 9.1.0)
83
- popper_js (>= 2.9.3, < 3)
93
+ popper_js (>= 2.11.8, < 3)
84
94
  sassc-rails (>= 2.0.0)
85
95
  builder (3.2.4)
86
- concurrent-ruby (1.1.10)
96
+ concurrent-ruby (1.2.2)
97
+ connection_pool (2.4.1)
87
98
  crass (1.0.6)
88
- devise (4.8.1)
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
- erubi (1.10.0)
95
- execjs (2.8.1)
96
- ffi (1.15.5)
97
- globalid (1.0.0)
98
- activesupport (>= 5.0)
99
- i18n (1.10.0)
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
- jquery-rails (4.5.0)
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.7.1)
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.18.0)
126
+ loofah (2.21.4)
109
127
  crass (~> 1.0.2)
110
- nokogiri (>= 1.5.9)
111
- mail (2.7.1)
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
- method_source (1.0.0)
115
- mini_mime (1.1.2)
116
- mini_portile2 (2.8.0)
117
- minitest (5.15.0)
118
- msgpack (1.5.2)
119
- net-imap (0.3.1)
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.3)
145
+ net-protocol (0.2.1)
124
146
  timeout
125
- net-smtp (0.3.3)
147
+ net-smtp (0.4.0)
126
148
  net-protocol
127
- nio4r (2.5.8)
128
- nokogiri (1.13.6)
129
- mini_portile2 (~> 2.8.0)
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.3.5)
133
- popper_js (2.9.3)
134
- racc (1.6.0)
135
- rack (2.2.3.1)
136
- rack-test (1.1.0)
137
- rack (>= 1.0, < 3)
138
- rails (7.0.3)
139
- actioncable (= 7.0.3)
140
- actionmailbox (= 7.0.3)
141
- actionmailer (= 7.0.3)
142
- actionpack (= 7.0.3)
143
- actiontext (= 7.0.3)
144
- actionview (= 7.0.3)
145
- activejob (= 7.0.3)
146
- activemodel (= 7.0.3)
147
- activerecord (= 7.0.3)
148
- activestorage (= 7.0.3)
149
- activesupport (= 7.0.3)
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.0.3)
152
- rails-dom-testing (2.0.3)
153
- activesupport (>= 4.2.0)
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.4.2)
156
- loofah (~> 2.3)
157
- railties (7.0.3)
158
- actionpack (= 7.0.3)
159
- activesupport (= 7.0.3)
160
- method_source
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.5)
194
+ thor (~> 1.0, >= 1.2.2)
195
+ zeitwerk (~> 2.6)
164
196
  rake (13.0.6)
165
- rb-fsevent (0.11.1)
197
+ rb-fsevent (0.11.2)
166
198
  rb-inotify (0.10.1)
167
199
  ffi (~> 1.0)
168
- responders (3.0.1)
169
- actionpack (>= 5.0)
170
- railties (>= 5.0)
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.1.0)
216
+ simple_form (5.3.0)
180
217
  actionpack (>= 5.2)
181
218
  activemodel (>= 5.2)
182
- sprockets (4.0.3)
219
+ sprockets (4.2.1)
183
220
  concurrent-ruby (~> 1.0)
184
- rack (> 1, < 3)
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.4.2)
190
- thor (1.2.1)
191
- tilt (2.0.10)
192
- timeout (0.3.0)
193
- tzinfo (2.0.4)
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
- websocket-driver (0.7.5)
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.5.4)
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 (!hasResize) {
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 if (hasPreview) {
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
@@ -1,3 +1,3 @@
1
1
  module SimpleFormBs5FileInput
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  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.0.7
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: 2022-11-28 00:00:00.000000000 Z
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: