PhoenixKitWeb.Components.Core.ReorderModal (phoenix_kit v1.7.126)

Copy Markdown View Source

Modal that lets the user pick a sort strategy for a bulk reorder.

Wraps core's <.modal> and renders radio buttons for each strategy the consumer LV passes in. The scope label tells the user up front whether the apply will rewrite "all N rows" or "the M selected rows" so they see the consequence before clicking Apply.

Strategies are domain-specific (projects sort by name, tasks by title, ai endpoints by priority, etc.) so the consumer owns the strategy list — the modal is just shell + radio UI.

Example

<.reorder_modal
  show={@show_reorder}
  on_close="close_reorder"
  on_apply="apply_reorder"
  selected_count={length(@captured_uuids)}
  total_count={length(@projects)}
  strategies={[
    {"name_asc", gettext("A → Z by name")},
    {"name_desc", gettext("Z → A by name")},
    {"created_desc", gettext("Newest first")},
    {"created_asc", gettext("Oldest first")},
    {"reverse", gettext("Reverse current order")}
  ]}
  noun_singular={gettext("project")}
  noun_plural={gettext("projects")}
/>

The Apply button submits the form, which emits on_apply with %{"strategy" => <value>}value is the first element of each {value, label} tuple. required on the radios blocks empty submits at the browser level; the consumer LV should still guard against bad strategy strings server-side (whitelist + fallback clause).

Summary

Functions

reorder_modal(assigns)

Attributes

  • show (:boolean) (required)
  • on_close (:string) (required)
  • on_apply (:string) (required)
  • selected_count (:integer) - Defaults to 0.
  • total_count (:integer) (required)
  • strategies (:list) (required) - List of {value :: String.t(), label :: String.t()} tuples.
  • noun_singular (:string) - Defaults to "item".
  • noun_plural (:string) - Defaults to "items".
  • id (:string) - Defaults to "reorder-modal".