diff --git a/backend/app/views/spree/admin/taxons/_form.html.erb b/backend/app/views/spree/admin/taxons/_form.html.erb index 6c93d998402..5b720beaa2d 100644 --- a/backend/app/views/spree/admin/taxons/_form.html.erb +++ b/backend/app/views/spree/admin/taxons/_form.html.erb @@ -20,11 +20,7 @@ <% end %> - <%= f.field_container :icon do %> - <%= f.label :icon %>
- <%= f.file_field :icon %> - <%= image_tag f.object.icon(:mini) if f.object.icon_present? %> - <% end %> + <%= render "spree/admin/taxons/attachment_forms/#{f.object.attachment_partial_name}", f: f %>
diff --git a/backend/app/views/spree/admin/taxons/attachment_forms/_paperclip.html.erb b/backend/app/views/spree/admin/taxons/attachment_forms/_paperclip.html.erb new file mode 100644 index 00000000000..939dcbf02e6 --- /dev/null +++ b/backend/app/views/spree/admin/taxons/attachment_forms/_paperclip.html.erb @@ -0,0 +1,7 @@ +<% f.object.class.attachment_definitions.each do |attachment, definition| %> + <%= f.field_container attachment do %> + <%= f.label attachment %>
+ <%= f.file_field attachment %> + <%= image_tag f.object.send(attachment, definition[:default_style]) if f.object.send(attachment).present? %> + <% end %> +<% end %> diff --git a/core/app/models/spree/taxon/paperclip_attachment.rb b/core/app/models/spree/taxon/paperclip_attachment.rb index cb4a83437cc..b688e5f8fd3 100644 --- a/core/app/models/spree/taxon/paperclip_attachment.rb +++ b/core/app/models/spree/taxon/paperclip_attachment.rb @@ -18,4 +18,8 @@ module Spree::Taxon::PaperclipAttachment def icon_present? icon.present? end + + def attachment_partial_name + 'paperclip' + end end