Normalize display of artist names
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
defmodule MusicLibraryWeb.ArtistHelpers do
|
||||||
|
def format_artist_names(artists) do
|
||||||
|
artists
|
||||||
|
|> Enum.map(fn a -> a.name end)
|
||||||
|
|> Enum.join(", ")
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
defmodule MusicLibraryWeb.StatsHTML do
|
defmodule MusicLibraryWeb.StatsHTML do
|
||||||
use MusicLibraryWeb, :html
|
use MusicLibraryWeb, :html
|
||||||
|
|
||||||
|
import MusicLibraryWeb.ArtistHelpers
|
||||||
|
|
||||||
alias MusicLibrary.Records.Record
|
alias MusicLibrary.Records.Record
|
||||||
|
|
||||||
embed_templates "stats_html/*"
|
embed_templates "stats_html/*"
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
<dd class="ml-16 flex items-baseline pb-6 sm:pb-7">
|
<dd class="ml-16 flex items-baseline pb-6 sm:pb-7">
|
||||||
<p class="font-semibold">
|
<p class="font-semibold">
|
||||||
<span class="text-2xl text-gray-900">
|
<span class="text-2xl text-gray-900">
|
||||||
<%= Enum.map(@latest_record.artists, fn a -> a.name end) %>
|
<%= format_artist_names(@latest_record.artists) %>
|
||||||
</span>
|
</span>
|
||||||
<span class="text-gray-600"><%= @latest_record.title %></span>
|
<span class="text-gray-600"><%= @latest_record.title %></span>
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
defmodule MusicLibraryWeb.RecordLive.Index do
|
defmodule MusicLibraryWeb.RecordLive.Index do
|
||||||
use MusicLibraryWeb, :live_view
|
use MusicLibraryWeb, :live_view
|
||||||
import MusicLibraryWeb.Pagination
|
import MusicLibraryWeb.Pagination
|
||||||
|
import MusicLibraryWeb.ArtistHelpers
|
||||||
|
|
||||||
alias MusicLibrary.Records
|
alias MusicLibrary.Records
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</:col>
|
</:col>
|
||||||
<:col :let={{_id, record}}>
|
<:col :let={{_id, record}}>
|
||||||
<p class="text-sm max-sm:text-xs"><%= Enum.map(record.artists, fn a -> a.name end) %></p>
|
<p class="text-sm max-sm:text-xs"><%= format_artist_names(record.artists) %></p>
|
||||||
<p class="text-base font-semibold text-wrap max-sm:text-xs"><%= record.title %></p>
|
<p class="text-base font-semibold text-wrap max-sm:text-xs"><%= record.title %></p>
|
||||||
<p class="text-sm max-sm:text-xs"><%= record.release %></p>
|
<p class="text-sm max-sm:text-xs"><%= record.release %></p>
|
||||||
</:col>
|
</:col>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
defmodule MusicLibraryWeb.RecordLive.Show do
|
defmodule MusicLibraryWeb.RecordLive.Show do
|
||||||
use MusicLibraryWeb, :live_view
|
use MusicLibraryWeb, :live_view
|
||||||
|
import MusicLibraryWeb.ArtistHelpers
|
||||||
|
|
||||||
alias MusicLibrary.Records
|
alias MusicLibrary.Records
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<.header>
|
<.header>
|
||||||
<%= @record.title %>
|
<%= @record.title %>
|
||||||
<:subtitle><%= Enum.map(@record.artists, fn a -> a.name end) %></:subtitle>
|
<:subtitle><%= format_artist_names(@record.artists) %></:subtitle>
|
||||||
<:actions>
|
<:actions>
|
||||||
<.link patch={~p"/records/#{@record}/show/edit"} phx-click={JS.push_focus()}>
|
<.link patch={~p"/records/#{@record}/show/edit"} phx-click={JS.push_focus()}>
|
||||||
<.button>Edit Metadata</.button>
|
<.button>Edit Metadata</.button>
|
||||||
|
|||||||
Reference in New Issue
Block a user