Skip to content

Commit 806d939

Browse files
committed
Override #destroy action on stores controller
Store deletion can be aborted if we are deleting a default store, so we'll show alert in that case.
1 parent 44508e2 commit 806d939

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

admin/app/controllers/solidus_admin/stores_controller.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
module SolidusAdmin
44
class StoresController < SolidusAdmin::ResourcesController
5+
def destroy
6+
@resource = resource_class.where(id: params[:id])
7+
8+
failed = @resource.destroy_all.reject(&:destroyed?)
9+
if failed.present?
10+
desc = failed.map { t(".error.description", name: _1.name, reason: _1.errors.full_messages.join(" ")) }.join("<br>")
11+
flash[:danger] = { title: t(".error.title"), description: desc }
12+
else
13+
flash[:notice] = t('.success')
14+
end
15+
16+
redirect_to after_destroy_path, status: :see_other
17+
end
18+
519
private
620

721
def resource_class = Spree::Store

0 commit comments

Comments
 (0)