administrate-field-active_storage 1.0.2 → 1.0.3

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: 679096f1bc559346a74c8a88c6ae7df7a540f0660b8ccf729332047f4908b2b7
4
- data.tar.gz: 1de086adcc1ef686c0e28b8d012e5291a56928b2c35503a9915be4720b71391c
3
+ metadata.gz: 12fb995471a84f218352f4c630c6de6088c1eec7b975671f42125a1f91fe05d5
4
+ data.tar.gz: 797c67a7742599097b761314a457f1f53f3153aeb5c6aa72c4556cfd0a86d449
5
5
  SHA512:
6
- metadata.gz: 20b177e400de627190c436537ee31c05cd5bc7407c1c37913f9eec62c14e92bd4393c86bd0d8eec5ab5fb6afec98d237c92b1a1f4a2f9974bde1e7607dfa0129
7
- data.tar.gz: ee7c23703ce310ee931f46dfb3df279296bef5614a0ca99507d275d28fe6b547339f54ff6c262318461dc4096da0e06cb390826749de7b5230fb7096f0c74418
6
+ metadata.gz: 3d285fd017385d5ce56a18a2ef464b5ec5d981fa065fe8a59706db2b7716676d81fbff44909a4b1543cfb70821c2368057184d0095bf6aaaafcf3e9139ad1b8e
7
+ data.tar.gz: 6ccbf0a5119607bda9110ace878002ba9a8fd40ae39573c112c96f14cc69c0fa54855ddf28bc5ce7e437776532a85f2d3f5c44cea8373b4a695176cd78000493
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- administrate-field-active_storage (1.0.1)
4
+ administrate-field-active_storage (1.0.2)
5
5
  administrate (>= 0.2.2)
6
6
  rails (>= 7.0)
7
7
 
@@ -121,23 +121,25 @@ GEM
121
121
  net-imap
122
122
  net-pop
123
123
  net-smtp
124
- marcel (1.0.2)
124
+ marcel (1.0.4)
125
125
  method_source (1.0.0)
126
126
  mini_mime (1.1.5)
127
- mini_portile2 (2.8.5)
128
127
  minitest (5.15.0)
129
- net-imap (0.4.10)
128
+ net-imap (0.4.11)
130
129
  date
131
130
  net-protocol
132
131
  net-pop (0.1.2)
133
132
  net-protocol
134
133
  net-protocol (0.2.2)
135
134
  timeout
136
- net-smtp (0.4.0.1)
135
+ net-smtp (0.5.0)
137
136
  net-protocol
138
- nio4r (2.7.0)
139
- nokogiri (1.13.3)
140
- mini_portile2 (~> 2.8.0)
137
+ nio4r (2.7.3)
138
+ nokogiri (1.13.3-arm64-darwin)
139
+ racc (~> 1.4)
140
+ nokogiri (1.13.3-x86_64-darwin)
141
+ racc (~> 1.4)
142
+ nokogiri (1.13.3-x86_64-linux)
141
143
  racc (~> 1.4)
142
144
  parser (3.0.3.2)
143
145
  ast (~> 2.4.1)
@@ -192,7 +194,9 @@ GEM
192
194
  actionpack (>= 5.2)
193
195
  activesupport (>= 5.2)
194
196
  sprockets (>= 3.0.0)
195
- sqlite3 (1.4.2)
197
+ sqlite3 (1.7.3-arm64-darwin)
198
+ sqlite3 (1.7.3-x86_64-darwin)
199
+ sqlite3 (1.7.3-x86_64-linux)
196
200
  terminal-table (3.0.2)
197
201
  unicode-display_width (>= 1.1.1, < 3)
198
202
  thor (1.1.0)
@@ -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.2"
5
+ gem.version = "1.0.3"
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"
@@ -16,27 +16,14 @@ By default, the attribute is rendered as an image tag.
16
16
  %>
17
17
 
18
18
  <% if field.attached? %>
19
- <% if field.index_display_preview? %>
20
- <% if field.many? %>
21
- <%= render partial: 'fields/active_storage/items',
22
- locals: {
23
- field: field,
24
- variant: field.index_preview_variant,
25
- size: field.index_preview_size,
26
- preview_only: field.index_preview_only?
27
- } %>
28
- <% else %>
29
- <%= render partial: 'fields/active_storage/item',
30
- locals: {
31
- field: field,
32
- attachment: field.data,
33
- variant: field.index_preview_variant,
34
- size: field.index_preview_size,
35
- preview_only: field.index_preview_only?
36
- } %>
37
- <% end %>
38
- <% end %>
39
-
19
+ <%= render partial: "fields/active_storage/items",
20
+ locals: {
21
+ field: field,
22
+ variant: field.index_preview_variant,
23
+ size: field.index_preview_size,
24
+ display_preview: field.index_display_preview?,
25
+ preview_only: field.index_preview_only?
26
+ } %>
40
27
  <% if field.index_display_count? %>
41
28
  <div class="attachments-count">
42
29
  <%= pluralize(field.attachments.count,
@@ -22,8 +22,9 @@ controlled via a boolean local variable.
22
22
  - `preview_only`:
23
23
  If true, show only the previous and not the name or destroy link
24
24
  %>
25
- <% preview_only = local_assigns.fetch(:preview_only, false) %>
26
- <% if field.show_display_preview? && attachment.persisted? %>
25
+ <% preview_only = local_assigns.fetch(:preview_only, false)
26
+ display_preview = local_assigns.fetch(:display_preview, field.show_display_preview?) %>
27
+ <% if display_preview && attachment.persisted? %>
27
28
  <div>
28
29
  <%= render partial: 'fields/active_storage/preview', locals: local_assigns %>
29
30
  </div>
@@ -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
+ display_preview = local_assigns.fetch(:display_preview, field.show_display_preview?)
20
21
  preview_only = local_assigns.fetch(:preview_only, false)
21
22
  %>
22
23
 
@@ -28,6 +29,7 @@ This partial renders one or more attachments
28
29
  attachment: attachment,
29
30
  variant: variant,
30
31
  size: size,
32
+ display_preview: display_preview,
31
33
  preview_only: preview_only
32
34
  } %>
33
35
  </div>
@@ -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.2)
5
5
  administrate (>= 0.2.2)
6
6
  rails (>= 7.0)
7
7
 
@@ -84,18 +84,16 @@ GEM
84
84
  tzinfo (~> 2.0)
85
85
  addressable (2.8.0)
86
86
  public_suffix (>= 2.0.2, < 5.0)
87
- administrate (0.16.0)
88
- actionpack (>= 5.0)
89
- actionview (>= 5.0)
90
- activerecord (>= 5.0)
91
- datetime_picker_rails (~> 0.0.7)
92
- jquery-rails (>= 4.0)
93
- kaminari (>= 1.0)
94
- momentjs-rails (~> 2.8)
87
+ administrate (0.20.1)
88
+ actionpack (>= 6.0, < 8.0)
89
+ actionview (>= 6.0, < 8.0)
90
+ activerecord (>= 6.0, < 8.0)
91
+ jquery-rails (~> 4.6.0)
92
+ kaminari (~> 1.2.2)
95
93
  sassc-rails (~> 2.1)
96
94
  selectize-rails (~> 0.6)
97
95
  base64 (0.2.0)
98
- bigdecimal (3.1.4)
96
+ bigdecimal (3.1.8)
99
97
  bindex (0.8.1)
100
98
  builder (3.2.4)
101
99
  byebug (11.1.3)
@@ -109,28 +107,25 @@ GEM
109
107
  regexp_parser (>= 1.5, < 3.0)
110
108
  xpath (~> 3.2)
111
109
  childprocess (4.1.0)
112
- concurrent-ruby (1.2.2)
110
+ concurrent-ruby (1.2.3)
113
111
  connection_pool (2.4.1)
114
112
  crass (1.0.6)
115
113
  date (3.3.4)
116
- datetime_picker_rails (0.0.7)
117
- momentjs-rails (>= 2.8.1)
118
- drb (2.2.0)
119
- ruby2_keywords
114
+ drb (2.2.1)
120
115
  erubi (1.12.0)
121
- ffi (1.15.4)
116
+ ffi (1.16.3)
122
117
  globalid (1.2.1)
123
118
  activesupport (>= 6.1)
124
- i18n (1.14.1)
119
+ i18n (1.14.5)
125
120
  concurrent-ruby (~> 1.0)
126
121
  image_processing (1.12.2)
127
122
  mini_magick (>= 4.9.5, < 5)
128
123
  ruby-vips (>= 2.0.17, < 3)
129
- io-console (0.6.0)
130
- irb (1.9.0)
131
- rdoc
132
- reline (>= 0.3.8)
133
- jquery-rails (4.4.0)
124
+ io-console (0.7.2)
125
+ irb (1.13.1)
126
+ rdoc (>= 4.0.0)
127
+ reline (>= 0.4.2)
128
+ jquery-rails (4.6.0)
134
129
  rails-dom-testing (>= 1, < 3)
135
130
  railties (>= 4.2.0)
136
131
  thor (>= 0.14, < 2.0)
@@ -158,9 +153,7 @@ GEM
158
153
  matrix (0.4.2)
159
154
  mini_magick (4.12.0)
160
155
  mini_mime (1.1.5)
161
- minitest (5.20.0)
162
- momentjs-rails (2.29.1)
163
- railties (>= 3.1)
156
+ minitest (5.23.0)
164
157
  mutex_m (0.2.0)
165
158
  net-imap (0.4.5)
166
159
  date
@@ -172,28 +165,28 @@ GEM
172
165
  net-smtp (0.4.0)
173
166
  net-protocol
174
167
  nio4r (2.6.0)
175
- nokogiri (1.15.5-arm64-darwin)
168
+ nokogiri (1.16.5-arm64-darwin)
176
169
  racc (~> 1.4)
177
- nokogiri (1.15.5-x86_64-darwin)
170
+ nokogiri (1.16.5-x86_64-darwin)
178
171
  racc (~> 1.4)
179
- nokogiri (1.15.5-x86_64-linux)
172
+ nokogiri (1.16.5-x86_64-linux)
180
173
  racc (~> 1.4)
181
- psych (5.1.1.1)
174
+ psych (5.1.2)
182
175
  stringio
183
176
  public_suffix (4.0.6)
184
177
  puma (5.6.4)
185
178
  nio4r (~> 2.0)
186
179
  racc (1.7.3)
187
- rack (2.2.8)
180
+ rack (3.0.11)
188
181
  rack-mini-profiler (2.3.3)
189
182
  rack (>= 1.2.0)
190
- rack-session (1.0.1)
191
- rack (< 3)
183
+ rack-session (2.0.0)
184
+ rack (>= 3.0.0)
192
185
  rack-test (2.1.0)
193
186
  rack (>= 1.3)
194
- rackup (1.0.0)
195
- rack (< 3)
196
- webrick
187
+ rackup (2.1.0)
188
+ rack (>= 3)
189
+ webrick (~> 1.8)
197
190
  rails (7.1.2)
198
191
  actioncable (= 7.1.2)
199
192
  actionmailbox (= 7.1.2)
@@ -223,16 +216,15 @@ GEM
223
216
  rake (>= 12.2)
224
217
  thor (~> 1.0, >= 1.2.2)
225
218
  zeitwerk (~> 2.6)
226
- rake (13.1.0)
227
- rdoc (6.6.0)
219
+ rake (13.2.1)
220
+ rdoc (6.6.3.1)
228
221
  psych (>= 4.0.0)
229
222
  regexp_parser (2.2.0)
230
- reline (0.4.0)
223
+ reline (0.5.7)
231
224
  io-console (~> 0.5)
232
225
  rexml (3.2.5)
233
226
  ruby-vips (2.2.0)
234
227
  ffi (~> 1.12)
235
- ruby2_keywords (0.0.5)
236
228
  rubyzip (2.3.2)
237
229
  sass-rails (6.0.0)
238
230
  sassc-rails (~> 2.1, >= 2.1.1)
@@ -249,17 +241,19 @@ GEM
249
241
  childprocess (>= 0.5, < 5.0)
250
242
  rexml (~> 3.2, >= 3.2.5)
251
243
  rubyzip (>= 1.2.2)
252
- sprockets (4.0.2)
244
+ sprockets (4.2.1)
253
245
  concurrent-ruby (~> 1.0)
254
- rack (> 1, < 3)
246
+ rack (>= 2.2.4, < 4)
255
247
  sprockets-rails (3.4.2)
256
248
  actionpack (>= 5.2)
257
249
  activesupport (>= 5.2)
258
250
  sprockets (>= 3.0.0)
259
- sqlite3 (1.4.2)
260
- stringio (3.0.9)
261
- thor (1.3.0)
262
- tilt (2.0.10)
251
+ sqlite3 (1.7.3-arm64-darwin)
252
+ sqlite3 (1.7.3-x86_64-darwin)
253
+ sqlite3 (1.7.3-x86_64-linux)
254
+ stringio (3.1.0)
255
+ thor (1.3.1)
256
+ tilt (2.3.0)
263
257
  timeout (0.4.1)
264
258
  tzinfo (2.0.6)
265
259
  concurrent-ruby (~> 1.0)
@@ -274,7 +268,7 @@ GEM
274
268
  websocket-extensions (0.1.5)
275
269
  xpath (3.2.0)
276
270
  nokogiri (~> 1.8)
277
- zeitwerk (2.6.12)
271
+ zeitwerk (2.6.14)
278
272
 
279
273
  PLATFORMS
280
274
  arm64-darwin-23
@@ -42,5 +42,11 @@ module Admin
42
42
 
43
43
  # See https://administrate-prototype.herokuapp.com/customizing_controller_actions
44
44
  # for more information
45
+
46
+ def destroy_other_image
47
+ other_image = requested_resource.other_images.find(params[:attachment_id])
48
+ other_image.purge
49
+ redirect_back(fallback_location: requested_resource)
50
+ end
45
51
  end
46
52
  end
@@ -10,6 +10,11 @@ class PostDashboard < Administrate::BaseDashboard
10
10
  ATTRIBUTE_TYPES = {
11
11
  id: Field::Number,
12
12
  cover_image: Field::ActiveStorage,
13
+ other_images: Field::ActiveStorage.with_options(
14
+ destroy_url: proc do |namespace, resource, attachment|
15
+ [:other_image_admin_post, { id: resource.id, attachment_id: attachment.id }]
16
+ end
17
+ ),
13
18
  title: Field::String,
14
19
  created_at: Field::DateTime,
15
20
  updated_at: Field::DateTime,
@@ -24,6 +29,7 @@ class PostDashboard < Administrate::BaseDashboard
24
29
  id
25
30
  title
26
31
  cover_image
32
+ other_images
27
33
  created_at
28
34
  ].freeze
29
35
 
@@ -33,6 +39,7 @@ class PostDashboard < Administrate::BaseDashboard
33
39
  id
34
40
  title
35
41
  cover_image
42
+ other_images
36
43
  created_at
37
44
  updated_at
38
45
  ].freeze
@@ -43,6 +50,7 @@ class PostDashboard < Administrate::BaseDashboard
43
50
  FORM_ATTRIBUTES = %i[
44
51
  title
45
52
  cover_image
53
+ other_images
46
54
  ].freeze
47
55
 
48
56
  # COLLECTION_FILTERS
@@ -63,4 +71,8 @@ class PostDashboard < Administrate::BaseDashboard
63
71
  # def display_resource(post)
64
72
  # "Post ##{post.id}"
65
73
  # end
74
+
75
+ def permitted_attributes(action = nil)
76
+ super + [:other_images => []]
77
+ end
66
78
  end
@@ -1,5 +1,6 @@
1
1
  class Post < ApplicationRecord
2
2
  has_one_attached :cover_image
3
+ has_many_attached :other_images
3
4
 
4
5
  validates :title, presence: true
5
6
  end
@@ -2,7 +2,9 @@ Rails.application.routes.draw do
2
2
  # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
3
3
 
4
4
  namespace :admin do
5
- resources :posts
5
+ resources :posts do
6
+ delete :other_image, on: :member, action: :destroy_other_image
7
+ end
6
8
 
7
9
  root to: "posts#index"
8
10
  end
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended that you check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(version: 2023_11_17_224946) do
13
+ ActiveRecord::Schema[7.1].define(version: 2023_11_17_224946) do
14
14
  create_table "active_storage_attachments", force: :cascade do |t|
15
15
  t.string "name", null: false
16
16
  t.string "record_type", null: false
@@ -40,9 +40,9 @@ ActiveRecord::Schema.define(version: 2023_11_17_224946) do
40
40
  end
41
41
 
42
42
  create_table "posts", force: :cascade do |t|
43
- t.string "title"
44
43
  t.datetime "created_at", null: false
45
44
  t.datetime "updated_at", null: false
45
+ t.string "title"
46
46
  end
47
47
 
48
48
  add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
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.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamad AlGhanim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-30 00:00:00.000000000 Z
11
+ date: 2024-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: administrate