administrate-field-active_storage 0.3.1 → 0.3.6
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/README.md +27 -3
- data/administrate-field-active_storage.gemspec +1 -1
- data/app/views/fields/active_storage/_index.html.erb +1 -1
- data/app/views/fields/active_storage/_item.html.erb +7 -6
- data/app/views/fields/active_storage/_preview.html.erb +1 -1
- data/contribute.md +2 -0
- data/lib/administrate/field/active_storage.rb +3 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3930e26efcb0aa795b6606100a6dd6e8da523f80e7f201def1aa5ab79219217
|
4
|
+
data.tar.gz: '0286fd8dcca57e38402f283fef4971b62cb88d909d4a6d00255aaffa3581286e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2942162811a236a3adc02f9607a2d941f002e40b422b3a39c83a148666390542eb15235ae3a6f65d906b3a2075b19e7946e4278091af55ce254ad423886ae923
|
7
|
+
data.tar.gz: 4e7800b780d17f2bf6ee6faa0d0b11a1e22e1456397d46d8e38a04d619be800ae7fc2778364c23f1041ef1e42c34276b11db8ca58fd34906db5822d42a99ccb1
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.5
|
data/README.md
CHANGED
@@ -11,7 +11,7 @@ Add `administrate-field-active_storage` and `mini_magick` to your Gemfile (rails
|
|
11
11
|
|
12
12
|
```ruby
|
13
13
|
gem 'administrate-field-active_storage'
|
14
|
-
gem
|
14
|
+
gem "image_processing"
|
15
15
|
```
|
16
16
|
|
17
17
|
for rails 5.x use the following
|
@@ -102,7 +102,33 @@ module Admin
|
|
102
102
|
end
|
103
103
|
end
|
104
104
|
```
|
105
|
+
For `has_one_attached` cases, you will use:
|
105
106
|
|
107
|
+
```rb
|
108
|
+
# routes.rb
|
109
|
+
...
|
110
|
+
namespace :admin do
|
111
|
+
...
|
112
|
+
resources :users do
|
113
|
+
delete :avatar, on: :member, action: :destroy_avatar
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# app/controllers/admin/users_controller.rb
|
118
|
+
module Admin
|
119
|
+
class UsersController < ApplicationController
|
120
|
+
|
121
|
+
# For illustrative purposes only.
|
122
|
+
#
|
123
|
+
# **SECURITY NOTICE**: first verify whether current user is authorized to perform the action.
|
124
|
+
def destroy_avatar
|
125
|
+
avatar = requested_resource.avatar
|
126
|
+
avatar.purge
|
127
|
+
redirect_back(fallback_location: requested_resource)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
```
|
106
132
|
This route can be customized with `destroy_url`. The option expects a `proc` receiving 3 arguments:
|
107
133
|
the Administrate `namespace`, the `resource`, and the `attachment`. The proc can return anything
|
108
134
|
accepted by `link_to`:
|
@@ -125,8 +151,6 @@ class UserDashboard < Administrate::BaseDashboard
|
|
125
151
|
end
|
126
152
|
```
|
127
153
|
|
128
|
-
To disable this feature, set `destroy_url` to `nil`.
|
129
|
-
|
130
154
|
## Options
|
131
155
|
|
132
156
|
Various options can be passed to `Administrate::Field::ActiveStorage#with_options`
|
@@ -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.
|
5
|
+
gem.version = "0.3.6"
|
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"
|
@@ -23,19 +23,20 @@ controlled via a boolean local variable.
|
|
23
23
|
[x, y]
|
24
24
|
Maximum size of the ActiveStorage preview.
|
25
25
|
%>
|
26
|
+
<% if field.show_display_preview? %>
|
27
|
+
<div>
|
28
|
+
<%= render partial: 'fields/active_storage/preview', locals: local_assigns %>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
26
31
|
|
27
32
|
<div>
|
28
|
-
<%=
|
29
|
-
</div>
|
30
|
-
|
31
|
-
<div>
|
32
|
-
<%= link_to 'Download', field.blob_url(attachment), title: attachment.filename %>
|
33
|
+
<%= link_to attachment.filename, field.blob_url(attachment), title: attachment.filename %>
|
33
34
|
</div>
|
34
35
|
|
35
36
|
<% if field.destroy_url.present? %>
|
36
37
|
<% destroy_url = field.destroy_url.call(namespace, field.data.record, attachment) %>
|
37
38
|
<div>
|
38
|
-
<%= link_to 'Remove', destroy_url, method: :delete, class: 'remove-attachment-link' %>
|
39
|
+
<%= link_to 'Remove', destroy_url, method: :delete, class: 'remove-attachment-link', data: { confirm: t("administrate.actions.confirm") } %>
|
39
40
|
</div>
|
40
41
|
<hr>
|
41
42
|
<% end %>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
autobuffer: true,
|
14
14
|
style: "object-fit: contain; width: 100%; height: 100%;") %>
|
15
15
|
<% else %>
|
16
|
-
<%= video_tag(field.url(attachment), controls: true, autobuffer: true, style:
|
16
|
+
<%= video_tag(field.url(attachment), controls: true, autobuffer: true, style: "object-fit: contain; width: 100%; height: 100%;") %>
|
17
17
|
<% end %>
|
18
18
|
<% elsif attachment.audio? %>
|
19
19
|
<%= audio_tag(field.url(attachment), autoplay: false, controls: true) %>
|
data/contribute.md
CHANGED
@@ -11,3 +11,5 @@
|
|
11
11
|
- Daniel Tinoco [@0urobor0s](https://github.com/0urobor0s)
|
12
12
|
- Matthew Hui [@mhui](https://github.com/mhui)
|
13
13
|
- Sébastien Dubois [@sedubois](https://github.com/sedubois)
|
14
|
+
- Jazzy Gasper [@jazzygasper](https://github.com/jazzygasper)
|
15
|
+
- David Ma [@taikon](https://github.com/taikon)
|
@@ -16,7 +16,7 @@ module Administrate
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def index_display_count?
|
19
|
-
options.fetch(:index_display_count) {
|
19
|
+
options.fetch(:index_display_count) { attached? && attachments.count != 1 }
|
20
20
|
end
|
21
21
|
|
22
22
|
def show_display_preview?
|
@@ -36,13 +36,7 @@ module Administrate
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def destroy_url
|
39
|
-
options.fetch(:destroy_url)
|
40
|
-
proc do |namespace, record, attachment|
|
41
|
-
options = [attachment.name, namespace, record]
|
42
|
-
options << { attachment_id: attachment.id } if many?
|
43
|
-
options
|
44
|
-
end
|
45
|
-
end
|
39
|
+
options.fetch(:destroy_url, nil)
|
46
40
|
end
|
47
41
|
|
48
42
|
# currently we are using Rails.application.routes.url_helpers
|
@@ -56,7 +50,7 @@ module Administrate
|
|
56
50
|
end
|
57
51
|
|
58
52
|
def variant(attachment, options)
|
59
|
-
Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(
|
53
|
+
Rails.application.routes.url_helpers.rails_representation_path(attachment.variant(options), only_path: true)
|
60
54
|
end
|
61
55
|
|
62
56
|
def url(attachment)
|
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.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamad AlGhanim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|