fp/services/bright/lib/bright_web/controllers/stream_html.ex

59 lines
1.4 KiB
Elixir
Raw Normal View History

2025-01-03 14:45:35 +00:00
defmodule BrightWeb.StreamHTML do
use BrightWeb, :html
embed_templates "stream_html/*"
@doc """
Renders a stream form.
"""
attr :changeset, Ecto.Changeset, required: true
attr :action, :string, required: true
def stream_form(assigns)
def tag_opts(changeset) do
existing_ids =
changeset
|> Ecto.Changeset.get_change(:tags, [])
|> Enum.map(& &1.data.id)
for tag <- Bright.Tags.list_tags(),
do: [key: tag.name, value: tag.id, selected: tag.id in existing_ids]
end
def vod_opts(changeset) do
existing_ids =
changeset
|> Ecto.Changeset.get_change(:vods, [])
|> Enum.map(& &1.data.id)
for vod <- Bright.Streams.list_vods(),
do: [key: vod.id, value: vod.id, selected: vod.id in existing_ids]
end
def vtuber_opts(changeset) do
existing_ids =
changeset
|> Ecto.Changeset.get_change(:vtubers, [])
|> Enum.map(& &1.data.id)
for vtuber <- Bright.Vtubers.list_vtubers(),
do: [key: vtuber.display_name, value: vtuber.id, selected: vtuber.id in existing_ids]
end
def platform_opts(changeset) do
existing_ids =
changeset
|> Ecto.Changeset.get_change(:vtubers, [])
|> Enum.map(& &1.data.id)
for platform <- Bright.Platforms.list_platforms(),
do: [key: platform.name, value: platform.id, selected: platform.id in existing_ids]
end
end