MishkaGervaz.Table.Web.Events.BulkActionHandler behaviour
(MishkaGervaz v0.0.1-alpha.2)
Copy Markdown
View Source
Handles bulk action execution for Events module.
This module provides functions for executing bulk actions on selected records, including building queries and running Ash bulk operations.
Customization
You can create a custom BulkActionHandler:
defmodule MyApp.CustomBulkActionHandler do
use MishkaGervaz.Table.Web.Events.BulkActionHandler
# Custom bulk action with additional logging
def execute_ash_bulk_action(action, ash_action, selected_ids, state, socket) do
MyApp.Logger.info("Executing bulk action", action: ash_action, count: length(selected_ids))
super(action, ash_action, selected_ids, state, socket)
end
endThen configure it in your resource's DSL:
mishka_gervaz do
table do
events do
bulk_action MyApp.CustomBulkActionHandler
end
end
endSee MishkaGervaz.Table.Web.Events,
MishkaGervaz.Table.Entities.BulkAction,
MishkaGervaz.Table.Web.DataLoader,
and the sibling handlers SanitizationHandler, RecordHandler,
SelectionHandler, HookRunner, RelationFilterHandler.
Summary
Callbacks
Builds a query for bulk operations.
Executes a bulk action based on its handler type.
Executes an Ash bulk action.
Types
@type bulk_action() :: map()
@type socket() :: Phoenix.LiveView.Socket.t()
@type state() :: MishkaGervaz.Table.Web.State.t()
Callbacks
@callback build_bulk_query( resource :: module(), state :: state(), filter :: {:exclude, list()} | nil ) :: Ash.Query.t()
Builds a query for bulk operations.
Applies any necessary filters based on the selection.
@callback execute( bulk_action :: bulk_action() | nil, selected_ids :: selected_ids(), state :: state(), socket :: socket() ) :: {:noreply, socket()}
Executes a bulk action based on its handler type.
Dispatches to the appropriate handler: :parent, function, or Ash action.
@callback execute_ash_bulk_action( action :: bulk_action(), ash_action :: atom(), selected_ids :: selected_ids(), state :: state(), socket :: socket() ) :: {:noreply, socket()}
Executes an Ash bulk action.
Handles both bulk_update and bulk_destroy based on action type.