Aurora. Uix. Templates. Basic. Actions. ManyToMany
(Aurora UIX v0.1.5)
Copy Markdown
Provides helpers for managing many-to-many association actions in Aurora UIX form layouts.
This module sets up and modifies actions for the three strips around the checkbox list that represents a many-to-many membership: beside the label, at the top right, and below the list.
Key Features
- Adds
:default_toggle_all, a tri-state checkbox rendered beside the group label: checked when every candidate is a member, unchecked when none is, and a dash when only some are. Clicking a checked toggle clears the membership; 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(seeAurora.Uix.Templates.Basic.Handlers.FormImpl). It must not usephx-click: a click on a checkbox firesclickand thenchange, and the trailing change would re-validate with the pre-click membership 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.
- Expects the
assignsmap to include an:auixkey with:layout_type,:many_to_many_toggle_stateand the layout tree options, plus the:fieldbeing rendered.
Summary
Functions
Sets up actions for the many-to-many field rendering layout by adding defaults and applying modifications.
Renders the tri-state checkbox that selects or clears the whole candidate list.
Functions
Sets up actions for the many-to-many field rendering layout by adding defaults and applying modifications.
Parameters
assigns(map()) - Assigns map containing the layout tree and context.- Must include
:auixkey with required subkeys.
- Must include
Returns
map() - The updated assigns with actions set.
@spec toggle_all(map()) :: Phoenix.LiveView.Rendered.t()
Renders the tri-state checkbox that selects or clears the whole candidate list.
Checked means every candidate is a member, unchecked means none is, and the mixed modifier
paints a dash for a partial membership. Only :all renders as checked, so clicking from either
other state selects everything.
Parameters
assigns(map()) - Assigns map containing the association context.- Must include
:auix(with:layout_typeand:many_to_many_toggle_state) and:field.
- Must include
Returns
Phoenix.LiveView.Rendered.t() - Rendered checkbox component.