Skip to content

Commit

Permalink
Add DestroyAction to ProductController
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielePalombo committed Jan 22, 2021
1 parent 8828473 commit 542ace5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
5 changes: 5 additions & 0 deletions backend/app/controllers/spree/admin/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ module Admin
class ProductsController < ResourceController
helper 'spree/products'

include Spree::Backend::Batch
set_batch_actions [
{ action: 'Spree::BatchAction::DestroyRecordAction', icon: :trash, label: :delete }
]

before_action :load_data, except: [:index]
update.before :update_before
helper_method :clone_object_url
Expand Down
28 changes: 21 additions & 7 deletions backend/app/views/spree/admin/products/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,29 @@
<%= paginate @collection, theme: "solidus_admin" %>

<% if @collection.any? %>
<table class="index" id="listing_products">
<%=
content_tag(
:table,
class: "index selectable-table actionable",
id: 'listing_products',
data: {
actions: batch_action_buttons(batch_actions),
search_form_selector: 'form.spree\\/product_search',
preview_batch_url: preview_batch_admin_products_path,
# process_batch_url: process_batch_admin_products_path
}
) do %>
<colgroup>
<col style="width: 15%;">
<col style="width: 5%;">
<col style="width: 50%;">
<col style="width: 15%;">
<col style="width: 15%;">
<col>
<col style="width: 15%;">
<col style="width: 5%;">
<col style="width: 50%;">
<col style="width: 15%;">
<col style="width: 15%;">
</colgroup>
<thead>
<tr data-hook="admin_products_index_headers">
<th></th>
<th><%= Spree::Variant.human_attribute_name(:sku) %></th>
<th></th>
<th><%= sort_link @search,:name, Spree::Product.human_attribute_name(:name), { default_order: "desc" }, {title: 'admin_products_listing_name_title'} %></th>
Expand All @@ -73,6 +86,7 @@
<tbody>
<% @collection.each do |product| %>
<tr <%== "style='color: red;'" if product.deleted? %> id="<%= spree_dom_id product %>" data-hook="admin_products_index_rows">
<td><%= check_box_tag 'q[id_in][]', product.id, false, class: 'selectable' %></td>
<td><%= product.sku %></td>
<td class="align-center">
<%= render 'spree/admin/shared/image', image: product.gallery.images.first, size: :mini %>
Expand All @@ -89,7 +103,7 @@
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% else %>
<div class="no-objects-found">
<%= render 'spree/admin/shared/no_objects_found',
Expand Down

0 comments on commit 542ace5

Please sign in to comment.