Skip to content

Commit

Permalink
Inline the attachment form for taxon icons
Browse files Browse the repository at this point in the history
There's no explicit support for multiple taxon attachment anywhere
else in the solidus codebase, and the attachment_partial_name was
using "paperclip" even for active_storage.

Given attachment adapters are substantially dormant prior to Rails 6.1
we just need to explain the change in the changelog without the burden
of an overcomplex deprecation cycle.
  • Loading branch information
elia committed Feb 12, 2021
1 parent b0092d0 commit a868fc3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
15 changes: 14 additions & 1 deletion backend/app/views/spree/admin/taxons/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@
</div>
<% end %>

<%= render "spree/admin/taxons/attachment_forms/#{f.object.attachment_partial_name}", f: f %>
<%= f.field_container :icon do %>
<%= f.label :icon %><br>
<%= f.file_field :icon %>
<% if f.object.icon_present? %>
<%= image_tag f.object.icon(:mini) %>
<%= link_to t('spree.actions.remove'),
admin_taxonomy_taxon_attachment_path(@taxonomy,
@taxon.id,
attachment_definition: :icon,
authenticity_token: form_authenticity_token),
method: :delete,
class: 'btn btn-sm btn-danger' %>
<% end %>
<% end %>
</div>

<div class="col-5">
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions core/app/models/spree/taxon/active_storage_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,5 @@ module Spree::Taxon::ActiveStorageAttachment
styles: { mini: '32x32>', normal: '128x128>' },
default_style: :mini
validate :icon_is_an_image


end

def attachment_partial_name
'paperclip'
end
end
4 changes: 0 additions & 4 deletions core/app/models/spree/taxon/paperclip_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ def icon_present?
icon.present?
end

def attachment_partial_name
'paperclip'
end

def destroy_attachment(definition)
return false unless respond_to?(definition)

Expand Down

0 comments on commit a868fc3

Please sign in to comment.