Aurora.Uix.Templates.Basic.Actions (Aurora UIX v0.1.0)

Provides helper functions to manage and modify action groups within Aurora UIX templates.

Adds, modifies, and removes actions from action groups in the assigns map. Supports both removal and modification of individual actions. Integrates with Aurora.Uix.Action and Aurora.Uix.Templates.Basic.Helpers for action creation and manipulation.

Summary

Functions

Adds a list of actions to the specified action group in the assigns map.

Modifies actions in the assigns map based on the provided actions map.

Removes all actions from the specified action groups in the container.

Functions

add_actions(assigns_or_socket, action_group, actions)

@spec add_actions(Phoenix.LiveView.Socket.t() | map(), atom(), [tuple()]) ::
  Phoenix.LiveView.Socket.t() | map()

Adds a list of actions to the specified action group in the assigns map.

Parameters

  • container (Socket.t() | map()) - The assigns map or Socket to update.

  • action_group (atom()) - The target action group (e.g., :main, :secondary).
  • actions (list(map() | struct())) - List of actions to add. Each action must be convertible via Aurora.Uix.Action.new/1.

Returns

(Socket.t() | map()) - The updated container with new actions added to the specified group.

modify_actions(socket, actions)

@spec modify_actions(Phoenix.LiveView.Socket.t() | map(), map()) :: map()

Modifies actions in the assigns map based on the provided actions map.

Iterates over the options in the assigns' layout tree and applies modifications or removals as specified in the actions map.

Parameters

  • assigns (Socket.t() | map()) - Must contain :auix.layout_tree.opts with action definitions.

  • actions (map()) - Map of action names to tuples specifying:
    • {action_group, :remove_auix_action} - Removes the action
    • {action_group, function} - Applies the specified BasicHelpers function

Returns

(Socket.t() | map()) - The updated container after applying all modifications.

remove_all_actions(assigns_or_socket, actions)

@spec remove_all_actions(Phoenix.LiveView.Socket.t() | map(), map()) :: map()

Removes all actions from the specified action groups in the container.

Parameters

  • assigns_or_socket (Socket.t() | map()) - The container to modify (either Socket or assigns map).

  • actions (map()) - Map of actions where each value is a tuple {actiongroup, }.

Returns

Socket.t() | map() - The modified container with all specified actions removed.