Aurora.Uix.Templates.Basic.Actions.MultiSelect (Aurora UIX v0.1.6-rc.4)

Copy Markdown

Provides helpers for managing multi-value select actions in Aurora UIX form layouts.

This module sets up and modifies actions for the three strips around the checkbox list that represents a multi-value select: beside the label, at the top right, and below the list. It is the scalar counterpart of Aurora.Uix.Templates.Basic.Actions.ManyToMany, which does the same for a many-to-many membership.

Key Features

  • Adds :default_toggle_all, a tri-state checkbox rendered beside the group label: checked when every option is selected, unchecked when none is, and a dash when only some are. Clicking a checked toggle clears the selection; clicking it in either other state selects everything.
  • Registers empty header and footer groups, so a host always has an extension point above and below the checkbox list even though the library ships no default there.
  • Integrates with the Aurora UIX action modification pipeline, so hosts add, insert, replace or remove actions from the layout DSL field options.

Key Constraints

  • Actions render only for layout_type: :form; every component falls back to ~H"" otherwise.
  • The toggle rides the parent form's phx-change="validate" and is identified by _target (see Aurora.Uix.Templates.Basic.Handlers.FormImpl). It must not use phx-click: a click on a checkbox fires click and then change, and the trailing change would re-validate with the pre-click selection and undo the toggle.
  • Its input name is deliberately outside the resource scope, so the toggle never reaches the host's changeset or Ash action as an unknown key. It shares the auix_toggle_all__ prefix with the many-to-many toggle because both are resolved by the same FormImpl clause.
  • Expects the assigns map to include an :auix key with :layout_type, :multi_select_toggle_state and the layout tree options, plus the :field being rendered.

Summary

Functions

Sets up actions for the multi-value select field rendering layout by adding defaults and applying modifications.

Renders the tri-state checkbox that selects or clears every option.

Functions

set_actions(assigns)

@spec set_actions(map()) :: map()

Sets up actions for the multi-value select field rendering layout by adding defaults and applying modifications.

Parameters

  • assigns (map()) - Assigns map containing the layout tree and context.
    • Must include :auix key with required subkeys.

Returns

map() - The updated assigns with actions set.

toggle_all(assigns)

@spec toggle_all(map()) :: Phoenix.LiveView.Rendered.t()

Renders the tri-state checkbox that selects or clears every option.

Checked means every option is selected, unchecked means none is, and the mixed modifier paints a dash for a partial selection. Only :all renders as checked, so clicking from either other state selects everything.

Parameters

  • assigns (map()) - Assigns map containing the select context.
    • Must include :auix (with :layout_type and :multi_select_toggle_state) and :field.

Returns

Phoenix.LiveView.Rendered.t() - Rendered checkbox component.