administrate-field-active_storage 0.3.7 → 0.3.8

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: 400847147cef13ebaf2becff0f8d6f60ab159e42373aab67e39d7823900b7061
4
- data.tar.gz: 28dcb24685789156e988f3aa1a2065a50c6d147e1863b277cc93c6ce73d91f56
3
+ metadata.gz: 7d685dc2a380f464f63d5b78dfd5a3c967e4a22ec7b28218f8e8bd8f22d5039e
4
+ data.tar.gz: ae36c6c3b520706249cf3bb917f1441cd22506f9ea0761fb14f51834406e2c7d
5
5
  SHA512:
6
- metadata.gz: a4395b379fb47e7efc923ef5c69cdc7d85f26f0cb1aa0efde7b31cd8f7dd4916f6ca650d94a8772d1a522510669fc0f125a02e69399e6d7ee0c68972c232934f
7
- data.tar.gz: c9966fd2cc8194963455def07ea138d28a19394d680c14edad1ec7d05740eedd7856dd1484ad4f16dd8db76eefaf0dab0993dde43e907d92a7a330798f53531f
6
+ metadata.gz: 91b86562577256f867aa848391004229f58200757c8ddddc9895d22d6907c15472d5e0308e292323979787687f9362a7aba9b2d7f2ec63cad8ac4151d6559069
7
+ data.tar.gz: 842ece6e36fb7592cbea4a99a362af6862824cb74f60dfe4f7d28a07a0a95d7174669e7a3e68dce5152efa9a4ce35309ac6271c685e335b1990e24ebdf352ad9
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "administrate-field-active_storage"
5
- gem.version = "0.3.7"
5
+ gem.version = "0.3.8"
6
6
  gem.authors = ["Hamad AlGhanim"]
7
7
  gem.email = ["hamadyalghanim@gmail.com"]
8
8
  gem.homepage = "https://github.com/Dreamersoul/administrate-field-active_storage"
@@ -16,18 +16,26 @@ By default, the attribute is rendered as an image tag.
16
16
  %>
17
17
 
18
18
  <% if field.attached? %>
19
- <style> <%# figure out a way to remove this %>
19
+ <style type="text/css" nonce="<%= content_security_policy_nonce %>"> <%# figure out a way to remove this %>
20
20
  td img {
21
21
  max-height: unset !important;
22
22
  }
23
23
  </style>
24
24
  <% if field.index_display_preview? %>
25
- <%= render partial: 'fields/active_storage/preview',
26
- locals: {
27
- field: field,
28
- attachment: field.data,
29
- size: field.index_preview_size
30
- } %>
25
+ <% if field.many? %>
26
+ <%= render partial: 'fields/active_storage/items',
27
+ locals: {
28
+ field: field,
29
+ size: field.index_preview_size
30
+ } %>
31
+ <% else %>
32
+ <%= render partial: 'fields/active_storage/item',
33
+ locals: {
34
+ field: field,
35
+ attachment: field.data,
36
+ size: field.index_preview_size
37
+ } %>
38
+ <% end %>
31
39
  <% end %>
32
40
 
33
41
  <% if field.index_display_count? %>
@@ -11,10 +11,15 @@ This partial renders one or more attachments
11
11
  - `removable`:
12
12
  A boolean used to control the display of a `Remove` link which
13
13
  is used to destroy a single attachment. Defaults to `false`
14
+ - `size`:
15
+ [x, y]
16
+ Maximum size of the ActiveStorage preview.
17
+ Defaults to `field.show_preview_size`.
14
18
  %>
15
19
 
16
20
  <%
17
21
  removable = local_assigns.fetch(:removable, false)
22
+ size = local_assigns.fetch(:size, field.show_preview_size)
18
23
  %>
19
24
 
20
25
  <% field.attachments.each do |attachment| %>
@@ -24,7 +29,7 @@ This partial renders one or more attachments
24
29
  field: field,
25
30
  attachment: attachment,
26
31
  removable: removable,
27
- size: field.show_preview_size
32
+ size: size
28
33
  } %>
29
34
  </div>
30
35
  <% end %>
@@ -1,4 +1,11 @@
1
- <div style="width: <%=size[0]%>px; height: auto; overflow: hidden;">
1
+ <style type="text/css" nonce="<%= content_security_policy_nonce %>">
2
+ #as-field-<%= attachment.id %> {
3
+ width: <%=size[0]/2%>px;
4
+ height: auto;
5
+ overflow: hidden;
6
+ }
7
+ </style>
8
+ <div id="as-field-<%= attachment.id %>">
2
9
  <% if attachment.image? %>
3
10
  <% if attachment.variable? %>
4
11
  <%= image_tag(field.variant(attachment, resize_to_limit: size)) %>
@@ -6,14 +13,21 @@
6
13
  <%= image_tag(field.url(attachment)) %>
7
14
  <% end %>
8
15
  <% elsif attachment.video? %>
16
+ <style type="text/css" nonce="<%= content_security_policy_nonce %>">
17
+ #as-field-video-<%= attachment.id %> {
18
+ object-fit: contain;
19
+ width: 100%;
20
+ height: 100%;
21
+ }
22
+ </style>
9
23
  <% if attachment.previewable? %>
10
24
  <%= video_tag(field.url(attachment),
11
25
  poster: field.preview(attachment, resize_to_limit: size),
12
26
  controls: true,
13
27
  autobuffer: true,
14
- style: "object-fit: contain; width: 100%; height: 100%;") %>
28
+ id: "as-field-video-#{attachment.id}") %>
15
29
  <% else %>
16
- <%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "object-fit: contain; width: 100%; height: 100%;") %>
30
+ <%= video_tag(field.url(attachment), controls: true, autobuffer: true, id: "as-field-video-#{attachment.id}") %>
17
31
  <% end %>
18
32
  <% elsif attachment.audio? %>
19
33
  <%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: administrate-field-active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamad AlGhanim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-30 00:00:00.000000000 Z
11
+ date: 2021-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate