Default
Default
In-browser search
Settings
Aurora.Uix.Templates.Basic.Helpers
(Aurora UIX v0.1.0)
Provides utility functions for LiveView components in Aurora UIX.
Includes functions for managing navigation stacks, assigning values to sockets, handling
entity relationships, and managing section/tab assignment.
Helper Categories Navigation - Routing and navigation stack managementAssign - Assigning values to sockets or assigns mapsEntity - Entity creation and relationship handlingError - Error formatting and processingField - Field configuration retrieval and processingLayout - Layout options assignment and retrievalAction - Action management within assigns mapsPath - Path and URL manipulations
Summary
Adds an action to the specified actions group in the map.
Assigns a value to the auix assigns map in the socket.
Extracts and assigns the current path out of the current url, to the auix map.
Sets the index new link value. Relies on the existence of auix.uri_path key.
Assigns a value to the auix assigns map in the socket only if it does not exist.
Assigns a layout option to the socket's assigns using the LayoutOptions module.
Sets a layout option to the auix entry in the socket's assigns.
Assigns routing stack to the socket. Decodes stack from params or uses default route.
Assigns section configuration to auix assigns map.
Sets a temporary to the auix entry in the socket's assigns.
There is no guarantee that the elements here will remain in the socket.
Sets the global uri path, relies on auix_current_path.
Assigns a new entity to the socket based on related parameters.
Assigns parsed options to the auix assigns map in the socket.
Handles backward navigation by popping the last route from the stack.
Handles forward navigation by updating the routing stack and navigating to the new path.
Extracts association fields from preload configuration grouped by association type.
Flattens a nested structure of elements into a list of paths.
A helper that transforms changeset errors into a map of messages.
Retrieves the configuration for a specific resource from the assigns or auix map.
Retrieves and processes field configuration from the resource configurations.
Retrieves the layout tree for a specific resource and layout type.
Retrieves a specific resource configuration key from the assigns or auix map.
Gets select field options and multiple selection flag.
Inserts an action at the beginning of the specified actions group in the assigns map.
Gets the value of an entity's primary key.
Removes an action by name from the specified actions group in the assigns map.
Replaces an action by name in the specified actions group in the map.
Functions
Adds an action to the specified actions group in the map.
Parameters Returns Phoenix.LiveView.Socket.t() | map() - The updated map with the action added to the group.
Assigns a value to the auix assigns map in the socket.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket key (atom()) - Key for storing in auix map value (term()) - Value to store Returns Phoenix.LiveView.Socket.t()
Extracts and assigns the current path out of the current url, to the auix map.
Parameters Returns Phoenix.LiveView.Socket.t() - Socket with updated auix assigns
Sets the index new link value. Relies on the existence of auix.uri_path key.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket Returns Phoenix.LiveView.Socket.t() - Socket with updated auix assigns
Assigns a value to the auix assigns map in the socket only if it does not exist.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket key (atom()) - Key for storing in auix map value (term()) - Value to store Returns Phoenix.LiveView.Socket.t() - Socket with updated auix assigns
Assigns a layout option to the socket's assigns using the LayoutOptions module.
Retrieves the option value using LayoutOptions.get/2. If the option is not found, assigns the
socket unchanged. Otherwise, stores the value in the :layout_options key within the auix map.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket.option (atom()) - The option key to retrieve and assign.Returns Phoenix.LiveView.Socket.t() - The socket with the option assigned in auix.layout_options.
Sets a layout option to the auix entry in the socket's assigns.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket.option (atom()) - The option key to retrieve and assign.option_value term() - The value to put on the option.Returns Phoenix.LiveView.Socket.t() - Socket with updated auix assigns
Assigns routing stack to the socket. Decodes stack from params or uses default route.
Parameters Returns Phoenix.LiveView.Socket.t() - The socket with updated routing stack.
Examples iex> params = %{ "routing_stack" => encoded_stack }
iex> assign_auix_routing_stack ( socket , params , nil )
#=> %Phoenix.LiveView.Socket{assigns: %{routing_stack: %Stack{...}}}
iex> assign_auix_routing_stack ( socket , %{ } , nil )
#=> %Phoenix.LiveView.Socket{assigns: %{routing_stack: %Stack{}}}
iex> assign_auix_routing_stack ( socket , %{ } , %{ path : "/default" } )
#=> %Phoenix.LiveView.Socket{assigns: %{routing_stack: %Stack{...}}}
Assigns section configuration to auix assigns map.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket sections_id (binary()) - Identifier for the sections group tab_id (binary()) - Identifier for the active tab Returns Phoenix.LiveView.Socket.t() - Socket with updated auix assigns
Sets a temporary to the auix entry in the socket's assigns.
There is no guarantee that the elements here will remain in the socket.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket.key (atom()) - The key to assign.value term() - The value to put on the temp space.Returns Phoenix.LiveView.Socket.t() - Socket with updated auix assigns
Sets the global uri path, relies on auix_current_path.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket Returns Phoenix.LiveView.Socket.t() - Socket with updated auix assigns
Assigns a new entity to the socket based on related parameters.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket params (map()) - Map containing optional related_key and parent_id for relationships default (struct()) - Default entity struct for new records Returns Phoenix.LiveView.Socket.t() - Socket with entity assigned to :auix.entity
Assigns parsed options to the auix assigns map in the socket.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket parsed_opts (map()) - Options to merge with existing auix assigns Returns Phoenix.LiveView.Socket.t()- Socket with updated auix assigns
Handles backward navigation by popping the last route from the stack.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket Returns Phoenix.LiveView.Socket.t()
Handles forward navigation by updating the routing stack and navigating to the new path.
Parameters socket (Phoenix.LiveView.Socket.t()) - The LiveView socket navigation (keyword()) - Navigation options with :navigate or :patch key Returns Phoenix.LiveView.Socket.t()
Flattens a nested structure of elements into a list of paths.
Parameters Returns list() - Flattened list of maps containing tag and name information
Retrieves the configuration for a specific resource from the assigns or auix map.
Parameters assigns_or_auix (map()) - The assigns map or auix map containing configurations resource_name (atom()) - The name of the resource to retrieve configuration for Returns map() - The configuration map for the specified resource, or an empty map if not_found
Retrieves and processes field configuration from the resource configurations.
Parameters:
field: %{name: atom()} - Map containing the field name and options configurations: map - Global configurations for all resources resource_name: atom - The name of the resource the field belongs to Returns:
Field.t() - A Field struct containing the processed field configuration
Retrieves the layout tree for a specific resource and layout type.
Parameters assigns_or_auix (map()) - The assigns ma wp or auix map containing configurations resource_name (atom()) - The name of the resource to retrieve layout for layout_type (atom()) - The type of layout to retrieve (e.g., :form, :index) Returns map() - The layout tree map for the specified resource and layout type,
or an empty map if not found
Retrieves a specific resource configuration key from the assigns or auix map.
Parameters assigns_or_auix (map()) - The assigns map or auix map containing configurations resource_name (atom()) - The name of the resource to retrieve configuration for key (atom()) - The specific key to retrieve from the resource configuration Returns map() - The value for the specified key in the resource configuration,
or an empty map if not found
@spec get_select_options(map ()) :: map ()
Gets select field options and multiple selection flag.
Processes field configuration to generate options for select inputs. Handles
different data sources including related resources and hardcoded options.
Parameters assigns (map()) - Assigns map containing field and configuration dataReturns map() - Map with :options (list of {label, value} tuples) and :multiple (boolean)
Inserts an action at the beginning of the specified actions group in the assigns map.
Parameters Returns Phoenix.LiveView.Socket.t() | map() - The updated map with the action inserted at the beginning of the group.
Gets the value of an entity's primary key.
Parameters Returns term() | list() | nil - Return a single value if the primary key is an atom() or a single element list.
Otherwise returns a list of values, each corresponding to each of the primary key list of fields.
Removes an action by name from the specified actions group in the assigns map.
Parameters Returns Phoenix.LiveView.Socket.t() | map() - The updated assigns map with the action removed from the group.
Replaces an action by name in the specified actions group in the map.
Parameters Returns Phoenix.LiveView.Socket.t() | map() - The updated map with the action replaced.