From 4a8b8dcf431506c22b36844f7c7df9c469b8f181 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Mon, 16 Sep 2024 08:19:18 +0100 Subject: [PATCH] Streamline information structure on records listing --- lib/music_library_web/live/record_live/index.ex | 4 ++++ .../live/record_live/index.html.heex | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/music_library_web/live/record_live/index.ex b/lib/music_library_web/live/record_live/index.ex index 11606ebc..b214b37d 100644 --- a/lib/music_library_web/live/record_live/index.ex +++ b/lib/music_library_web/live/record_live/index.ex @@ -44,4 +44,8 @@ defmodule MusicLibraryWeb.RecordLive.Index do {:noreply, stream_delete(socket, :records, record)} end + + defp musicbrainz_url(record) do + "https://musicbrainz.org/release-group/#{record.musicbrainz_id}" + end end diff --git a/lib/music_library_web/live/record_live/index.html.heex b/lib/music_library_web/live/record_live/index.html.heex index 243ad756..5c97e5d4 100644 --- a/lib/music_library_web/live/record_live/index.html.heex +++ b/lib/music_library_web/live/record_live/index.html.heex @@ -12,17 +12,17 @@ rows={@streams.records} row_click={fn {_id, record} -> JS.navigate(~p"/records/#{record}") end} > - <:col :let={{_id, record}} label="Type"><%= record.type %> - <:col :let={{_id, record}} label="Artists"> - <%= Enum.map(record.artists, fn a -> a.name end) %> - <:col :let={{_id, record}} label="Image"> {record.title} + <:col :let={{_id, record}} label="Artists"> + <%= Enum.map(record.artists, fn a -> a.name end) %> + <:col :let={{_id, record}} label="Title"><%= record.title %> - <:col :let={{_id, record}} label="Musicbrainz"><%= record.musicbrainz_id %> <:col :let={{_id, record}} label="Year"><%= record.year %> - <:col :let={{_id, record}} label="Genres"><%= Enum.join(record.genres || [], ",") %> + <:action :let={{_id, record}}> + <.link href={musicbrainz_url(record)} target=".blank">MB + <:action :let={{_id, record}}>
<.link navigate={~p"/records/#{record}"}>Show