SelectoComponents.Form.ParamsState (selecto_components v0.4.5)
Handles bidirectional conversion between URL parameters and application state for SelectoComponents forms.
This module manages:
- Converting view configuration to URL parameters
- Parsing URL parameters back to view state
- Processing filters and view-specific parameters
- Executing queries with error handling
- Managing URL state updates
Link to this section Summary
Functions
Clears cached query pagination state.
Convert saved view configuration to full params format.
Build view_config from URL params, updating only filter state.
Check if filter structure changed (not just values).
Convert filters back to params format.
Build view_config from a submitted form payload.
Normalize parameter maps for comparison.
Build view_config from URL params, updating full state including view-specific configs.
Restore a saved-view payload into socket state.
Update the URL to include the configured view parameters.
Normalize submitted form params so submit uses the browser form state as truth.
Convert view_config structure to URL parameters format.
Convert full view_config structure to saved-view persistence format.
Process filters from params, extracting and sorting them.
Execute view from URL parameters, handling query execution and error cases.
Version of view_from_params that applies sorting.
Check if view parameters have changed significantly enough to require a view reset.
Check if view-specific parameters changed.
Link to this section Functions
assign_view_config(socket, view_config)
canonicalize_form_params(params)
clear_query_caches(socket)
Clears cached query pagination state.
This is used when a user explicitly re-submits or reloads a view so results are recomputed from fresh execution instead of page-cache reuse.
convert_saved_config_to_full_params(saved_params, view_type)
Convert saved view configuration to full params format.
filter_params_to_state(params, socket)
Build view_config from URL params, updating only filter state.
filter_structure_changed?(params, used_params)
Check if filter structure changed (not just values).
filters_to_params(filters)
Convert filters back to params format.
form_params_to_state(params, socket)
Build view_config from a submitted form payload.
Unlike URL params, the form payload contains inputs for all rendered view tabs, so every view can be reconstructed from the browser state in one pass.
mark_form_state_applied(socket)
normalize_param_map(param_map)
Normalize parameter maps for comparison.
params_to_state(params, socket)
Build view_config from URL params, updating full state including view-specific configs.
saved_params_to_state(saved_params, socket)
Restore a saved-view payload into socket state.
state_to_url(params, socket, opts \\ [])
Update the URL to include the configured view parameters.
submitted_form_params(params)
Normalize submitted form params so submit uses the browser form state as truth.
view_config_to_params(view_config)
Convert view_config structure to URL parameters format.
view_config_to_saved_params(view_config)
Convert full view_config structure to saved-view persistence format.
view_filter_process(params, item_name)
Process filters from params, extracting and sorting them.
view_from_params(params, socket)
Execute view from URL parameters, handling query execution and error cases.
This is the core function that:
- Parses URL parameters into a view configuration
- Applies filters to the Selecto structure
- Executes the query
- Handles errors gracefully
- Updates socket state with results or errors
view_from_params_with_sort(params, socket, sort_by)
Version of view_from_params that applies sorting.
view_params_changed?(params, socket)
Check if view parameters have changed significantly enough to require a view reset.
view_specific_params_changed?(params, used_params, param_key)
Check if view-specific parameters changed.