Bootstrap5Components.MovableInputs (bootstrap5components v0.5.1)

View Source

Functions to convert the nested inputs into Ecto changesets.

Summary

Functions

Cast a group of movable inputs into an %Ecto.Changeset{}. This part is necessarily coupled to Ecto, and creates a dependency on Ecto. This is expected, as the frontend must be coupled to the backend somehow.

Functions

cast_movable_assoc(changeset, assoc, opts)

Cast a group of movable inputs into an %Ecto.Changeset{}. This part is necessarily coupled to Ecto, and creates a dependency on Ecto. This is expected, as the frontend must be coupled to the backend somehow.

This function expects the following options:

  • :move_param - the name of the parameter that represents the index of the moved input and the direction of the movement. The value of this parameter must be a map of the form %{"up" => index} or %{"down" => index}.

  • :sort_param - the name of the sort parameter which controls the order of the elements. If we're using this function we aren't actually changing the order, we're only working with a single item that has moved up or down.

  • :moved_param - the name of the field in the ecto schema that contains the new position for the item that has moved.