Skip to content

Commit a1a4449

Browse files
Add DestroyAction to ProductController
1 parent 8828473 commit a1a4449

2 files changed

Lines changed: 26 additions & 7 deletions

File tree

backend/app/controllers/spree/admin/products_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ module Admin
55
class ProductsController < ResourceController
66
helper 'spree/products'
77

8+
include Spree::Backend::Batch
9+
set_batch_actions [
10+
{ action: 'Spree::BatchAction::DestroyRecordAction', icon: :trash, label: :delete }
11+
]
12+
813
before_action :load_data, except: [:index]
914
update.before :update_before
1015
helper_method :clone_object_url

backend/app/views/spree/admin/products/index.html.erb

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,29 @@
5353
<%= paginate @collection, theme: "solidus_admin" %>
5454

5555
<% if @collection.any? %>
56-
<table class="index" id="listing_products">
56+
<%=
57+
content_tag(
58+
:table,
59+
class: "index selectable-table actionable",
60+
id: 'listing_products',
61+
data: {
62+
actions: batch_action_buttons(batch_actions),
63+
search_form_selector: 'form.spree\\/product_search',
64+
preview_batch_url: preview_batch_admin_products_path,
65+
process_batch_url: process_batch_admin_products_path
66+
}
67+
) do %>
5768
<colgroup>
58-
<col style="width: 15%;">
59-
<col style="width: 5%;">
60-
<col style="width: 50%;">
61-
<col style="width: 15%;">
62-
<col style="width: 15%;">
69+
<col>
70+
<col style="width: 15%;">
71+
<col style="width: 5%;">
72+
<col style="width: 50%;">
73+
<col style="width: 15%;">
74+
<col style="width: 15%;">
6375
</colgroup>
6476
<thead>
6577
<tr data-hook="admin_products_index_headers">
78+
<th></th>
6679
<th><%= Spree::Variant.human_attribute_name(:sku) %></th>
6780
<th></th>
6881
<th><%= sort_link @search,:name, Spree::Product.human_attribute_name(:name), { default_order: "desc" }, {title: 'admin_products_listing_name_title'} %></th>
@@ -73,6 +86,7 @@
7386
<tbody>
7487
<% @collection.each do |product| %>
7588
<tr <%== "style='color: red;'" if product.deleted? %> id="<%= spree_dom_id product %>" data-hook="admin_products_index_rows">
89+
<td><%= check_box_tag 'q[id_in][]', product.id, false, class: 'selectable' %></td>
7690
<td><%= product.sku %></td>
7791
<td class="align-center">
7892
<%= render 'spree/admin/shared/image', image: product.gallery.images.first, size: :mini %>
@@ -89,7 +103,7 @@
89103
</tr>
90104
<% end %>
91105
</tbody>
92-
</table>
106+
<% end %>
93107
<% else %>
94108
<div class="no-objects-found">
95109
<%= render 'spree/admin/shared/no_objects_found',

0 commit comments

Comments
 (0)