administrate-field-active_storage 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +11 -10
- data/README.md +7 -1
- data/administrate-field-active_storage.gemspec +1 -1
- data/app/views/fields/active_storage/_index.html.erb +4 -2
- data/app/views/fields/active_storage/_item.html.erb +5 -0
- data/app/views/fields/active_storage/_items.html.erb +3 -1
- data/lib/administrate/field/active_storage.rb +4 -0
- 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: 679096f1bc559346a74c8a88c6ae7df7a540f0660b8ccf729332047f4908b2b7
|
4
|
+
data.tar.gz: 1de086adcc1ef686c0e28b8d012e5291a56928b2c35503a9915be4720b71391c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20b177e400de627190c436537ee31c05cd5bc7407c1c37913f9eec62c14e92bd4393c86bd0d8eec5ab5fb6afec98d237c92b1a1f4a2f9974bde1e7607dfa0129
|
7
|
+
data.tar.gz: ee7c23703ce310ee931f46dfb3df279296bef5614a0ca99507d275d28fe6b547339f54ff6c262318461dc4096da0e06cb390826749de7b5230fb7096f0c74418
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
administrate-field-active_storage (0.
|
4
|
+
administrate-field-active_storage (1.0.1)
|
5
5
|
administrate (>= 0.2.2)
|
6
6
|
rails (>= 7.0)
|
7
7
|
|
@@ -67,12 +67,12 @@ GEM
|
|
67
67
|
i18n (>= 1.6, < 2)
|
68
68
|
minitest (>= 5.1)
|
69
69
|
tzinfo (~> 2.0)
|
70
|
-
administrate (0.
|
71
|
-
actionpack (>=
|
72
|
-
actionview (>=
|
73
|
-
activerecord (>=
|
74
|
-
jquery-rails (
|
75
|
-
kaminari (
|
70
|
+
administrate (0.20.1)
|
71
|
+
actionpack (>= 6.0, < 8.0)
|
72
|
+
actionview (>= 6.0, < 8.0)
|
73
|
+
activerecord (>= 6.0, < 8.0)
|
74
|
+
jquery-rails (~> 4.6.0)
|
75
|
+
kaminari (~> 1.2.2)
|
76
76
|
sassc-rails (~> 2.1)
|
77
77
|
selectize-rails (~> 0.6)
|
78
78
|
ast (2.4.2)
|
@@ -126,16 +126,16 @@ GEM
|
|
126
126
|
mini_mime (1.1.5)
|
127
127
|
mini_portile2 (2.8.5)
|
128
128
|
minitest (5.15.0)
|
129
|
-
net-imap (0.4.
|
129
|
+
net-imap (0.4.10)
|
130
130
|
date
|
131
131
|
net-protocol
|
132
132
|
net-pop (0.1.2)
|
133
133
|
net-protocol
|
134
134
|
net-protocol (0.2.2)
|
135
135
|
timeout
|
136
|
-
net-smtp (0.4.0)
|
136
|
+
net-smtp (0.4.0.1)
|
137
137
|
net-protocol
|
138
|
-
nio4r (2.
|
138
|
+
nio4r (2.7.0)
|
139
139
|
nokogiri (1.13.3)
|
140
140
|
mini_portile2 (~> 2.8.0)
|
141
141
|
racc (~> 1.4)
|
@@ -208,6 +208,7 @@ GEM
|
|
208
208
|
|
209
209
|
PLATFORMS
|
210
210
|
arm64-darwin-21
|
211
|
+
arm64-darwin-22
|
211
212
|
x86_64-darwin-20
|
212
213
|
x86_64-linux
|
213
214
|
|
data/README.md
CHANGED
@@ -60,7 +60,9 @@ class ModelDashboard < Administrate::BaseDashboard
|
|
60
60
|
```
|
61
61
|
I know it is not ideal, if you have a workaround please submit a PR.
|
62
62
|
|
63
|
-
Note: Rails 6 introduced a new config to determine the behavior on updates to `has_many_attached`. Setting `Rails.application.config.active_storage.replace_on_assign_to_many` to `true` will overwrite any existing values (purging the old ones), and setting it to `false` will append the new values.
|
63
|
+
Note: Rails 6 introduced a new config to determine the behavior on updates to `has_many_attached`. Setting `Rails.application.config.active_storage.replace_on_assign_to_many` to `true` will overwrite any existing values (purging the old ones), and setting it to `false` will append the new values. Please note that this configuation was [deprecated with Rails 7.1](https://github.com/rails/rails/blob/v7.0.2.3/activestorage/lib/active_storage/attached/model.rb#L150)
|
64
|
+
>config.active_storage.replace_on_assign_to_many is deprecated and will be removed in Rails 7.1. Make sure that your code works well with config.active_storage.replace_on_assign_to_many set to true before upgrading. To append new attachables to the Active Storage association, prefer using attach. Using association setter would result in purging the existing attached attachments and replacing them with new ones.
|
65
|
+
|
64
66
|
|
65
67
|
### Prevent N+1 queries
|
66
68
|
In order to prevent N+1 queries from active storage you have to modify your admin model controller, below an example for a model called `User` and with attached avatars
|
@@ -182,6 +184,10 @@ in the `index` action.
|
|
182
184
|
|
183
185
|
Defaults to `true`.
|
184
186
|
|
187
|
+
### index_preview_only
|
188
|
+
|
189
|
+
If true, will show only the preview in the `index` action, and not the filename or destroy link (if set).
|
190
|
+
|
185
191
|
### index_preview_size and show_preview_size
|
186
192
|
|
187
193
|
Indicate the size of the image preview for the `index` and `show` actions, respectively.
|
@@ -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 = "1.0.
|
5
|
+
gem.version = "1.0.2"
|
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"
|
@@ -22,7 +22,8 @@ By default, the attribute is rendered as an image tag.
|
|
22
22
|
locals: {
|
23
23
|
field: field,
|
24
24
|
variant: field.index_preview_variant,
|
25
|
-
size: field.index_preview_size
|
25
|
+
size: field.index_preview_size,
|
26
|
+
preview_only: field.index_preview_only?
|
26
27
|
} %>
|
27
28
|
<% else %>
|
28
29
|
<%= render partial: 'fields/active_storage/item',
|
@@ -30,7 +31,8 @@ By default, the attribute is rendered as an image tag.
|
|
30
31
|
field: field,
|
31
32
|
attachment: field.data,
|
32
33
|
variant: field.index_preview_variant,
|
33
|
-
size: field.index_preview_size
|
34
|
+
size: field.index_preview_size,
|
35
|
+
preview_only: field.index_preview_only?
|
34
36
|
} %>
|
35
37
|
<% end %>
|
36
38
|
<% end %>
|
@@ -19,13 +19,17 @@ controlled via a boolean local variable.
|
|
19
19
|
- `size`:
|
20
20
|
[x, y]
|
21
21
|
Maximum size of the ActiveStorage preview.
|
22
|
+
- `preview_only`:
|
23
|
+
If true, show only the previous and not the name or destroy link
|
22
24
|
%>
|
25
|
+
<% preview_only = local_assigns.fetch(:preview_only, false) %>
|
23
26
|
<% if field.show_display_preview? && attachment.persisted? %>
|
24
27
|
<div>
|
25
28
|
<%= render partial: 'fields/active_storage/preview', locals: local_assigns %>
|
26
29
|
</div>
|
27
30
|
<% end %>
|
28
31
|
|
32
|
+
<% unless preview_only %>
|
29
33
|
<% if attachment.persisted? %>
|
30
34
|
<div>
|
31
35
|
<%= link_to attachment.filename, field.blob_url(attachment), title: attachment.filename %>
|
@@ -40,3 +44,4 @@ controlled via a boolean local variable.
|
|
40
44
|
</div>
|
41
45
|
<hr>
|
42
46
|
<% end %>
|
47
|
+
<% end %>
|
@@ -17,6 +17,7 @@ This partial renders one or more attachments
|
|
17
17
|
<%
|
18
18
|
variant = local_assigns.fetch(:variant, field.show_preview_variant)
|
19
19
|
size = local_assigns.fetch(:size, field.show_preview_size)
|
20
|
+
preview_only = local_assigns.fetch(:preview_only, false)
|
20
21
|
%>
|
21
22
|
|
22
23
|
<% field.attachments.each do |attachment| %>
|
@@ -26,7 +27,8 @@ This partial renders one or more attachments
|
|
26
27
|
field: field,
|
27
28
|
attachment: attachment,
|
28
29
|
variant: variant,
|
29
|
-
size: size
|
30
|
+
size: size,
|
31
|
+
preview_only: preview_only
|
30
32
|
} %>
|
31
33
|
</div>
|
32
34
|
<% end %>
|
@@ -20,6 +20,10 @@ module Administrate
|
|
20
20
|
options.fetch(:index_preview_variant, nil)
|
21
21
|
end
|
22
22
|
|
23
|
+
def index_preview_only?
|
24
|
+
options.fetch(:index_preview_only, false)
|
25
|
+
end
|
26
|
+
|
23
27
|
def index_display_count?
|
24
28
|
options.fetch(:index_display_count) { attached? && attachments.count != 1 }
|
25
29
|
end
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamad AlGhanim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|