From b80a98a88133f4736d501285996271b0dd54d2e9 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Thu, 6 Feb 2025 11:37:55 +0000 Subject: [PATCH] Included published releases count in record details pages --- lib/music_library/records/record.ex | 4 ++++ .../live/collection_live/show.html.heex | 8 +++++++ .../live/wishlist_live/show.html.heex | 8 +++++++ priv/gettext/default.pot | 22 ++++++++++++------- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/music_library/records/record.ex b/lib/music_library/records/record.ex index 5c96edc2..46680eda 100644 --- a/lib/music_library/records/record.ex +++ b/lib/music_library/records/record.ex @@ -70,6 +70,10 @@ defmodule MusicLibrary.Records.Record do Enum.count(record.included_release_group_ids) end + def release_count(record) do + Enum.count(record.release_ids) + end + def add_artists(record, artists_attrs) do record |> change() 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 8fc90323..ca4b684c 100644 --- a/lib/music_library_web/live/collection_live/show.html.heex +++ b/lib/music_library_web/live/collection_live/show.html.heex @@ -204,6 +204,14 @@ {Records.Record.format_as_date(@record.purchased_at)} +
+
+ {gettext("Published releases")} +
+
+ {Records.Record.release_count(@record)} +
+
0} class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0" 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 edf3acea..6a8b0add 100644 --- a/lib/music_library_web/live/wishlist_live/show.html.heex +++ b/lib/music_library_web/live/wishlist_live/show.html.heex @@ -216,6 +216,14 @@
+
+
+ {gettext("Published releases")} +
+
+ {Records.Record.release_count(@record)} +
+
0} class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0" diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index cbba4b74..c4d32ea9 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -101,8 +101,8 @@ msgstr "" msgid "Import" msgstr "" -#: lib/music_library_web/live/collection_live/show.html.heex:224 -#: lib/music_library_web/live/wishlist_live/show.html.heex:236 +#: lib/music_library_web/live/collection_live/show.html.heex:232 +#: lib/music_library_web/live/wishlist_live/show.html.heex:244 #, elixir-autogen, elixir-format msgid "Inserted at" msgstr "" @@ -285,8 +285,8 @@ msgstr "" msgid "Types" msgstr "" -#: lib/music_library_web/live/collection_live/show.html.heex:232 -#: lib/music_library_web/live/wishlist_live/show.html.heex:244 +#: lib/music_library_web/live/collection_live/show.html.heex:240 +#: lib/music_library_web/live/wishlist_live/show.html.heex:252 #, elixir-autogen, elixir-format msgid "Updated at" msgstr "" @@ -326,8 +326,8 @@ msgstr "" msgid "Copy MusicBrainz ID to clipboard" msgstr "" -#: lib/music_library_web/live/collection_live/show.html.heex:243 -#: lib/music_library_web/live/wishlist_live/show.html.heex:255 +#: lib/music_library_web/live/collection_live/show.html.heex:251 +#: lib/music_library_web/live/wishlist_live/show.html.heex:263 #, elixir-autogen, elixir-format msgid "MusicBrainz data" msgstr "" @@ -359,8 +359,8 @@ msgstr "" msgid "Number of included records" msgstr "" -#: lib/music_library_web/live/collection_live/show.html.heex:212 -#: lib/music_library_web/live/wishlist_live/show.html.heex:224 +#: lib/music_library_web/live/collection_live/show.html.heex:220 +#: lib/music_library_web/live/wishlist_live/show.html.heex:232 #, elixir-autogen, elixir-format msgid "Includes" msgstr "" @@ -613,3 +613,9 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Record added to the collection" msgstr "" + +#: lib/music_library_web/live/collection_live/show.html.heex:209 +#: lib/music_library_web/live/wishlist_live/show.html.heex:221 +#, elixir-autogen, elixir-format +msgid "Published releases" +msgstr ""