viniBaxter-field-active_storage 3.0.0 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/fields/active_storage/_dropjs_items.html.erb +24 -0
- data/app/views/fields/active_storage/_dropjs_list_edit.html.erb +84 -0
- data/app/views/fields/active_storage/_dropjs_template.html.erb +54 -0
- data/app/views/fields/active_storage/_form.html.erb +15 -8
- data/app/views/fields/active_storage/_index.html.erb +17 -7
- data/app/views/fields/active_storage/_item.html.erb +41 -29
- data/app/views/fields/active_storage/_items.html.erb +43 -5
- data/app/views/fields/active_storage/_items_on_show.html.erb +9 -0
- data/app/views/fields/active_storage/_show.html.erb +5 -2
- data/lib/viniBaxter/field/active_storage.rb +44 -3
- data/viniBaxter-field-active_storage.gemspec +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d5ca940790c25b14fcae6e4fbbda5ba4e9a9e93b894a2b9d2460f1b8f923a2
|
4
|
+
data.tar.gz: ae3119f47aa46ec39d218d0781cdc8581e3bdc9ed7c89d7eca56988d6e78e293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47d56263a5fc5ee206bc848ffe0dea05a19b9df516d1f74bdd463aa335faa49d818046d2ebdbda6634e465293e88c85779a12465278765e902267d34fc55933f
|
7
|
+
data.tar.gz: 58dd1300740f61194ab4574f18d38f9333bafffce2d9066cb1ac9722ec9f99c4010c6cc8a8f889cbfb544b46a19750e321ec3a38550e7f400a84b7d7e00cf522
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="">
|
2
|
+
<div
|
3
|
+
class="dropzone dropzone-default dz-clickable"
|
4
|
+
data-controller="dropzonegem"
|
5
|
+
data-dropzonegem-max-file-size="<%= field.drop_max_file_size? %>"
|
6
|
+
data-dropzonegem-max-files="<%= field.drop_max_file? %>"
|
7
|
+
data-dropzonegem-accepted-files="<%= field.drop_accepted_files? %>"
|
8
|
+
data-dropzonegem-add-remove-links="hello">
|
9
|
+
<%= f.file_field field.attribute, multiple: field.many?, direct_upload: field.direct?, data: { target: 'dropzonegem.inputdropzonegem' } %>
|
10
|
+
<div class="dropzone-msg dz-message needsclick text-gray-600">
|
11
|
+
<h3 class="dropzone-msg-title">Drag & Drop here to upload or click here to browse</h3>
|
12
|
+
<span class="dropzone-msg-desc text-sm">
|
13
|
+
<%= field.drop_max_file_size? %>
|
14
|
+
MB par fichier. Les fichiers autorisés :
|
15
|
+
<%= field.drop_accepted_files? %>. Un maximum de
|
16
|
+
<%= field.drop_max_file? %> fichiers autorisés.
|
17
|
+
</span>
|
18
|
+
</div>
|
19
|
+
<div id="tpl" style='display:none'>
|
20
|
+
<%= render partial: 'fields/active_storage/dropjs_template'%>
|
21
|
+
</div>
|
22
|
+
<%#= render 'ulFordropjs' %>
|
23
|
+
</div>
|
24
|
+
</div>
|
@@ -0,0 +1,84 @@
|
|
1
|
+
<div class="list-group list-group-flush pt-4 my-n3 dz-image-preview dz-processing dz-success dz-complete">
|
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
|
+
<%
|
8
|
+
# By default we don't allow attachment removal
|
9
|
+
removable = local_assigns.fetch(:removable, false)
|
10
|
+
image_size = local_assigns.fetch(:image_size, [1920, 1080])
|
11
|
+
%>
|
12
|
+
<% if attachment.image? and attachment.variable? and !field.url_only? %>
|
13
|
+
<%= link_to(field.blob_url(attachment), title: attachment.filename, class:'avatar') do %>
|
14
|
+
<%= image_tag(field.variant(attachment, resize_to_limit: image_size),class:'avatar-img rounded 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
|
+
</div>
|
36
|
+
<div class="col ml-n2">
|
37
|
+
<h4 class="font-weight-normal mb-1">
|
38
|
+
<div class="dz-filename"> <span>SEO: </span><span data-dz-name=""><%= alt_method(attachment) %></span></div>
|
39
|
+
</h4>
|
40
|
+
<div class="dz-error-message"><span data-dz-errormessage=""></span></div>
|
41
|
+
<!-- Text -->
|
42
|
+
<small class="text-muted">
|
43
|
+
<div class="dz-size" data-dz-size="">
|
44
|
+
<strong>
|
45
|
+
<%= attachment.filename %> |
|
46
|
+
<%= attachment.byte_size.fdiv(1000).round(1) %>
|
47
|
+
</strong> KB</div>
|
48
|
+
</small>
|
49
|
+
</div>
|
50
|
+
<div class="col-auto">
|
51
|
+
<!-- Dropdown -->
|
52
|
+
<div class="dropdown">
|
53
|
+
<a href="#" class="dropdown-ellipses dropdown-toggle" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
54
|
+
<i class="fe fe-more-vertical"></i>
|
55
|
+
</a>
|
56
|
+
<div class="dropdown-menu dropdown-menu-right">
|
57
|
+
<%# <a href="#!" class="dropdown-item">
|
58
|
+
Action
|
59
|
+
</a> %>
|
60
|
+
<% if field.destroy_url.present? %>
|
61
|
+
<% destroy_url = field.destroy_url.call(namespace, field.data.record, attachment) %>
|
62
|
+
<div>
|
63
|
+
<%= link_to 'Remove', destroy_url,
|
64
|
+
method: :delete,
|
65
|
+
remote: true,
|
66
|
+
class: 'dropdown-item dz-remove delete_on_click' %>
|
67
|
+
</div>
|
68
|
+
<%# <hr> %>
|
69
|
+
<% end %>
|
70
|
+
<%#= link_to 'Remove file', field.destroy_path(field, attachment), method: :delete, remote: true, class: 'dropdown-item dz-remove delete_on_click' %>
|
71
|
+
<%# <a href="#!" class="dropdown-item">
|
72
|
+
Another action
|
73
|
+
</a>
|
74
|
+
<a href="#!" class="dropdown-item">
|
75
|
+
Something else here
|
76
|
+
</a> %>
|
77
|
+
</div>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
</div>
|
81
|
+
<!-- / .row -->
|
82
|
+
</div>
|
83
|
+
</div>
|
84
|
+
</div>
|
@@ -0,0 +1,54 @@
|
|
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>
|
@@ -14,17 +14,24 @@ By default, the input is a text field for the image's URL.
|
|
14
14
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
|
16
16
|
%>
|
17
|
-
|
18
17
|
<div class="field-unit__label">
|
19
18
|
<%= f.label field.attribute %>
|
20
19
|
</div>
|
21
|
-
|
22
20
|
<div class="field-unit__field">
|
23
|
-
<% if field.
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
<% if field.drop_js? %>
|
22
|
+
<!-- Form dropJS -->
|
23
|
+
<%= render partial: 'fields/active_storage/dropjs_items', locals: { f: f, field: field, removable: field.destroyable? } %>
|
24
|
+
<%else %>
|
25
|
+
<!-- Form if no dropJS -->
|
26
|
+
<%= f.file_field field.attribute, multiple: field.many?, direct_upload: field.direct? %>
|
27
|
+
<%end %>
|
28
|
+
<!-- show previous images recorded -->
|
29
|
+
<% if field.attached? %>
|
30
|
+
<% if !field.drop_js? %>
|
31
|
+
<%= render partial: 'fields/active_storage/items', locals: { field: field, removable: field.destroyable? } %>
|
32
|
+
<%= field.can_add_attachment? ? "Add:" : "Replace:" %>
|
33
|
+
<%else %>
|
34
|
+
<%= render partial: 'fields/active_storage/items', locals: { field: field, removable: field.destroyable? } %>
|
35
|
+
<%end %>
|
27
36
|
<% end %>
|
28
|
-
|
29
|
-
<%= f.file_field field.attribute, multiple: field.many?, direct_upload: field.direct? %>
|
30
37
|
</div>
|
@@ -14,19 +14,29 @@ By default, the attribute is rendered as an image tag.
|
|
14
14
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
|
16
16
|
%>
|
17
|
-
<style>
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
<style>
|
18
|
+
<%# figure out a way to remove this %>
|
19
|
+
td img {
|
20
|
+
max-height: unset !important;
|
21
|
+
}
|
21
22
|
</style>
|
22
23
|
<%
|
23
24
|
attachments = Array(field.many? ? field.attachments : field.data)
|
24
25
|
%>
|
25
26
|
<% if field.attached? %>
|
26
27
|
<% if field.show_in_index? %>
|
27
|
-
<%= render partial: 'fields/active_storage/item',
|
28
|
+
<%= render partial: 'fields/active_storage/item',
|
29
|
+
locals: {
|
30
|
+
field: field,
|
31
|
+
attachment: attachments[0],
|
32
|
+
image_size: [50, 50]
|
33
|
+
} %>
|
34
|
+
<% end %>
|
35
|
+
<% if field.index_display_count? %>
|
36
|
+
<div class="attachments-count">
|
37
|
+
<%= pluralize(field.attachments.count, 'Attachment') %>
|
38
|
+
</div>
|
28
39
|
<% end %>
|
29
|
-
<% pluralize(attachments.count, 'Attached file') %>
|
30
40
|
<% else %>
|
31
|
-
0 Attached files
|
41
|
+
0 Attached files
|
32
42
|
<% end %>
|
@@ -20,38 +20,50 @@ controlled via a boolean local variable.
|
|
20
20
|
A boolean used to control the display of a `Remove` link which
|
21
21
|
is used to destroy a single attachment. Defaults to `false`
|
22
22
|
%>
|
23
|
-
|
24
23
|
<%
|
25
24
|
# By default we don't allow attachment removal
|
26
25
|
removable = local_assigns.fetch(:removable, false)
|
27
26
|
image_size = local_assigns.fetch(:image_size, [1920, 1080])
|
28
27
|
%>
|
29
|
-
|
30
28
|
<% if attachment.image? and attachment.variable? and !field.url_only? %>
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
<%
|
29
|
+
<%#= link_to(field.blob_url(attachment), title: attachment.filename) do %>
|
30
|
+
<%#= image_tag(field.variant(attachment, resize_to_limit: image_size)) %>
|
31
|
+
<%#= link_to(field.blob_url(attachment), title: attachment.filename, class:'avatar avatar-sm mr-2') do %>
|
32
|
+
<%#= image_tag attachment, class:"avatar-img rounded-circle" %>
|
33
|
+
<!-- last option/ .comment -->
|
34
|
+
<%#= link_to(field.blob_url(attachment), title: attachment.filename, class:'avatar avatar-sm mr-2') do %>
|
35
|
+
<%#= image_tag(field.variant(attachment, resize_to_limit: image_size, quality: 100, :loader => {strip: true, type: "TrueColorMatte"}), class:"avatar-img rounded-circle") %>
|
36
|
+
<%# end %>
|
37
|
+
<!-- end of last option/ .comment -->
|
38
|
+
<div class="avatar avatar-lg">
|
39
|
+
<%= image_tag field.variant(attachment,resize: "400x400"), class:"avatar-img rounded" %>
|
40
|
+
</div>
|
41
|
+
<% elsif attachment.image? and !field.url_only? %>
|
42
|
+
<%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
|
43
|
+
<%= image_tag(field.url(attachment)) %>
|
44
|
+
<% end %>
|
45
|
+
<% elsif attachment.video? and attachment.previewable? and !field.url_only? %> <%# if ffmpeg is installed %>
|
46
|
+
<%= video_tag(field.url(attachment), poster: field.preview(attachment, resize_to_limit: image_size), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
|
47
|
+
<% elsif attachment.video? and !field.url_only? %>
|
48
|
+
<%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "width: 100%; height: auto;") %>
|
49
|
+
<% elsif attachment.audio? and !field.url_only? %>
|
50
|
+
<%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
|
51
|
+
<% else %>
|
52
|
+
<%= link_to(field.blob_url(attachment), title: attachment.filename) do %>
|
53
|
+
<% if attachment.previewable? and !field.url_only? %>
|
54
|
+
<%= image_tag(field.preview(attachment, resize_to_limit: [595, 842])) %>
|
55
|
+
<% else %>
|
56
|
+
<%= attachment.filename %>
|
57
|
+
<% end %>
|
58
|
+
<% end %>
|
59
|
+
<% end %>
|
60
|
+
<% if removable %>
|
61
|
+
<%#= link_to 'Remove', field.destroy_path(field, attachment), method: :delete, class: 'remove-attachment-link' %>
|
62
|
+
<%= link_to 'Remove', destroy_url,
|
63
|
+
method: :delete,
|
64
|
+
# data: { confirm: t("administrate.actions.confirm") },
|
65
|
+
remote: true,
|
66
|
+
class: 'remove-attachment-link'
|
67
|
+
%>
|
68
|
+
<hr>
|
69
|
+
<% end %>
|
@@ -12,14 +12,52 @@ This partial renders one or more attachments
|
|
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
14
|
%>
|
15
|
-
|
16
15
|
<%
|
17
16
|
attachments = Array(field.many? ? field.attachments : field.data)
|
18
17
|
removable = local_assigns.fetch(:removable, false)
|
19
18
|
%>
|
20
|
-
|
21
|
-
<%
|
22
|
-
|
23
|
-
|
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>
|
24
62
|
</div>
|
25
63
|
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%
|
2
|
+
attachments = Array(field.many? ? field.attachments : field.data)
|
3
|
+
removable = local_assigns.fetch(:removable, false)
|
4
|
+
%>
|
5
|
+
<% attachments.each do |attachment| %>
|
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 } %>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
@@ -14,7 +14,10 @@ By default, the attribute is rendered as an image tag.
|
|
14
14
|
|
15
15
|
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Image
|
16
16
|
%>
|
17
|
-
|
18
17
|
<% if field.attached? %>
|
19
|
-
|
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 } %>
|
22
|
+
<% end %>
|
20
23
|
<% end %>
|
@@ -19,19 +19,48 @@ module Administrate
|
|
19
19
|
options.fetch(:show_in_index, false)
|
20
20
|
end
|
21
21
|
|
22
|
+
def index_display_count?
|
23
|
+
options.fetch(:index_display_count) { attachments.present? && attachments.count != 1 }
|
24
|
+
end
|
25
|
+
|
22
26
|
def show_preview_size
|
23
27
|
options.fetch(:show_preview_size, [1080, 1920])
|
24
28
|
end
|
25
29
|
|
26
30
|
def many?
|
27
31
|
# find a way to use instance_of
|
28
|
-
data.class.name == 'ActiveStorage::Attached::Many'
|
32
|
+
# data.class.name == 'ActiveStorage::Attached::Many'
|
33
|
+
data.is_a? ::ActiveStorage::Attached::Many
|
29
34
|
end
|
30
35
|
|
31
36
|
def direct?
|
32
37
|
options.fetch(:direct_upload, false)
|
33
38
|
end
|
34
39
|
|
40
|
+
def drop_js?
|
41
|
+
options.fetch(:drop_js, false)
|
42
|
+
end
|
43
|
+
|
44
|
+
def show_drop_js_on_show?
|
45
|
+
options.fetch(:show_drop_js_on_show, false)
|
46
|
+
end
|
47
|
+
|
48
|
+
def drop_max_file?
|
49
|
+
options.fetch(:drop_max_file, many? == true ? 10 : 1)
|
50
|
+
end
|
51
|
+
|
52
|
+
def drop_max_file_size?
|
53
|
+
options.fetch(:drop_max_file_size, 10)
|
54
|
+
end
|
55
|
+
|
56
|
+
def drop_accepted_files?
|
57
|
+
options.fetch(:drop_accepted_files, ".jpeg,.jpg,.png,.gif,.svg")
|
58
|
+
end
|
59
|
+
|
60
|
+
def destroy_url
|
61
|
+
options.fetch(:destroy_url, nil)
|
62
|
+
end
|
63
|
+
|
35
64
|
# def destroy_path?
|
36
65
|
# options.fetch(:destroy_path, false).present?
|
37
66
|
# end
|
@@ -58,6 +87,11 @@ module Administrate
|
|
58
87
|
Rails.application.routes.url_helpers.rails_blob_path(attachment, disposition: :attachment, only_path: true)
|
59
88
|
end
|
60
89
|
|
90
|
+
def can_add_attachment?
|
91
|
+
many? || attachments.blank?
|
92
|
+
end
|
93
|
+
|
94
|
+
# this methode is no longer used ness to clean safety
|
61
95
|
def destroy_path(field, attachment)
|
62
96
|
destroy_path_helper = options.fetch(:destroy_path)
|
63
97
|
record_id = field.data.record.id
|
@@ -65,8 +99,15 @@ module Administrate
|
|
65
99
|
Rails.application.routes.url_helpers.send(destroy_path_helper, {:record_id => record_id, :attachment_id => attachment_id})
|
66
100
|
end
|
67
101
|
|
68
|
-
delegate :attached?, to: :data
|
69
|
-
delegate :attachments, to: :data
|
102
|
+
# delegate :attached?, to: :data
|
103
|
+
# delegate :attachments, to: :data
|
104
|
+
def attached?
|
105
|
+
data.present? && data.attached?
|
106
|
+
end
|
107
|
+
|
108
|
+
def attachments
|
109
|
+
data.attachments if attached?
|
110
|
+
end
|
70
111
|
end
|
71
112
|
end
|
72
113
|
end
|
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "viniBaxter-field-active_storage"
|
5
|
-
gem.version = "
|
5
|
+
gem.version = "9.0.0"
|
6
6
|
gem.authors = ["viny baxter"]
|
7
7
|
gem.email = ["vincent.viricel@gmail.com"]
|
8
8
|
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:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- viny baxter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|
@@ -66,10 +66,14 @@ 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
|
69
72
|
- app/views/fields/active_storage/_form.html.erb
|
70
73
|
- app/views/fields/active_storage/_index.html.erb
|
71
74
|
- app/views/fields/active_storage/_item.html.erb
|
72
75
|
- app/views/fields/active_storage/_items.html.erb
|
76
|
+
- app/views/fields/active_storage/_items_on_show.html.erb
|
73
77
|
- app/views/fields/active_storage/_show.html.erb
|
74
78
|
- contribute.md
|
75
79
|
- lib/viniBaxter/field/active_storage.rb
|