Added new media_profile options to creation form; made show helper for rendering database items
This commit is contained in:
parent
d60f2d1422
commit
44bdf6a708
4 changed files with 54 additions and 10 deletions
|
|
@ -546,6 +546,30 @@ defmodule PinchflatWeb.CoreComponents do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Renders a data list from a given map. Used in development to
|
||||||
|
quickly show the attributes of a database record.
|
||||||
|
"""
|
||||||
|
attr :map, :map, required: true
|
||||||
|
|
||||||
|
def list_items_from_map(assigns) do
|
||||||
|
attrs =
|
||||||
|
Enum.filter(assigns.map, fn
|
||||||
|
{_, %{__struct__: _}} -> false
|
||||||
|
_ -> true
|
||||||
|
end)
|
||||||
|
|
||||||
|
assigns = assign(assigns, iterable_attributes: attrs)
|
||||||
|
|
||||||
|
~H"""
|
||||||
|
<.list>
|
||||||
|
<:item :for={{k, v} <- @iterable_attributes} title={k}>
|
||||||
|
<%= v %>
|
||||||
|
</:item>
|
||||||
|
</.list>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Renders a back navigation link.
|
Renders a back navigation link.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,12 @@ defmodule PinchflatWeb.MediaProfiles.MediaProfileHTML do
|
||||||
attr :action, :string, required: true
|
attr :action, :string, required: true
|
||||||
|
|
||||||
def media_profile_form(assigns)
|
def media_profile_form(assigns)
|
||||||
|
|
||||||
|
def friendly_format_type_options do
|
||||||
|
[
|
||||||
|
{"Include (default)", :include},
|
||||||
|
{"Exclude", :exclude},
|
||||||
|
{"Only", :only}
|
||||||
|
]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,31 @@
|
||||||
</.error>
|
</.error>
|
||||||
<.input field={f[:name]} type="text" label="Name" />
|
<.input field={f[:name]} type="text" label="Name" />
|
||||||
<.input field={f[:output_path_template]} type="text" label="Output path template" />
|
<.input field={f[:output_path_template]} type="text" label="Output path template" />
|
||||||
|
|
||||||
|
<h3>Subtitle Options</h3>
|
||||||
<.input field={f[:download_subs]} type="checkbox" label="Download Subs" />
|
<.input field={f[:download_subs]} type="checkbox" label="Download Subs" />
|
||||||
<.input field={f[:download_auto_subs]} type="checkbox" label="Download Autogenerated Subs" />
|
<.input field={f[:download_auto_subs]} type="checkbox" label="Download Autogenerated Subs" />
|
||||||
<.input field={f[:embed_subs]} type="checkbox" label="Embed Subs" />
|
<.input field={f[:embed_subs]} type="checkbox" label="Embed Subs" />
|
||||||
<.input field={f[:sub_langs]} type="text" label="Sub Langs" />
|
<.input field={f[:sub_langs]} type="text" label="Sub Langs" />
|
||||||
|
|
||||||
|
<h3>Thumbnail Options</h3>
|
||||||
|
<.input field={f[:download_thumbnail]} type="checkbox" label="Download Thumbnail" />
|
||||||
|
<.input field={f[:embed_thumbnail]} type="checkbox" label="Embed Thumbnail" />
|
||||||
|
|
||||||
|
<h3>Release Format Options</h3>
|
||||||
|
<.input
|
||||||
|
field={f[:shorts_behaviour]}
|
||||||
|
options={friendly_format_type_options()}
|
||||||
|
type="select"
|
||||||
|
label="Include Shorts?"
|
||||||
|
/>
|
||||||
|
<.input
|
||||||
|
field={f[:livestream_behaviour]}
|
||||||
|
options={friendly_format_type_options()}
|
||||||
|
type="select"
|
||||||
|
label="Include Livestreams?"
|
||||||
|
/>
|
||||||
|
|
||||||
<:actions>
|
<:actions>
|
||||||
<.button>Save Media profile</.button>
|
<.button>Save Media profile</.button>
|
||||||
</:actions>
|
</:actions>
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,6 @@
|
||||||
</:actions>
|
</:actions>
|
||||||
</.header>
|
</.header>
|
||||||
|
|
||||||
<.list>
|
<.list_items_from_map map={Map.from_struct(@media_profile)} />
|
||||||
<:item
|
|
||||||
:for={
|
|
||||||
attr <- ~w(name output_path_template download_subs download_auto_subs embed_subs sub_langs)a
|
|
||||||
}
|
|
||||||
title={attr}
|
|
||||||
>
|
|
||||||
<%= Map.get(@media_profile, attr) %>
|
|
||||||
</:item>
|
|
||||||
</.list>
|
|
||||||
|
|
||||||
<.back navigate={~p"/media_profiles"}>Back to media_profiles</.back>
|
<.back navigate={~p"/media_profiles"}>Back to media_profiles</.back>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue