Handles all table events for MishkaGervaz.
This module centralizes event handling for:
- Sorting
- Filtering
- Row actions (delete, edit, custom events)
- Bulk actions
- Row expansion
- Archive status changes
- Pagination, Load more and Load earlier
- Reloading, the error state's Retry (
"reload")
Sub-builders
Events functionality is split into specialized sub-builders:
SanitizationHandler- Input sanitizationRecordHandler- Record CRUD operationsSelectionHandler- Selection state managementBulkActionHandler- Bulk action executionHookRunner- Hook executionRelationFilterHandler- Relation filter search/select events
Customization
You can override individual sub-builders via DSL:
mishka_gervaz do
table do
events do
sanitization MyApp.CustomSanitizationHandler
record MyApp.CustomRecordHandler
selection MyApp.CustomSelectionHandler
bulk_action MyApp.CustomBulkActionHandler
hooks MyApp.CustomHookRunner
relation_filter MyApp.CustomRelationFilterHandler
end
end
endOr override the entire Events module:
mishka_gervaz do
table do
events MyApp.CustomEvents
end
endSee MishkaGervaz.Table.Web.Events.SanitizationHandler,
MishkaGervaz.Table.Web.Events.RecordHandler,
MishkaGervaz.Table.Web.Events.SelectionHandler,
MishkaGervaz.Table.Web.Events.BulkActionHandler,
MishkaGervaz.Table.Web.Events.HookRunner,
MishkaGervaz.Table.Web.Events.RelationFilterHandler,
MishkaGervaz.Table.Web.State,
MishkaGervaz.Table.Web.DataLoader,
MishkaGervaz.Table.Web.Live.
Summary
Callbacks
Main event handler dispatcher.
Functions
Deletes one record, runs the :delete action hooks and the after_delete hook, then drops
the row from the stream and the header count.
Takes the row id out of what the view shows, so the next Load more reads after the rows still
shown.
Main event handler dispatcher.
Runs a failed row action's on_row_action_error hook, then puts the error flash. A hook answering
{:halt, socket} puts no flash.
The label of the row action a failed row event ran, for its error flash, or nil when the action
declares none.
Types
@type socket() :: Phoenix.LiveView.Socket.t()
@type state() :: MishkaGervaz.Table.Web.State.t()
Callbacks
Functions
@spec do_delete( MishkaGervaz.Table.Web.State.t(), map(), Phoenix.LiveView.Socket.t(), map() ) :: {:noreply, Phoenix.LiveView.Socket.t()}
Deletes one record, runs the :delete action hooks and the after_delete hook, then drops
the row from the stream and the header count.
params are the "delete" event's params; their "action" names the row action a failed
delete's flash is labelled with (see row_action_label/3).
Public so a RecordHandler override can defer the destroy itself to the default behaviour
rather than re-implementing the surrounding bookkeeping.
@spec drop_shown_row(MishkaGervaz.Table.Web.State.t(), term(), :self | :realtime) :: MishkaGervaz.Table.Web.State.t()
Takes the row id out of what the view shows, so the next Load more reads after the rows still
shown.
A table with keep_loaded_records true drops it from loaded_records. Any other table moves
next_offset back by one, the offset Load more reads from when its read action has no keyset
pagination; a Load more by keyset reads after the last row's keyset and does not use it. A row
the view removes itself (:self) is held by its id in removed_ids until its own realtime
removal (:realtime) arrives, which then moves nothing, so the row is counted once whether
realtime is on or off.
Main event handler dispatcher.
Called from LiveComponent's handle_event callback.
@spec report_row_error( MishkaGervaz.Table.Web.State.t(), atom(), any(), any(), Phoenix.LiveView.Socket.t() ) :: Phoenix.LiveView.Socket.t()
Runs a failed row action's on_row_action_error hook, then puts the error flash. A hook answering
{:halt, socket} puts no flash.
@spec row_action_label(MishkaGervaz.Table.Web.State.t(), map(), atom()) :: String.t() | nil
The label of the row action a failed row event ran, for its error flash, or nil when the action
declares none.
params are the event's params. The action is the row action of type named by "action", else
the one "event" names, else the first row action of type, dropdown items included.