PhoenixKitStaff.Web.SkillFormLive (PhoenixKitStaff v0.6.0)

Copy Markdown View Source

Create or edit a skill, including its level selectors.

A skill owns zero or more named selectors (level groups); each selector has a translatable name, its own allow_multiple toggle, and an ordered list of translatable options. The whole selector tree is staged in @staged_groups (the source of truth) and rendered inside #skill-form but outside <.multilang_fields_wrapper>, so it survives language switches (the wrapper re-mounts its subtree on switch).

Each selector/option name input is keyed on @current_lang in its DOM id, so morphdom replaces it on a language switch and the value refreshes to the active language; validate merges only the active language's typed names back into the staged tree. Structural edits (add / remove / reorder selectors and options) are event-driven so a reconnect can't strand them, and reordering uses the core <.draggable_list> drag-and-drop (handle = .pk-drag-handle). On save the staged tree is injected as attrs["levels"] and normalised by Skill.changeset/2.