Consolidate usage of 'artist names' string
This commit is contained in:
@@ -30,6 +30,10 @@ defmodule MusicLibrary.Records.Record do
|
|||||||
timestamps(type: :utc_datetime)
|
timestamps(type: :utc_datetime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def artist_names(record) do
|
||||||
|
Enum.map_join(record.artists, ", ", fn artist -> artist.name end)
|
||||||
|
end
|
||||||
|
|
||||||
def formats, do: @formats
|
def formats, do: @formats
|
||||||
def types, do: @types
|
def types, do: @types
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ defmodule MusicLibraryWeb.FormComponent do
|
|||||||
|
|
||||||
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
import MusicLibraryWeb.RecordComponents, only: [format_label: 1, type_label: 1]
|
||||||
alias MusicLibrary.Records
|
alias MusicLibrary.Records
|
||||||
alias MusicLibrary.Records.Cover
|
alias MusicLibrary.Records.{Cover, Record}
|
||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def mount(socket) do
|
def mount(socket) do
|
||||||
@@ -18,7 +18,7 @@ defmodule MusicLibraryWeb.FormComponent do
|
|||||||
<div>
|
<div>
|
||||||
<header>
|
<header>
|
||||||
<h1 class="text-sm font-medium leading-6 text-zinc-700 dark:text-zinc-400">
|
<h1 class="text-sm font-medium leading-6 text-zinc-700 dark:text-zinc-400">
|
||||||
{Enum.map(@record.artists, & &1.name) |> Enum.join(", ")}
|
{Record.artist_names(@record)}
|
||||||
</h1>
|
</h1>
|
||||||
<h2 class="text-base font-medium leading-6 text-zinc-700 dark:text-zinc-400">
|
<h2 class="text-base font-medium leading-6 text-zinc-700 dark:text-zinc-400">
|
||||||
{@record.title}
|
{@record.title}
|
||||||
|
|||||||
@@ -116,11 +116,9 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def page_title(:show, record) do
|
def page_title(:show, record) do
|
||||||
artist_names = Enum.map(record.artists, & &1.name)
|
|
||||||
|
|
||||||
Enum.join(
|
Enum.join(
|
||||||
[
|
[
|
||||||
Enum.join(artist_names, ", "),
|
Records.Record.artist_names(record),
|
||||||
"-",
|
"-",
|
||||||
record.title,
|
record.title,
|
||||||
"·",
|
"·",
|
||||||
@@ -133,11 +131,9 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def page_title(action, record) do
|
def page_title(action, record) do
|
||||||
artist_names = Enum.map(record.artists, & &1.name)
|
|
||||||
|
|
||||||
Enum.join(
|
Enum.join(
|
||||||
[
|
[
|
||||||
Enum.join(artist_names, ", "),
|
Records.Record.artist_names(record),
|
||||||
"-",
|
"-",
|
||||||
record.title,
|
record.title,
|
||||||
"·",
|
"·",
|
||||||
|
|||||||
@@ -124,11 +124,9 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def page_title(action, record) do
|
def page_title(action, record) do
|
||||||
artist_names = Enum.map(record.artists, & &1.name)
|
|
||||||
|
|
||||||
Enum.join(
|
Enum.join(
|
||||||
[
|
[
|
||||||
Enum.join(artist_names, ", "),
|
Records.Record.artist_names(record),
|
||||||
"-",
|
"-",
|
||||||
record.title,
|
record.title,
|
||||||
"·",
|
"·",
|
||||||
|
|||||||
Reference in New Issue
Block a user