avo 1.18.0.pre.1 → 1.18.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of avo might be problematic. Click here for more details.

Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +4 -2
  4. data/app/components/avo/fields/files_field/edit_component.html.erb +3 -1
  5. data/app/controllers/avo/attachments_controller.rb +1 -2
  6. data/app/packs/entrypoints/application.css +1 -0
  7. data/app/packs/entrypoints/application.js +1 -0
  8. data/app/packs/js/active-storage.js +45 -0
  9. data/app/packs/stylesheets/active-storage.css +37 -0
  10. data/lib/avo/fields/files_field.rb +2 -2
  11. data/lib/avo/version.rb +1 -1
  12. data/public/avo-packs/css/{application-2b4685ca.css → application-f9191617.css} +39 -1
  13. data/public/avo-packs/css/application-f9191617.css.br +0 -0
  14. data/public/avo-packs/css/application-f9191617.css.gz +0 -0
  15. data/public/avo-packs/css/application-f9191617.css.map +1 -0
  16. data/public/avo-packs/css/application-f9191617.css.map.br +0 -0
  17. data/public/avo-packs/css/application-f9191617.css.map.gz +0 -0
  18. data/public/avo-packs/js/application-cc89f096028eb1d4d971.js +26 -0
  19. data/public/avo-packs/js/{application-6842378de4da9b615e18.js.LICENSE.txt → application-cc89f096028eb1d4d971.js.LICENSE.txt} +0 -0
  20. data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.br +0 -0
  21. data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.gz +0 -0
  22. data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.map +1 -0
  23. data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.map.br +0 -0
  24. data/public/avo-packs/js/application-cc89f096028eb1d4d971.js.map.gz +0 -0
  25. data/public/avo-packs/manifest.json +15 -15
  26. metadata +17 -15
  27. data/public/avo-packs/css/application-2b4685ca.css.br +0 -0
  28. data/public/avo-packs/css/application-2b4685ca.css.gz +0 -0
  29. data/public/avo-packs/css/application-2b4685ca.css.map +0 -1
  30. data/public/avo-packs/css/application-2b4685ca.css.map.br +0 -0
  31. data/public/avo-packs/css/application-2b4685ca.css.map.gz +0 -0
  32. data/public/avo-packs/js/application-6842378de4da9b615e18.js +0 -26
  33. data/public/avo-packs/js/application-6842378de4da9b615e18.js.br +0 -0
  34. data/public/avo-packs/js/application-6842378de4da9b615e18.js.gz +0 -0
  35. data/public/avo-packs/js/application-6842378de4da9b615e18.js.map +0 -1
  36. data/public/avo-packs/js/application-6842378de4da9b615e18.js.map.br +0 -0
  37. data/public/avo-packs/js/application-6842378de4da9b615e18.js.map.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccd552281f8ac8b77ea15f6d9000271a447a01190cb3c46905898f94df366009
4
- data.tar.gz: c97173ac80821f5ef2de0f3d1060be50fe1c3b2c19d1b2f8eb177c9fc750f2d2
3
+ metadata.gz: ca20ddd1db1b6f1d54f2aed3133447353a1bbba60ea7eda4b55487bbcc8f1239
4
+ data.tar.gz: 9631043fb317c49d93c76080172ebefeb278ca7749b8860eafe64f8fffe2c26f
5
5
  SHA512:
6
- metadata.gz: 84703917f0960fb186bd79b5b7463298afd544e625f0b9ef83af6373c56d673e22479c2e88528cd2df1add04bd2ced0c31d50ea4bc6d856cfb26dd00a07cac42
7
- data.tar.gz: f0e6a6d3b59bf79dac877bb012da1f56c979bf72897241e0f9d1633c7745e7fc1ce769d72610105d42b1e37d4a86f19e8a1e39370e709a2be24869a4b7a20981
6
+ metadata.gz: 3998c7fb60112685ab0d92754604f29b6a57bee36b235d2a9674a870ab83013f5e411419b8a14c4325b1b96386b807a7474561344cb0877c4045825af929d86a
7
+ data.tar.gz: 29e905bc525f5593910920eb574dc79e16d68fca01ff88ebe315fb6fe17b532e6c4cbafa7cd2ca20305e0db5e8d33b9349cd176f3d687bf828bc3285822ad0aa
data/Gemfile CHANGED
@@ -115,7 +115,7 @@ gem "hotwire-rails"
115
115
 
116
116
  gem "active_link_to"
117
117
 
118
- gem "view_component"
118
+ gem "view_component", require: "view_component/engine"
119
119
 
120
120
  gem "addressable"
121
121
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (1.18.0.pre.1)
4
+ avo (1.18.0.pre.2)
5
5
  active_link_to
6
6
  addressable
7
7
  breadcrumbs_on_rails
@@ -209,8 +209,10 @@ GEM
209
209
  nokogiri (1.12.5)
210
210
  mini_portile2 (~> 2.6.1)
211
211
  racc (~> 1.4)
212
+ nokogiri (1.12.5-x86_64-linux)
213
+ racc (~> 1.4)
212
214
  orm_adapter (0.5.0)
213
- pagy (5.6.6)
215
+ pagy (5.6.10)
214
216
  parallel (1.20.1)
215
217
  parser (3.0.0.0)
216
218
  ast (~> 2.4.1)
@@ -2,6 +2,8 @@
2
2
  <%= render Avo::Fields::Common::FilesListViewerComponent.new(field: @field, resource: @resource) if @field.value.present? %>
3
3
 
4
4
  <% if @resource.authorization.authorize_action(:upload_attachments?, raise_exception: false) %>
5
- <%= @form.file_field @field.id, disabled: @field.readonly, multiple: true, direct_upload: @field.direct_upload %>
5
+ <div class="mt-2">
6
+ <%= @form.file_field @field.id, disabled: @field.readonly, multiple: true, direct_upload: @field.direct_upload %>
7
+ </div>
6
8
  <% end %>
7
9
  <% end %>
@@ -21,8 +21,7 @@ module Avo
21
21
  end
22
22
 
23
23
  def destroy
24
- blob = ActiveStorage::Blob.find(params[:signed_attachment_id])
25
- attachment = blob.attachments.find_by record_id: params[:id], record_type: @model.class.to_s
24
+ attachment = ActiveStorage::Attachment.find(params[:signed_attachment_id])
26
25
 
27
26
  if attachment.present?
28
27
  attachment.destroy
@@ -16,6 +16,7 @@
16
16
  @import './../stylesheets/pagination.css';
17
17
  @import './../stylesheets/breadcrumbs.css';
18
18
  @import './../stylesheets/search.css';
19
+ @import './../stylesheets/active-storage.css';
19
20
 
20
21
  @import './../stylesheets/components/status.css';
21
22
  @import './../stylesheets/components/code.css';
@@ -11,6 +11,7 @@ import Rails from '@rails/ujs'
11
11
  import tippy from 'tippy.js'
12
12
 
13
13
  // Toastr alerts
14
+ import '../js/active-storage'
14
15
  import '../js/toastr'
15
16
 
16
17
  Rails.start()
@@ -0,0 +1,45 @@
1
+ document.addEventListener('direct-upload:initialize', (event) => {
2
+ const { target, detail } = event
3
+ const { id, file } = detail
4
+
5
+ target.insertAdjacentHTML(
6
+ 'beforebegin',
7
+ `
8
+ <div id="direct-upload-${id}" class="direct-upload direct-upload--pending">
9
+ <div id="direct-upload-progress-${id}" class="direct-upload__progress" style="width: 0%"></div>
10
+ <span class="direct-upload__filename"></span>
11
+ </div>
12
+ `,
13
+ )
14
+ target.previousElementSibling.querySelector(
15
+ '.direct-upload__filename',
16
+ ).textContent = file.name
17
+ })
18
+
19
+ document.addEventListener('direct-upload:start', (event) => {
20
+ const { id } = event.detail
21
+ const element = document.getElementById(`direct-upload-${id}`)
22
+ element.classList.remove('direct-upload--pending')
23
+ })
24
+
25
+ document.addEventListener('direct-upload:progress', (event) => {
26
+ const { id, progress } = event.detail
27
+ const progressElement = document.getElementById(
28
+ `direct-upload-progress-${id}`,
29
+ )
30
+ progressElement.style.width = `${progress}%`
31
+ })
32
+
33
+ document.addEventListener('direct-upload:error', (event) => {
34
+ event.preventDefault()
35
+ const { id, error } = event.detail
36
+ const element = document.getElementById(`direct-upload-${id}`)
37
+ element.classList.add('direct-upload--error')
38
+ element.setAttribute('title', error)
39
+ })
40
+
41
+ document.addEventListener('direct-upload:end', (event) => {
42
+ const { id } = event.detail
43
+ const element = document.getElementById(`direct-upload-${id}`)
44
+ element.classList.add('direct-upload--complete')
45
+ })
@@ -0,0 +1,37 @@
1
+ .direct-upload {
2
+ display: inline-block;
3
+ position: relative;
4
+ padding: 2px 4px;
5
+ margin: 0 3px 3px 0;
6
+ border: 1px solid rgba(0, 0, 0, 0.3);
7
+ border-radius: 3px;
8
+ font-size: 11px;
9
+ line-height: 13px;
10
+ }
11
+
12
+ .direct-upload--pending {
13
+ opacity: 0.6;
14
+ }
15
+
16
+ .direct-upload__progress {
17
+ position: absolute;
18
+ top: 0;
19
+ left: 0;
20
+ bottom: 0;
21
+ opacity: 0.2;
22
+ background: #0076ff;
23
+ transition: width 120ms ease-out, opacity 60ms 60ms ease-in;
24
+ transform: translate3d(0, 0, 0);
25
+ }
26
+
27
+ .direct-upload--complete .direct-upload__progress {
28
+ opacity: 0.4;
29
+ }
30
+
31
+ .direct-upload--error {
32
+ border-color: red;
33
+ }
34
+
35
+ input[type=file][data-direct-upload-url][disabled] {
36
+ display: none;
37
+ }
@@ -25,8 +25,8 @@ module Avo
25
25
  value.each do |file|
26
26
  # Skip empty values
27
27
  next unless file.present?
28
- # Skip Capybara Nil files in tests
29
- next unless file.class === Capybara::RackTest::Form::NilUploadedFile
28
+ # Keep only String values
29
+ next unless file.class === String
30
30
 
31
31
  model.send(key).attach file
32
32
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "1.18.0.pre.1"
2
+ VERSION = "1.18.0.pre.2"
3
3
  end
@@ -3220,6 +3220,44 @@ svg.tea #steamR {
3220
3220
  color: rgba(255, 255, 255, var(--tw-text-opacity));
3221
3221
  }
3222
3222
 
3223
+ .direct-upload {
3224
+ display: inline-block;
3225
+ position: relative;
3226
+ padding: 2px 4px;
3227
+ margin: 0 3px 3px 0;
3228
+ border: 1px solid rgba(0, 0, 0, 0.3);
3229
+ border-radius: 3px;
3230
+ font-size: 11px;
3231
+ line-height: 13px;
3232
+ }
3233
+
3234
+ .direct-upload--pending {
3235
+ opacity: 0.6;
3236
+ }
3237
+
3238
+ .direct-upload__progress {
3239
+ position: absolute;
3240
+ top: 0;
3241
+ left: 0;
3242
+ bottom: 0;
3243
+ opacity: 0.2;
3244
+ background: #0076ff;
3245
+ transition: width 120ms ease-out, opacity 60ms 60ms ease-in;
3246
+ transform: translate3d(0, 0, 0);
3247
+ }
3248
+
3249
+ .direct-upload--complete .direct-upload__progress {
3250
+ opacity: 0.4;
3251
+ }
3252
+
3253
+ .direct-upload--error {
3254
+ border-color: red;
3255
+ }
3256
+
3257
+ input[type=file][data-direct-upload-url][disabled] {
3258
+ display: none;
3259
+ }
3260
+
3223
3261
  .spinner {
3224
3262
  width: 16px;
3225
3263
  height: 16px;
@@ -6246,4 +6284,4 @@ html, body{
6246
6284
  }
6247
6285
 
6248
6286
 
6249
- /*# sourceMappingURL=application-2b4685ca.css.map*/
6287
+ /*# sourceMappingURL=application-f9191617.css.map*/