12398: add destroy action with turbo stream

This commit is contained in:
Ahmed Ejaz
2024-05-23 14:30:28 +05:00
parent e5b9e07874
commit 53fb77eb23
3 changed files with 11 additions and 0 deletions

View File

@@ -31,6 +31,14 @@ module Admin
end
end
# will update this in further commits
def destroy
@product = Spree::Product.find(params[:id])
respond_with do |format|
format.turbo_stream
end
end
def index_url(params)
"/admin/products?#{params.to_query}" # todo: fix routing so this can be automaticly generated
end

View File

@@ -0,0 +1 @@
= turbo_stream.remove dom_id(@product)

View File

@@ -75,6 +75,8 @@ Openfoodnetwork::Application.routes.draw do
# This might be easier to arrange once we rename the controller to plain old "products"
post '/products/bulk_update', to: 'products_v3#bulk_update'
get '/products', to: 'products_v3#index'
# we already have DELETE admin/products/:id here
delete 'products_v3/:id', to: 'products_v3#destroy', as: 'product_destroy'
end
resources :variant_overrides do