SelectoComponents.Form.EventHandlers (selecto_components v0.3.10)
Consolidated event handlers for SelectoComponents forms.
This module serves as a single entry point for all form event handlers, organizing them into logical groups based on functionality:
- ViewLifecycle - View configuration, validation, and application
- FilterOperations - Adding, removing, and configuring filters
- DrillDown - Drill-down operations from aggregates and graphs
- ListOperations - List picker operations (add, remove, reorder)
- QueryOperations - Query execution, sorting, and pagination
- ModalOperations - Modal dialog display and interaction
- ExportOperations - Export current results as CSV/JSON
architecture
Architecture
Each event handler group is defined in its own module under
SelectoComponents.Form.EventHandlers.* namespace. This provides:
- Better code organization and maintainability
- Clear separation of concerns
- Easier testing of individual handler groups
- Improved documentation and discoverability
usage
Usage
This module is automatically imported when using SelectoComponents.Form:
defmodule MyLive do
use SelectoComponents.Form
# All event handlers are now available
end
event-handler-groups
Event Handler Groups
viewlifecycle
ViewLifecycle
set_active_tab- Switch between view/filter/save tabsview-validate- Form validation without executionview-apply- Form submission and query executionload_view_config- Load saved view configuration
filteroperations
FilterOperations
treedrop- Add filter via drag-and-dropfilter_remove- Remove filter from list
drilldown
DrillDown
agg_add_filters- Drill down from aggregate viewgraph_drill_down- Drill down from graphchart_click- Drill down from chart element
listoperations
ListOperations
{:list_picker_add, ...}- Add item to list{:list_picker_remove, ...}- Remove item from list{:list_picker_move, ...}- Reorder item in list
queryoperations
QueryOperations
handle_params/3- URL parameter routing{:rerun_query_with_sort, ...}- Sort query results{:update_detail_page, ...}- Pagination{:query_executed, ...}- Handle query completion{:update_view_config, ...}- Update configuration{:filters_updated, ...}- Update filters
### ModalOperations
{:show_detail_modal, ...}- Show detail modal{:close_detail_modal, ...}- Close detail modal
### ExportOperations
export_data- Export current results (CSV/JSON)
adding-new-event-handlers
Adding New Event Handlers
When adding new event handlers:
- Identify the appropriate handler group (or create a new one)
- Add the handler to the corresponding module
- Document the handler with @doc
- Add integration tests
- Update this module's documentation
implementation-notes
Implementation Notes
All event handler modules use the __using__ macro pattern to inject
handlers into the calling LiveView. This allows handlers to access the
LiveView's socket and assigns directly while keeping code organized.
Error handling is provided by SelectoComponents.Form.ErrorHandling,
which wraps operations in try/rescue blocks and provides user-friendly
error messages.