defmodule BrightWeb.VodHTML do use BrightWeb, :html embed_templates "vod_html/*" @doc """ Renders a vod form. """ attr :changeset, Ecto.Changeset, required: true attr :action, :string, required: true def vod_form(assigns) def stream_opts(changeset) do existing_ids = changeset |> Ecto.Changeset.get_change(:stream, []) |> Enum.map(& &1.data.id) for stream <- Bright.Streams.list_streams(), do: [key: "#{stream.id} | #{stream.date} | #{stream.vtubers |> Enum.map(& &1.display_name) |> Enum.join(", ")}", value: stream.id, selected: stream.id in existing_ids] end end