Use labels for selects in record edit form
This commit is contained in:
@@ -203,6 +203,15 @@ defmodule MusicLibrary.Records.Record do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def formats, do: @formats
|
def formats, do: @formats
|
||||||
|
def types, do: @types
|
||||||
|
|
||||||
|
def formats_with_labels do
|
||||||
|
Enum.map(@formats, fn f -> {format_long_label(f), f} end)
|
||||||
|
end
|
||||||
|
|
||||||
|
def types_with_labels do
|
||||||
|
Enum.map(@types, fn t -> {type_long_label(t), t} end)
|
||||||
|
end
|
||||||
|
|
||||||
def format_long_label(:cd), do: "CD"
|
def format_long_label(:cd), do: "CD"
|
||||||
def format_long_label(:backup), do: "Backup"
|
def format_long_label(:backup), do: "Backup"
|
||||||
|
|||||||
@@ -34,14 +34,14 @@ defmodule MusicLibraryWeb.RecordLive.FormComponent do
|
|||||||
type="select"
|
type="select"
|
||||||
label={gettext("Type")}
|
label={gettext("Type")}
|
||||||
prompt={gettext("Choose a value")}
|
prompt={gettext("Choose a value")}
|
||||||
options={Ecto.Enum.values(MusicLibrary.Records.Record, :type)}
|
options={Records.Record.types_with_labels()}
|
||||||
/>
|
/>
|
||||||
<.input
|
<.input
|
||||||
field={@form[:format]}
|
field={@form[:format]}
|
||||||
type="select"
|
type="select"
|
||||||
label={gettext("Format")}
|
label={gettext("Format")}
|
||||||
prompt={gettext("Choose a value")}
|
prompt={gettext("Choose a value")}
|
||||||
options={Ecto.Enum.values(MusicLibrary.Records.Record, :format)}
|
options={Records.Record.formats_with_labels()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<.input field={@form[:musicbrainz_id]} type="text" label={gettext("MusicBrainz ID")} />
|
<.input field={@form[:musicbrainz_id]} type="text" label={gettext("MusicBrainz ID")} />
|
||||||
|
|||||||
Reference in New Issue
Block a user