diff --git a/lib/music_library_web/live/wishlist_live/index.ex b/lib/music_library_web/live/wishlist_live/index.ex
index 07248318..1134b38d 100644
--- a/lib/music_library_web/live/wishlist_live/index.ex
+++ b/lib/music_library_web/live/wishlist_live/index.ex
@@ -60,7 +60,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|> Map.take([:query, :page, :page_size])
|> URI.encode_query()
- {:noreply, push_patch(socket, to: ~s"/records?#{qs}")}
+ {:noreply, push_patch(socket, to: ~s"/wishlist?#{qs}")}
end
defp merge_query(record_list_params, query) do
diff --git a/lib/music_library_web/live/wishlist_live/index.html.heex b/lib/music_library_web/live/wishlist_live/index.html.heex
index c7d65a1a..c499defc 100644
--- a/lib/music_library_web/live/wishlist_live/index.html.heex
+++ b/lib/music_library_web/live/wishlist_live/index.html.heex
@@ -17,7 +17,7 @@
autocapitalize="none"
/>
- <.link patch={~p"/records/import"}>
+ <.link patch={~p"/wishlist/import"}>
<.button><%= gettext("Import") %>
@@ -35,7 +35,7 @@
-
@@ -50,7 +50,7 @@
<.link
:for={artist <- record.artists}
class="hover:text-zinc-500"
- patch={~p"/records?query=mbid:#{artist.musicbrainz_id}"}
+ patch={~p"/wishlist?query=mbid:#{artist.musicbrainz_id}"}
>
<%= artist.name %>
@@ -120,7 +120,7 @@
role="menuitem"
tabindex="-1"
id={"actions-#{record.id}-show"}
- navigate={~p"/records/#{record}"}
+ navigate={~p"/wishlist/#{record}"}
>
<%= gettext("Show") %>
@@ -140,7 +140,7 @@
role="menuitem"
tabindex="-1"
id={"actions-#{record.id}-edit"}
- patch={~p"/records/#{record}/edit"}
+ patch={~p"/wishlist/#{record}/edit"}
>
<%= gettext("Edit") %>
@@ -161,25 +161,25 @@
-<.modal :if={@live_action == :edit} id="record-modal" show on_cancel={JS.patch(~p"/records")}>
+<.modal :if={@live_action == :edit} id="record-modal" show on_cancel={JS.patch(~p"/wishlist")}>
<.live_component
module={MusicLibraryWeb.RecordLive.FormComponent}
id={@record.id}
title={@page_title}
action={@live_action}
record={@record}
- patch={~p"/records"}
+ patch={~p"/wishlist"}
/>
-<.modal :if={@live_action == :import} id="record-modal" show on_cancel={JS.patch(~p"/records")}>
+<.modal :if={@live_action == :import} id="record-modal" show on_cancel={JS.patch(~p"/wishlist")}>
<.live_component
module={MusicLibraryWeb.RecordLive.ImportComponent}
id={:search}
title={@page_title}
action={@live_action}
record={@record}
- patch={~p"/records"}
+ patch={~p"/wishlist"}
initial_query=""
/>
diff --git a/lib/music_library_web/live/wishlist_live/show.ex b/lib/music_library_web/live/wishlist_live/show.ex
new file mode 100644
index 00000000..c88f27ba
--- /dev/null
+++ b/lib/music_library_web/live/wishlist_live/show.ex
@@ -0,0 +1,55 @@
+defmodule MusicLibraryWeb.WishlistLive.Show do
+ use MusicLibraryWeb, :live_view
+
+ alias MusicLibrary.Records
+
+ @impl true
+ def mount(_params, _session, socket) do
+ back_url =
+ if connected?(socket) do
+ socket
+ |> get_connect_params()
+ |> Map.get("_live_referer", ~p"/records")
+ else
+ ~p"/records"
+ end
+
+ socket =
+ if static_changed?(socket) do
+ put_flash(socket, :warning, gettext("The application has been updated, please reload."))
+ else
+ socket
+ end
+
+ {:ok, assign(socket, :back_url, back_url)}
+ end
+
+ @impl true
+ def handle_params(%{"id" => id}, _, socket) do
+ {:noreply,
+ socket
+ |> assign(:nav_section, :records)
+ |> assign(:page_title, page_title(socket.assigns.live_action))
+ |> assign(:record, Records.get_record!(id))}
+ end
+
+ @impl true
+ def handle_event("delete", %{"id" => id}, socket) do
+ record = Records.get_record!(id)
+ {:ok, _} = Records.delete_record(record)
+
+ {:noreply, push_navigate(socket, to: ~p"/records")}
+ end
+
+ @impl true
+ def handle_info({MusicLibraryWeb.RecordLive.FormComponent, {:saved, record}}, socket) do
+ {:noreply, assign(socket, :record, record)}
+ end
+
+ defp page_title(:show), do: gettext("Show")
+ defp page_title(:edit), do: gettext("Edit")
+
+ defp musicbrainz_url(record) do
+ "https://musicbrainz.org/release-group/#{record.musicbrainz_id}"
+ end
+end
diff --git a/lib/music_library_web/live/wishlist_live/show.html.heex b/lib/music_library_web/live/wishlist_live/show.html.heex
new file mode 100644
index 00000000..2310a9aa
--- /dev/null
+++ b/lib/music_library_web/live/wishlist_live/show.html.heex
@@ -0,0 +1,88 @@
+<.header>
+ <.link
+ :for={artist <- @record.artists}
+ class=" hover:text-gray-500"
+ patch={~p"/wishlist?query=mbid:#{artist.musicbrainz_id}"}
+ >
+ <%= artist.name %>
+
+ <:subtitle>
+ <%= @record.title %>
+
+ <:actions>
+ <.link patch={~p"/wishlist/#{@record}/show/edit"} phx-click={JS.push_focus()}>
+ <.button>
+ <%= gettext("Edit") %>
+
+
+ <.link
+ phx-click={JS.push("delete", value: %{id: @record.id})}
+ data-confirm={gettext("Are you sure?")}
+ >
+ <.button class="!bg-red-900 hover:!bg-red-700">
+ <%= gettext("Delete") %>
+
+
+
+
+
+
+
+

+
+ <%= Records.Record.format_short_label(@record.format) %>
+
+
+
+ <.list>
+ <:item title={gettext("Type")}>
+
+ <%= @record.type %>
+
+
+ <:item title={gettext("Musicbrainz ID")}>
+
+ <%= @record.musicbrainz_id %>
+
+
+ <:item title={gettext("Release")}>
+ <%= Records.Record.format_release(@record.release) %>
+
+ <:item title={gettext("Genres")}>
+
+ <%= genre %>
+
+
+ <:item title={gettext("Inserted at")}><%= @record.inserted_at %>
+ <:item title={gettext("Updated at")}><%= @record.updated_at %>
+
+
+
+
+ <.back navigate={@back_url}>
+ <%= gettext("Back to wishlist") %>
+
+
+
+<.modal
+ :if={@live_action == :edit}
+ id="record-modal"
+ show
+ on_cancel={JS.patch(~p"/wishlist/#{@record}")}
+>
+ <.live_component
+ module={MusicLibraryWeb.RecordLive.FormComponent}
+ id={@record.id}
+ title={@page_title}
+ action={@live_action}
+ record={@record}
+ patch={~p"/wishlist/#{@record}"}
+ />
+
diff --git a/lib/music_library_web/router.ex b/lib/music_library_web/router.ex
index 7c6e7d94..45643015 100644
--- a/lib/music_library_web/router.ex
+++ b/lib/music_library_web/router.ex
@@ -39,6 +39,7 @@ defmodule MusicLibraryWeb.Router do
live "/records/:id/show/edit", RecordLive.Show, :edit
live "/wishlist", WishlistLive.Index, :index
+ live "/wishlist/:id", WishlistLive.Show, :show
end
end