viniBaxter-field-active_storage 14.0.0 → 300.0.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.
Files changed (23) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/app/views/fields/active_storage/_form.html.erb +7 -21
  4. data/app/views/fields/active_storage/_index.html.erb +27 -35
  5. data/app/views/fields/active_storage/_show.html.erb +6 -20
  6. data/app/views/fields/active_storage/drop_js/_drop_js_items_if_sweety.html.erb +57 -0
  7. data/app/views/fields/active_storage/drop_js/_drop_js_items_on_edit.html.erb +37 -0
  8. data/app/views/fields/active_storage/drop_js/_drop_js_items_on_show.html.erb +33 -0
  9. data/app/views/fields/active_storage/{_dropjs_items.html.erb → drop_js/_dropjs_items.html.erb} +1 -1
  10. data/app/views/fields/active_storage/drop_js/_dropjs_list_edit.html.erb +49 -0
  11. data/app/views/fields/active_storage/{_dropjs_list_edit.html.erb → drop_js/_dropjs_list_show.html.erb} +0 -0
  12. data/app/views/fields/active_storage/drop_js/_dropjs_template.html.erb +33 -0
  13. data/app/views/fields/active_storage/normal/_item.html.erb +33 -0
  14. data/app/views/fields/active_storage/normal/_items.html.erb +35 -0
  15. data/app/views/fields/active_storage/{_items_on_show.html.erb → normal/_items_on_show.html.erb} +6 -1
  16. data/app/views/fields/active_storage/normal/_preview.html.erb +42 -0
  17. data/lib/viniBaxter/field/active_storage.rb +18 -2
  18. data/lib/viniBaxter/version.rb +13 -0
  19. data/viniBaxter-field-active_storage.gemspec +2 -1
  20. metadata +18 -12
  21. data/app/views/fields/active_storage/_dropjs_template.html.erb +0 -54
  22. data/app/views/fields/active_storage/_item.html.erb +0 -35
  23. data/app/views/fields/active_storage/_items.html.erb +0 -63
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3d30540212b411b917f5d8323a78d6f4b0b883b7832c9d0ad0ba3fbc529a9cd
4
- data.tar.gz: 62b661ca2860aff1cc65f39d7d553ada80095d64c37ec4d19a3948f9aa0545e5
3
+ metadata.gz: 87b79589f648d29cae389c4f4e05ba2f5eda5a204a05d3a868f2a5d4bb001587
4
+ data.tar.gz: 500b6345e53af356d9bb4062462185d1c700edd5a2b7736fd6d68a63e7c8eba6
5
5
  SHA512:
6
- metadata.gz: 393b4b2c4585b0930786cb0c1f3eb0f33fd6665f208d41b65de9dd282b056625fa8cfbcfa1f0a83e5948a22a94c4801859ca3c7db26c2379a729df4fa39731f1
7
- data.tar.gz: 774c280755a06dc643059a5b91fbb6addf63dcbb7fba04a470980145cad68d5ce0b763bd8e9caab606913ea6785c2cdc72fc421d14f93ab392dffbfd84eab66e
6
+ metadata.gz: 105b6b52b9bc8d9cce99b1e73718cd37c38832f1cf23e4773eafb20c6a5672e4e77dd030f000d62f4c4b41d00db831c43878db931d881691a2163e736c296ab9
7
+ data.tar.gz: 4d8d9ddc967eb6f9659fa7e2e69e8bd7a7b5a56fbb99bcdef90410c331151bb6e1ebb850f7daf2471cc068143d27cafb52b82be7971f3a26f88eab6eb854cbf5
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.3
1
+ 3.0.3
@@ -1,37 +1,23 @@
1
- <%#
2
- # Image Form Partial
3
-
4
- This partial renders an input element for image attributes.
5
- By default, the input is a text field for the image's URL.
6
-
7
- ## Local variables:
8
-
9
- - `f`:
10
- A Rails form generator, used to help create the appropriate input fields.
11
- - `field`:
12
- An instance of [Administrate::Field::Image][1].
13
- A wrapper around the image url pulled from the database.
14
-
15
- [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
16
- %>
17
1
  <div class="field-unit__label">
18
2
  <%= f.label field.attribute %>
19
3
  </div>
20
4
  <div class="field-unit__field">
21
5
  <% if field.drop_js? %>
22
- <!-- Form dropJS -->
23
- <%= render partial: 'fields/active_storage/dropjs_items', locals: { f: f, field: field, removable: field.destroyable? } %>
6
+ <%= render partial: 'fields/active_storage/drop_js/dropjs_items', locals: { f: f, field: field, removable: field.destroyable? } %>
24
7
  <%else %>
25
- <!-- Form if no dropJS -->
26
8
  <%= f.file_field field.attribute, multiple: field.many?, direct_upload: field.direct? %>
27
9
  <%end %>
28
10
  <!-- show previous images recorded -->
29
11
  <% if field.attached? %>
30
12
  <% if !field.drop_js? %>
31
- <%= render partial: 'fields/active_storage/items', locals: { field: field, removable: field.destroyable? } %>
13
+ <%= render partial: 'fields/active_storage/normal/items_on_show', locals: { field: field, removable: field.destroyable? } %>
32
14
  <%= field.can_add_attachment? ? "Add:" : "Replace:" %>
33
15
  <%else %>
34
- <%= render partial: 'fields/active_storage/items', locals: { field: field, removable: field.destroyable? } %>
16
+ <% if request.env["PATH_INFO"].include?('edit')%>
17
+ <%= render partial: 'fields/active_storage/drop_js/drop_js_items_on_edit', locals: { field: field, removable: field.destroyable? } %>
18
+ <% else %>
19
+ <%= render partial: 'fields/active_storage/drop_js/drop_js_items_on_show', locals: { field: field, removable: field.destroyable? } %>
20
+ <% end %>
35
21
  <%end %>
36
22
  <% end %>
37
23
  </div>
@@ -1,42 +1,34 @@
1
- <%#
2
- # Image Index Partial
3
-
4
- This partial renders an image attribute
5
- to be displayed on a resource's index page.
6
-
7
- By default, the attribute is rendered as an image tag.
8
-
9
- ## Local variables:
10
-
11
- - `field`:
12
- An instance of [Administrate::Field::Image][1].
13
- A wrapper around the image url pulled from the database.
14
-
15
- [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
16
- %>
17
- <style>
18
- <%# figure out a way to remove this %>
19
- td img {
20
- max-height: unset !important;
21
- }
22
- </style>
23
- <%
24
- attachments = Array(field.many? ? field.attachments : field.data)
25
- %>
26
1
  <% if field.attached? %>
27
- <% if field.show_in_index? %>
28
- <%= render partial: 'fields/active_storage/item',
29
- locals: {
30
- field: field,
31
- attachment: field.data,
32
- image_size: [200, 200]
33
- } %>
2
+ <style type="text/css" nonce="<%= content_security_policy_nonce %>">
3
+ <%# figure out a way to remove this %>
4
+ td img {
5
+ max-height: unset !important;
6
+ }
7
+ </style>
8
+ <% if field.index_display_preview? %>
9
+ <% if field.many? %>
10
+ <%= render partial: 'fields/active_storage/normal/items',
11
+ locals: {
12
+ many: true,
13
+ field: field,
14
+ size: field.index_preview_size
15
+ } %>
16
+ <% else %>
17
+ <%= render partial: 'fields/active_storage/normal/item',
18
+ locals: {
19
+ many: false,
20
+ field: field,
21
+ attachment: field.data,
22
+ size: field.index_preview_size
23
+ } %>
24
+ <% end %>
34
25
  <% end %>
35
26
  <% if field.index_display_count? %>
36
27
  <div class="attachments-count">
37
- <%= pluralize(field.attachments.count, 'Attachment') %>
28
+ <%= pluralize(field.attachments.count,
29
+ I18n.t("administrate.fields.active_storage.attachment", default: 'Attachment')
30
+ )
31
+ %>
38
32
  </div>
39
33
  <% end %>
40
- <% else %>
41
- 0 Attached files
42
34
  <% end %>
@@ -1,23 +1,9 @@
1
- <%#
2
- # Image Show Partial
3
-
4
- This partial renders an image attribute,
5
- to be displayed on a resource's show page.
6
-
7
- By default, the attribute is rendered as an image tag.
8
-
9
- ## Local variables:
10
-
11
- - `field`:
12
- An instance of [Administrate::Field::Image][1].
13
- A wrapper around the image url pulled from the database.
14
-
15
- [1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
16
- %>
17
1
  <% if field.attached? %>
18
- <% if field.show_drop_js_on_show? %>
19
- <%= render partial: 'fields/active_storage/items', locals: { field: field } %>
20
- <%else %>
21
- <%= render partial: 'fields/active_storage/items_on_show', locals: { field: field } %>
2
+ <% if field.show_drop_js_on_show? && field.sweety_show_drop_js_on_show? %>
3
+ <%= render partial: 'fields/active_storage/drop_js/drop_js_items_if_sweety', locals: { field: field, removable: field.destroyable? } %>
4
+ <% elsif field.show_drop_js_on_show?%>
5
+ <%= render partial: 'fields/active_storage/drop_js/drop_js_items_on_show', locals: { field: field } %>
6
+ <% else %>
7
+ <%= render partial: 'fields/active_storage/normal/items_on_show', locals: { field: field } %>
22
8
  <% end %>
23
9
  <% end %>
@@ -0,0 +1,57 @@
1
+ <%
2
+ attachments = Array(field.many? ? field.attachments : field.data)
3
+ removable = local_assigns.fetch(:removable, false)
4
+ %>
5
+ <div class="mt-5 col-12 ">
6
+ <div class="row">
7
+ <div class="col-12">
8
+ <div class="">
9
+ <div class="card-body">
10
+ <div class="already-downloaded dropzone">
11
+ <div class="list-group list-group-flush">
12
+ <div class="list-group-item">
13
+ <div class="row align-items-center">
14
+ <% attachments.each do |attachment| %>
15
+ <div>
16
+ <div class="" id="<%= @page.class %>_picture_<%= attachment.id %>">
17
+ <%= render partial: 'fields/active_storage/drop_js/dropjs_list_edit', locals: {
18
+ field: field,
19
+ attachment: attachment,
20
+ removable: removable,
21
+ image_size: field.show_preview_size
22
+ }%>
23
+ </div>
24
+ <div class="col ml-n2">
25
+ <small class="text-muted">
26
+ <div class="mb-1 dz-size" data-dz-size="">
27
+ <strong>
28
+ SEO: <%= alt_method(attachment) %>
29
+ </strong>
30
+ </div>
31
+ </small>
32
+ <div class="dz-error-message"><span data-dz-errormessage=""></span></div>
33
+ <!-- Text -->
34
+ <small class="text-muted">
35
+ <div class="mb-1 dz-size" data-dz-size="">
36
+ <strong>
37
+ full name : <%= attachment.filename %> |
38
+ </strong></div>
39
+ </small>
40
+ <small class="text-muted">
41
+ <div class="mb-1 dz-size" data-dz-size="">
42
+ <strong>
43
+ <%= attachment.byte_size.fdiv(1000).round(1) %>
44
+ </strong> KB</div>
45
+ </small>
46
+ </div>
47
+ </div>
48
+ <% end %>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </div>
@@ -0,0 +1,37 @@
1
+ <%
2
+ attachments = Array(field.many? ? field.attachments : field.data)
3
+ removable = local_assigns.fetch(:removable, false)
4
+ %>
5
+ <div class="mt-5 col-12 ">
6
+ <div class="row">
7
+ <div class="col-12">
8
+ <div class="card card light-shadow card-fill">
9
+ <div class="card-header">
10
+ <h4 class="card-header-title">
11
+ Latest Uploads
12
+ </h4>
13
+ </div>
14
+ <div class="card-body">
15
+ <div class="already-downloaded dropzone">
16
+ <div class="list-group list-group-flush">
17
+ <div class="list-group-item">
18
+ <div class="row align-items-center">
19
+ <% attachments.each do |attachment| %>
20
+ <div class="" id="<%= @page.class %>_picture_<%= attachment.id %>">
21
+ <%= render partial: 'fields/active_storage/drop_js/dropjs_list_edit', locals: {
22
+ field: field,
23
+ attachment: attachment,
24
+ removable: removable,
25
+ image_size: field.show_preview_size
26
+ }%>
27
+ </div>
28
+ <% end %>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </div>
@@ -0,0 +1,33 @@
1
+ <%
2
+ attachments = Array(field.many? ? field.attachments : field.data)
3
+ removable = local_assigns.fetch(:removable, false)
4
+ %>
5
+ <div class="mt-5 col-12 ">
6
+ <div class="row">
7
+ <div class="col-12">
8
+ <div class="card card light-shadow card-fill">
9
+ <div class="card-header">
10
+ <h4 class="card-header-title">
11
+ Latest Uploads
12
+ </h4>
13
+ </div>
14
+ <div class="card-body">
15
+ <div class="already-downloaded dropzone">
16
+ <div class="row">
17
+ <% attachments.each do |attachment| %>
18
+ <div class="col-4" id="<%= @page.class %>_picture_<%= attachment.id %>">
19
+ <%= render partial: 'fields/active_storage/drop_js/dropjs_list_show', locals: {
20
+ field: field,
21
+ attachment: attachment,
22
+ removable: removable,
23
+ image_size: field.show_preview_size
24
+ }%>
25
+ </div>
26
+ <% end %>
27
+ </div>
28
+ </div>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </div>
@@ -18,7 +18,7 @@
18
18
  </span>
19
19
  </div>
20
20
  <div id="tpl" style='display:none'>
21
- <%= render partial: 'fields/active_storage/dropjs_template'%>
21
+ <%= render partial: 'fields/active_storage/drop_js/dropjs_template'%>
22
22
  </div>
23
23
  <%#= render 'ulFordropjs' %>
24
24
  </div>
@@ -0,0 +1,49 @@
1
+ <div class='mt-4 list-group list-group-flush'>
2
+ <div class="dz-preview dz-file-preview bibi">
3
+ <div class="row align-items-center">
4
+ <div class="col-auto">
5
+ <div class="mx-1 my-1 avatar avatar-xl">
6
+ <%
7
+ # By default we don't allow attachment removal
8
+ removable = local_assigns.fetch(:removable, false)
9
+ image_size = local_assigns.fetch(:image_size, [200, 200])
10
+ %>
11
+ <% if attachment.image? and attachment.variable? and !field.url_only? %>
12
+ <%= link_to(field.blob_url(attachment), title: attachment.filename, class:'rounded avatar-img') do %>
13
+ <%#= image_tag(field.variant(attachment, resize_to_limit: image_size),class:'avatar-img rounded delete_on_click') %>
14
+ <%= image_tag attachment.variant(resize_to_limit: image_size), class:"rounded avatar-img delete_on_click" %>
15
+ <% end %>
16
+ <% elsif attachment.image? and !field.url_only? %>
17
+ <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
18
+ <%= image_tag(field.url(attachment)) %>
19
+ <% end %>
20
+ <% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
21
+ <%= video_tag(field.url(attachment), poster: field.preview(attachment, resize_to_limit: image_size), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
22
+ <% elsif attachment.video? and !field.url_only? %>
23
+ <%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
24
+ <% elsif attachment.audio? and !field.url_only? %>
25
+ <%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
26
+ <% else %>
27
+ <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
28
+ <% if attachment.previewable? and !field.url_only? %>
29
+ <%= image_tag(field.preview(attachment, resize_to_limit: [595, 842])) %>
30
+ <% else %>
31
+ <%= attachment.filename %>
32
+ <% end %>
33
+ <% end %>
34
+ <% end %>
35
+ <% if field.destroy_url.present? %>
36
+ <% destroy_url = field.destroy_url.call(namespace, field.data.record, attachment) %>
37
+ <div class="position-absolute delete-link d-flex align-items-center justify-content-center">
38
+ <%= link_to destroy_url,
39
+ method: :delete,
40
+ remote: true do %>
41
+ <i class="tim-icons icon-simple-remove text-light"></i>
42
+ <% end %>
43
+ </div>
44
+ <% end %>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </div>
@@ -0,0 +1,33 @@
1
+
2
+ <div class='mt-4 list-group list-group-flush'>
3
+ <div class="dz-preview dz-file-preview bibi">
4
+ <div class="row align-items-center">
5
+ <div class="col-auto">
6
+ <div class="mx-1 my-1 avatar avatar-xl">
7
+ <img class="rounded avatar-img" data-dz-thumbnail>
8
+ <div class="position-absolute delete-link d-flex align-items-center justify-content-center">
9
+ <a rel="nofollow" data-dz-remove>
10
+ <i class="tim-icons icon-simple-remove text-light"></i>
11
+ </a>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ <div class="col ml-n2">
16
+ <!-- Title -->
17
+ <h4 class="mb-1 text-body name">
18
+ <div class="dz-filename"><span data-dz-name></span></div>
19
+ <div class="dz-error-message"><span data-dz-errormessage></span></div>
20
+ </h4>
21
+ <!-- Time -->
22
+ <p class="mb-0 small text-muted">
23
+ <span class="fe fe-clock"></span>
24
+ <time data-dz-size></time>
25
+ </p>
26
+ <div class="ml-1 w-50 dz-progress">
27
+ <span class="dz-upload" data-dz-uploadprogress>
28
+ </span>
29
+ </div>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ </div>
@@ -0,0 +1,33 @@
1
+ <%#
2
+ # Item Partial
3
+
4
+ This partial renders attached items.
5
+
6
+ Attachments of type image, video and audio are emedded. For all other types
7
+ we try use it's preview. If all else fails we simply link to the attached file.
8
+
9
+ This partial will optionally show a `remove` link next to each attachment which is
10
+ controlled via a boolean local variable.
11
+
12
+ ## Local variables:
13
+
14
+ - `field`:
15
+ An instance of [Administrate::Field::Image].
16
+ A wrapper around the image url pulled from the database.
17
+ - `attachment`:
18
+ Reference to the file
19
+ - `removable`:
20
+ A boolean used to control the display of a `Remove` link which
21
+ is used to destroy a single attachment. Defaults to `false`
22
+ - `size`:
23
+ [x, y]
24
+ Maximum size of the ActiveStorage preview.
25
+ %>
26
+ <% if field.show_display_preview? %>
27
+ <div>
28
+ <%= render partial: 'fields/active_storage/normal/preview', locals: local_assigns %>
29
+ </div>
30
+ <% end %>
31
+ <div>
32
+ <%#= link_to attachment.filename, field.blob_url(attachment), title: attachment.filename %>
33
+ </div>
@@ -0,0 +1,35 @@
1
+ <%#
2
+ # Items Partial
3
+
4
+ This partial renders one or more attachments
5
+
6
+ ## Local variables:
7
+
8
+ - `field`:
9
+ An instance of [Administrate::Field::Image].
10
+ A wrapper around the image url pulled from the database.
11
+ - `removable`:
12
+ A boolean used to control the display of a `Remove` link which
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`.
18
+ %>
19
+ <%
20
+ removable = local_assigns.fetch(:removable, false)
21
+ size = local_assigns.fetch(:size, field.show_preview_size)
22
+ %>
23
+ <div class="d-flex" style="flex-wrap: wrap;">
24
+ <% field.attachments.each do |attachment| %>
25
+ <div class="attachments-listing m-1">
26
+ <%= render partial: 'fields/active_storage/normal/item',
27
+ locals: {
28
+ field: field,
29
+ attachment: attachment,
30
+ removable: removable,
31
+ size: size
32
+ } %>
33
+ </div>
34
+ <% end %>
35
+ </div>
@@ -4,6 +4,11 @@
4
4
  %>
5
5
  <% attachments.each do |attachment| %>
6
6
  <div class="attachments-listing">
7
- <%= render partial: 'fields/active_storage/item', locals: { field: field, attachment: attachment, removable: removable, image_size: field.show_preview_size } %>
7
+ <%= render partial: 'fields/active_storage/normal/item', locals: {
8
+ field: field,
9
+ attachment: attachment,
10
+ removable: removable,
11
+ image_size: field.show_preview_size
12
+ } %>
8
13
  </div>
9
14
  <% end %>
@@ -0,0 +1,42 @@
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 %>">
9
+ <% if attachment.image? %>
10
+ <% if attachment.variable? %>
11
+ <div class="avatar">
12
+ <%#= image_tag attachment.variant(resize_to_limit: image_size)%>
13
+ <%= image_tag(field.variant(attachment, resize_to_limit: size), class:"avatar-img rounded") %>
14
+ </div>
15
+ <% else %>
16
+ <%= image_tag(field.url(attachment)) %>
17
+ <% end %>
18
+ <% elsif attachment.video? %>
19
+ <style type="text/css" nonce="<%= content_security_policy_nonce %>">
20
+ #as-field-video-<%= attachment.id %> {
21
+ object-fit: contain;
22
+ width: 100%;
23
+ height: 100%;
24
+ }
25
+ </style>
26
+ <% if attachment.previewable? %>
27
+ <%= video_tag(field.url(attachment),
28
+ poster: field.preview(attachment, resize_to_limit: size),
29
+ controls: true,
30
+ autobuffer: true,
31
+ id: "as-field-video-#{attachment.id}") %>
32
+ <% else %>
33
+ <%= video_tag(field.url(attachment), controls: true, autobuffer: true, id: "as-field-video-#{attachment.id}") %>
34
+ <% end %>
35
+ <% elsif attachment.audio? %>
36
+ <%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
37
+ <% elsif attachment.previewable? %>
38
+ <%= image_tag(field.preview(attachment, resize_to_limit: size)) %>
39
+ <% else %>
40
+ <%= attachment.filename %>
41
+ <% end %>
42
+ </div>
@@ -17,6 +17,18 @@ module Administrate
17
17
  # theVariant.service.send(:path_for, theVariant.key) # Absolute path to variant file
18
18
  # end
19
19
 
20
+ def index_display_preview?
21
+ options.fetch(:index_display_preview, true)
22
+ end
23
+
24
+ def index_preview_size
25
+ options.fetch(:index_preview_size, [150, 150])
26
+ end
27
+
28
+ def show_display_preview?
29
+ options.fetch(:show_display_preview, true)
30
+ end
31
+
20
32
  def url_only?
21
33
  options.fetch(:url_only, false)
22
34
  end
@@ -34,7 +46,7 @@ module Administrate
34
46
  end
35
47
 
36
48
  def show_preview_size
37
- options.fetch(:show_preview_size, [1080, 1920])
49
+ options.fetch(:show_preview_size, [800, 800])
38
50
  end
39
51
 
40
52
  def many?
@@ -55,6 +67,10 @@ module Administrate
55
67
  options.fetch(:show_drop_js_on_show, false)
56
68
  end
57
69
 
70
+ def sweety_show_drop_js_on_show?
71
+ options.fetch(:sweety_show_drop_js_on_show, false)
72
+ end
73
+
58
74
  def drop_max_file?
59
75
  options.fetch(:drop_max_file, many? == true ? 10 : 1)
60
76
  end
@@ -86,7 +102,7 @@ module Administrate
86
102
  end
87
103
 
88
104
  def variant(attachment, options)
89
- Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(combine_options: options), only_path: true)
105
+ Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(options), only_path: true)
90
106
  end
91
107
 
92
108
  def url(attachment)
@@ -0,0 +1,13 @@
1
+ module ViniBaxter
2
+ # module SpaLanding
3
+ # VERSION = '15.0.0'
4
+ # end
5
+ module ViniBaxterFieldActiveStorage
6
+ MAJOR = 300
7
+ MINOR = 0
8
+ TINY = 4
9
+ PRE = "STUDIO"
10
+
11
+ VERSION = [MAJOR, MINOR, TINY].compact.join(".")
12
+ end
13
+ end
@@ -1,8 +1,9 @@
1
1
  $:.push File.expand_path("../lib", __FILE__)
2
+ require "viniBaxter/version"
2
3
 
3
4
  Gem::Specification.new do |gem|
4
5
  gem.name = "viniBaxter-field-active_storage"
5
- gem.version = "14.0.0"
6
+ gem.version = ViniBaxter::ViniBaxterFieldActiveStorage::VERSION
6
7
  gem.authors = ["viny baxter"]
7
8
  gem.email = ["vincent.viricel@gmail.com"]
8
9
  gem.homepage = "https://github.com/Dreamersoul/administrate-field-active_storage"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viniBaxter-field-active_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.0.0
4
+ version: 300.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - viny baxter
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-17 00:00:00.000000000 Z
11
+ date: 2022-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate
@@ -66,24 +66,30 @@ files:
66
66
  - README.md
67
67
  - Rakefile
68
68
  - _config.yml
69
- - app/views/fields/active_storage/_dropjs_items.html.erb
70
- - app/views/fields/active_storage/_dropjs_list_edit.html.erb
71
- - app/views/fields/active_storage/_dropjs_template.html.erb
72
69
  - app/views/fields/active_storage/_form.html.erb
73
70
  - app/views/fields/active_storage/_index.html.erb
74
- - app/views/fields/active_storage/_item.html.erb
75
- - app/views/fields/active_storage/_items.html.erb
76
- - app/views/fields/active_storage/_items_on_show.html.erb
77
71
  - app/views/fields/active_storage/_show.html.erb
72
+ - app/views/fields/active_storage/drop_js/_drop_js_items_if_sweety.html.erb
73
+ - app/views/fields/active_storage/drop_js/_drop_js_items_on_edit.html.erb
74
+ - app/views/fields/active_storage/drop_js/_drop_js_items_on_show.html.erb
75
+ - app/views/fields/active_storage/drop_js/_dropjs_items.html.erb
76
+ - app/views/fields/active_storage/drop_js/_dropjs_list_edit.html.erb
77
+ - app/views/fields/active_storage/drop_js/_dropjs_list_show.html.erb
78
+ - app/views/fields/active_storage/drop_js/_dropjs_template.html.erb
79
+ - app/views/fields/active_storage/normal/_item.html.erb
80
+ - app/views/fields/active_storage/normal/_items.html.erb
81
+ - app/views/fields/active_storage/normal/_items_on_show.html.erb
82
+ - app/views/fields/active_storage/normal/_preview.html.erb
78
83
  - contribute.md
79
84
  - lib/viniBaxter/field/active_storage.rb
85
+ - lib/viniBaxter/version.rb
80
86
  - spec/lib/administrate/field/active_storage_spec.rb
81
87
  - viniBaxter-field-active_storage.gemspec
82
88
  homepage: https://github.com/Dreamersoul/administrate-field-active_storage
83
89
  licenses:
84
90
  - MIT
85
91
  metadata: {}
86
- post_install_message:
92
+ post_install_message:
87
93
  rdoc_options: []
88
94
  require_paths:
89
95
  - lib
@@ -98,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
104
  - !ruby/object:Gem::Version
99
105
  version: '0'
100
106
  requirements: []
101
- rubygems_version: 3.0.3
102
- signing_key:
107
+ rubygems_version: 3.2.32
108
+ signing_key:
103
109
  specification_version: 4
104
110
  summary: Administrate fields for active storage
105
111
  test_files:
@@ -1,54 +0,0 @@
1
- <div class='list-group list-group-flush pt-4 my-n3'>
2
- <div class="dz-preview dz-file-preview bibi">
3
- <div class="list-group-item">
4
- <div class="row align-items-center">
5
- <div class="col-auto">
6
- <!-- Avatar -->
7
- <a href="#!" class="avatar">
8
- <img data-dz-thumbnail data-dz-remove class="avatar-img rounded delete_on_click" />
9
- </a>
10
- </div>
11
- <div class="col ml-n2">
12
- <!-- Title -->
13
- <h4 class="font-weight-normal mb-1">
14
- <a href="#!">
15
- <div class="dz-filename"><span data-dz-name></span></div>
16
- </a>
17
- </h4>
18
- <div class="dz-progress">
19
- <span
20
- class="dz-upload"
21
- data-dz-uploadprogress>
22
- </span>
23
- </div>
24
- <div class="dz-error-message"><span data-dz-errormessage ></span></div>
25
- <!-- Text -->
26
- <small class="text-muted">
27
- <div class="dz-size" data-dz-size></div>
28
- </small>
29
- </div>
30
- <div class="col-auto">
31
- <!-- Dropdown -->
32
- <div class="dropdown">
33
- <a href="#" class="dropdown-ellipses dropdown-toggle" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
34
- <i class="fe fe-more-vertical"></i>
35
- </a>
36
- <div class="dropdown-menu dropdown-menu-right">
37
- <a href="#!" class="dropdown-item">
38
- Action
39
- </a>
40
- <a href="#!" class="dropdown-item dz-remove delete_on_click" data-dz-remove>Remove file</a>
41
- <a href="#!" class="dropdown-item">
42
- Another action
43
- </a>
44
- <a href="#!" class="dropdown-item">
45
- Something else here
46
- </a>
47
- </div>
48
- </div>
49
- </div>
50
- </div>
51
- <!-- / .row -->
52
- </div>
53
- </div>
54
- </div>
@@ -1,35 +0,0 @@
1
- <% removable = local_assigns.fetch(:removable, false)
2
- image_size = local_assigns.fetch(:image_size, [200, 200]) %>
3
- <% if attachment.image? and attachment.variable? and !field.url_only? %>
4
- <div class="avatar avatar-lg">
5
- <%= image_tag attachment.variant(resize_to_limit: image_size), class:"avatar-img rounded"%>
6
- </div>
7
- <% elsif attachment.image? and !field.url_only? %>
8
- <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
9
- <%= image_tag(field.url(attachment)) %>
10
- <% end %>
11
- <% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
12
- <%= video_tag(field.url(attachment), poster: field.preview(attachment, resize_to_limit: image_size), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
13
- <% elsif attachment.video? and !field.url_only? %>
14
- <%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
15
- <% elsif attachment.audio? and !field.url_only? %>
16
- <%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
17
- <% else %>
18
- <%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
19
- <% if attachment.previewable? and !field.url_only? %>
20
- <%= image_tag(field.preview(attachment, resize_to_limit: [595, 842])) %>
21
- <% else %>
22
- <%= attachment.filename %>
23
- <% end %>
24
- <% end %>
25
- <% end %>
26
- <% if removable %>
27
- <%#= link_to 'Remove', field.destroy_path(field, attachment), method: :delete, class: 'remove-attachment-link' %>
28
- <%= link_to 'Remove', destroy_url,
29
- method: :delete,
30
- # data: { confirm: t("administrate.actions.confirm") },
31
- remote: true,
32
- class: 'remove-attachment-link'
33
- %>
34
- <hr>
35
- <% end %>
@@ -1,63 +0,0 @@
1
- <%#
2
- # Items Partial
3
-
4
- This partial renders one or more attachments
5
-
6
- ## Local variables:
7
-
8
- - `field`:
9
- An instance of [Administrate::Field::Image].
10
- A wrapper around the image url pulled from the database.
11
- - `removable`:
12
- A boolean used to control the display of a `Remove` link which
13
- is used to destroy a single attachment. Defaults to `false`
14
- %>
15
- <%
16
- attachments = Array(field.many? ? field.attachments : field.data)
17
- removable = local_assigns.fetch(:removable, false)
18
- %>
19
- <!-- On edit if no dropJS -->
20
- <% if !field.drop_js? %>
21
- <% attachments.each do |attachment| %>
22
- <div class="attachments-listing">
23
- <%= render partial: 'fields/active_storage/item', locals: {
24
- field: field,
25
- attachment: attachment,
26
- removable: removable,
27
- image_size: field.show_preview_size
28
- } %>
29
- </div>
30
- <% end %>
31
- <%else %>
32
- <!-- On edit if dropJS -->
33
- <div class="mt-5 col-12 ">
34
- <div class="row">
35
- <div class="col-12">
36
- <div class="card card light-shadow card-fill">
37
- <div class="card-header">
38
- <!-- Title -->
39
- <h4 class="card-header-title">
40
- Latest Uploads
41
- </h4>
42
- </div>
43
- <div class="card-body">
44
- <div class="already-downloaded dropzone">
45
- <div class="row">
46
- <% attachments.each do |attachment| %>
47
- <div class="col-12" id="<%= @page.class %>_picture_<%= attachment.id %>">
48
- <%= render partial: 'fields/active_storage/dropjs_list_edit', locals: {
49
- field: field,
50
- attachment: attachment,
51
- removable: removable,
52
- image_size: field.show_preview_size
53
- }%>
54
- </div>
55
- <% end %>
56
- </div>
57
- </div>
58
- </div>
59
- </div>
60
- </div>
61
- </div>
62
- </div>
63
- <% end %>