diff --git a/lib/music_library/record_sets.ex b/lib/music_library/record_sets.ex
index 5eda129d..606c944f 100644
--- a/lib/music_library/record_sets.ex
+++ b/lib/music_library/record_sets.ex
@@ -167,6 +167,17 @@ defmodule MusicLibrary.RecordSets do
{:ok, get_record_set!(record_set.id)}
end
+ def list_record_sets_for_record(record_id) do
+ from(rs in RecordSet,
+ join: i in RecordSetItem,
+ on: i.record_set_id == rs.id,
+ where: i.record_id == ^record_id,
+ order_by: [asc: rs.name],
+ preload: [items: :record]
+ )
+ |> Repo.all()
+ end
+
defp record_sets_search_query(""), do: from(rs in RecordSet)
defp record_sets_search_query(query) do
diff --git a/lib/music_library_web/live/collection_live/show.ex b/lib/music_library_web/live/collection_live/show.ex
index 69f3c2bc..a7f6e9f9 100644
--- a/lib/music_library_web/live/collection_live/show.ex
+++ b/lib/music_library_web/live/collection_live/show.ex
@@ -15,8 +15,9 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
similar_records: 1
]
- alias MusicLibrary.{Records, ScrobbleActivity}
+ alias MusicLibrary.{Records, RecordSets, ScrobbleActivity}
alias MusicLibrary.Records.Similarity
+ alias MusicLibrary.RecordSets.RecordSet
alias Phoenix.LiveView.JS
@impl true
@@ -45,12 +46,15 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
socket
end
+ record_sets = RecordSets.list_record_sets_for_record(record.id)
+
{:noreply,
socket
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|> assign(:record, record)
|> assign(:last_listened_track, last_listened_track)
|> assign(:play_count, play_count)
+ |> assign(:record_sets, record_sets)
|> assign_embedding_text()
|> assign_similar_records()}
end
diff --git a/lib/music_library_web/live/collection_live/show.html.heex b/lib/music_library_web/live/collection_live/show.html.heex
index 437fbc8c..8020d30d 100644
--- a/lib/music_library_web/live/collection_live/show.html.heex
+++ b/lib/music_library_web/live/collection_live/show.html.heex
@@ -263,6 +263,24 @@
+ <.dl_row :if={@record_sets != []} label={gettext("Record sets")}>
+
+ -
+ <.link
+ navigate={~p"/record-sets/#{record_set}"}
+ class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300 hover:underline"
+ >
+ {record_set.name}
+
+
+ {gettext(
+ "%{collected}/%{total} collected",
+ RecordSet.count_by_status(record_set)
+ )}
+
+
+
+
<.dl_row label={gettext("Inserted at")}>
{Records.Record.format_as_date(@record.inserted_at)}
diff --git a/lib/music_library_web/live/wishlist_live/show.ex b/lib/music_library_web/live/wishlist_live/show.ex
index a820a657..6158ffe8 100644
--- a/lib/music_library_web/live/wishlist_live/show.ex
+++ b/lib/music_library_web/live/wishlist_live/show.ex
@@ -13,7 +13,8 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
]
alias MusicLibrary.OnlineStoreTemplates
- alias MusicLibrary.Records
+ alias MusicLibrary.{Records, RecordSets}
+ alias MusicLibrary.RecordSets.RecordSet
@impl true
def mount(%{"id" => record_id}, _session, socket) do
@@ -34,11 +35,14 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
record = Records.get_record!(id)
online_store_templates = OnlineStoreTemplates.list_enabled_templates()
+ record_sets = RecordSets.list_record_sets_for_record(record.id)
+
{:noreply,
socket
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|> assign(:record, record)
- |> assign(:online_store_templates, online_store_templates)}
+ |> assign(:online_store_templates, online_store_templates)
+ |> assign(:record_sets, record_sets)}
end
@impl true
diff --git a/lib/music_library_web/live/wishlist_live/show.html.heex b/lib/music_library_web/live/wishlist_live/show.html.heex
index b8c11507..dd7fa0a3 100644
--- a/lib/music_library_web/live/wishlist_live/show.html.heex
+++ b/lib/music_library_web/live/wishlist_live/show.html.heex
@@ -224,6 +224,24 @@
+ <.dl_row :if={@record_sets != []} label={gettext("Record sets")}>
+
+ -
+ <.link
+ navigate={~p"/record-sets/#{record_set}"}
+ class="text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300 hover:underline"
+ >
+ {record_set.name}
+
+
+ {gettext(
+ "%{collected}/%{total} collected",
+ RecordSet.count_by_status(record_set)
+ )}
+
+
+
+
<.dl_row label={gettext("Inserted at")}>
{Records.Record.format_as_date(@record.inserted_at)}
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot
index 1ab7af81..cb604d49 100644
--- a/priv/gettext/default.pot
+++ b/priv/gettext/default.pot
@@ -1946,3 +1946,15 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Try a different search term or check the spelling"
msgstr ""
+
+#: lib/music_library_web/live/collection_live/show.html.heex
+#: lib/music_library_web/live/wishlist_live/show.html.heex
+#, elixir-autogen, elixir-format
+msgid "%{collected}/%{total} collected"
+msgstr ""
+
+#: lib/music_library_web/live/collection_live/show.html.heex
+#: lib/music_library_web/live/wishlist_live/show.html.heex
+#, elixir-autogen, elixir-format
+msgid "Record sets"
+msgstr ""
diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po
index bbcaa896..a46cf1c6 100644
--- a/priv/gettext/en/LC_MESSAGES/default.po
+++ b/priv/gettext/en/LC_MESSAGES/default.po
@@ -1946,3 +1946,15 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Try a different search term or check the spelling"
msgstr ""
+
+#: lib/music_library_web/live/collection_live/show.html.heex
+#: lib/music_library_web/live/wishlist_live/show.html.heex
+#, elixir-autogen, elixir-format, fuzzy
+msgid "%{collected}/%{total} collected"
+msgstr ""
+
+#: lib/music_library_web/live/collection_live/show.html.heex
+#: lib/music_library_web/live/wishlist_live/show.html.heex
+#, elixir-autogen, elixir-format, fuzzy
+msgid "Record sets"
+msgstr ""