administrate-field-active_storage 1.0.0 → 1.0.2

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: 03bb904e84f812c143ffd299953296173301a72e1d26b897c835bb68581978c2
4
- data.tar.gz: 88b1502b5b0f3a92d28c78e2e54621024dd3c3ff57b31ac2d53b496a9951ac43
3
+ metadata.gz: 679096f1bc559346a74c8a88c6ae7df7a540f0660b8ccf729332047f4908b2b7
4
+ data.tar.gz: 1de086adcc1ef686c0e28b8d012e5291a56928b2c35503a9915be4720b71391c
5
5
  SHA512:
6
- metadata.gz: 35555e8d94b496e494c28f2f9c2fa24a70ee359dffb66181abf1cc079a95efd761ba0a513a4087f6db0fe0b5c7ebf3f2533a4eab5ff204c2d87d8d9bf9df7153
7
- data.tar.gz: 814f250f4eaa7e5d5dbcf05f282daf0ae3ee3544419942ec16a42881905a32f478f4e09e1b1fadd735821e902229c045ce5ef8ce70d9616a071dc47045851aa0
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.1)
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.19.0)
71
- actionpack (>= 5.0)
72
- actionview (>= 5.0)
73
- activerecord (>= 5.0)
74
- jquery-rails (>= 4.0)
75
- kaminari (>= 1.0)
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.5)
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.6.0)
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.
@@ -201,6 +207,10 @@ It might be necessary to add to app/assets/config/manifest.js:
201
207
  ```
202
208
  When set, this takes precedence over `index_preview_size` and `show_preview_size`.
203
209
 
210
+ Setting this to `false` displays original images instead of variants.
211
+
212
+ Defaults to `nil`.
213
+
204
214
  ### index_display_count
205
215
 
206
216
  Displays the number of attachments in the `index` action.
@@ -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.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 %>
@@ -3,6 +3,8 @@
3
3
  <% if attachment.variable? %>
4
4
  <% if variant.nil? %>
5
5
  <%= image_tag(field.variant(attachment, resize_to_limit: size)) %>
6
+ <% elsif variant == false %>
7
+ <%= image_tag(field.url(attachment)) %>
6
8
  <% else %>
7
9
  <%= image_tag(attachment.variant(variant)) %>
8
10
  <% end %>
data/contribute.md CHANGED
@@ -15,3 +15,4 @@
15
15
  - David Ma [@taikon](https://github.com/taikon)
16
16
  - Dmitry Davydov [@haukot](https://github.com/haukot)
17
17
  - Jeanine Soterwood [@littleforest](https://github.com/littleforest)
18
+ - Shouichi Kamiya [@shouichi](https://github.com/shouichi)
@@ -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.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: 2023-11-18 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate