Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: bulk destroy #3211

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions app/components/avo/resource_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,33 @@ def render_delete_button(control)
end
end

def render_bulk_delete_button(control)
# # If the resource is a related resource, we use the can_delete? policy method because it uses
# # authorize_association_for(:destroy).
# # Otherwise we use the can_see_the_destroy_button? policy method becuse it do no check for assiciation
# # only for authorize_action .
# policy_method = is_a_related_resource? ? :can_delete? : :can_see_the_destroy_button?
# return unless send policy_method

a_link helpers.resources_destroy_path,
style: :text,
color: :red,
icon: "avo/trash",
form_class: "flex flex-col sm:flex-row sm:inline-flex",
title: control.title,
aria_label: control.title,
data: {
turbo_confirm: t("avo.are_you_sure", item: @resource.record.model_name.name.downcase),
turbo_method: :delete,
target: "control:destroy",
control: :destroy,
tippy: control.title ? :tooltip : nil,
"resource-id": @resource.record_param,
} do
control.label
end
end

def render_save_button(control)
return unless can_see_the_save_button?

Expand Down
4 changes: 4 additions & 0 deletions lib/avo/dynamic_router.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ def self.routes
member do
get :preview
end

collection do
delete :bulk_destroy
end
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions lib/avo/resources/controls/bulk_delete_button.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Avo
module Resources
module Controls
class BulkDeleteButton < DeleteButton
end
end
end
end
Loading