From 8bd7197d18f9feb58459aa66ddae044d1b77753b Mon Sep 17 00:00:00 2001
From: Claudio Ortolina
Date: Wed, 1 Jan 2025 16:45:43 +0000
Subject: [PATCH] Show purchase date in collection view
---
lib/music_library/records/record.ex | 4 ++++
.../components/record_components.ex | 20 +++++++++++++++++++
priv/gettext/default.pot | 20 ++++++++++---------
.../live/collection_live/index_test.exs | 1 +
4 files changed, 36 insertions(+), 9 deletions(-)
diff --git a/lib/music_library/records/record.ex b/lib/music_library/records/record.ex
index 4dfa4fc0..5f1f052c 100644
--- a/lib/music_library/records/record.ex
+++ b/lib/music_library/records/record.ex
@@ -228,6 +228,10 @@ defmodule MusicLibrary.Records.Record do
end
end
+ def format_purchased_at(purchased_at) do
+ "#{purchased_at.day}/#{purchased_at.month}/#{purchased_at.year}"
+ end
+
defp parse_subtype("Album"), do: :album
defp parse_subtype("EP"), do: :ep
defp parse_subtype("Live"), do: :live
diff --git a/lib/music_library_web/components/record_components.ex b/lib/music_library_web/components/record_components.ex
index cd85aca5..29ab559c 100644
--- a/lib/music_library_web/components/record_components.ex
+++ b/lib/music_library_web/components/record_components.ex
@@ -63,6 +63,19 @@ defmodule MusicLibraryWeb.RecordComponents do
{Records.Record.child_release_groups_count(record)}
+
+ ยท
+
+ {gettext("Purchased on")}
+
+ <.icon
+ name="hero-banknotes"
+ class="-mt-1 h-4 w-4"
+ aria-hidden="true"
+ data-slot="icon"
+ />
+ {Records.Record.format_purchased_at(record.purchased_at)}
+
@@ -90,6 +103,13 @@ defmodule MusicLibraryWeb.RecordComponents do
+
+
+ {gettext("Purchased on")}
+
+ <.icon name="hero-banknotes" class="-mt-1 h-4 w-4" aria-hidden="true" data-slot="icon" />
+ {Records.Record.format_purchased_at(record.purchased_at)}
+
<%!-- TODO: replace with OSS version --%>
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot
index b717d383..5b26d0ed 100644
--- a/priv/gettext/default.pot
+++ b/priv/gettext/default.pot
@@ -16,7 +16,7 @@ msgstr ""
msgid "Actions"
msgstr ""
-#: lib/music_library_web/components/record_components.ex:179
+#: lib/music_library_web/components/record_components.ex:199
#: lib/music_library_web/live/collection_live/show.html.heex:127
#: lib/music_library_web/live/wishlist_live/show.html.heex:144
#, elixir-autogen, elixir-format
@@ -43,14 +43,14 @@ msgstr ""
msgid "Cover art"
msgstr ""
-#: lib/music_library_web/components/record_components.ex:181
+#: lib/music_library_web/components/record_components.ex:201
#: lib/music_library_web/live/collection_live/show.html.heex:135
#: lib/music_library_web/live/wishlist_live/show.html.heex:152
#, elixir-autogen, elixir-format
msgid "Delete"
msgstr ""
-#: lib/music_library_web/components/record_components.ex:159
+#: lib/music_library_web/components/record_components.ex:179
#: lib/music_library_web/live/collection_live/show.ex:139
#: lib/music_library_web/live/collection_live/show.html.heex:70
#: lib/music_library_web/live/wishlist_live/show.ex:136
@@ -151,7 +151,7 @@ msgstr ""
msgid "No results"
msgstr ""
-#: lib/music_library_web/components/record_components.ex:104
+#: lib/music_library_web/components/record_components.ex:124
#: lib/music_library_web/live/collection_live/show.html.heex:38
#: lib/music_library_web/live/wishlist_live/show.html.heex:38
#, elixir-autogen, elixir-format
@@ -169,7 +169,7 @@ msgstr ""
msgid "Previous"
msgstr ""
-#: lib/music_library_web/components/record_components.ex:170
+#: lib/music_library_web/components/record_components.ex:190
#: lib/music_library_web/live/collection_live/index.html.heex:42
#: lib/music_library_web/live/wishlist_live/show.html.heex:135
#, elixir-autogen, elixir-format
@@ -181,6 +181,8 @@ msgstr ""
msgid "Purchased at"
msgstr ""
+#: lib/music_library_web/components/record_components.ex:69
+#: lib/music_library_web/components/record_components.ex:108
#: lib/music_library_web/live/collection_live/show.html.heex:181
#, elixir-autogen, elixir-format
msgid "Purchased on"
@@ -215,7 +217,7 @@ msgstr ""
msgid "Saving..."
msgstr ""
-#: lib/music_library_web/components/record_components.ex:201
+#: lib/music_library_web/components/record_components.ex:221
#, elixir-autogen, elixir-format
msgid "Search"
msgstr ""
@@ -230,7 +232,7 @@ msgstr ""
msgid "Search for records"
msgstr ""
-#: lib/music_library_web/components/record_components.ex:139
+#: lib/music_library_web/components/record_components.ex:159
#: lib/music_library_web/live/collection_live/show.ex:138
#: lib/music_library_web/live/wishlist_live/show.ex:135
#, elixir-autogen, elixir-format
@@ -293,7 +295,7 @@ msgstr ""
msgid "Updated at"
msgstr ""
-#: lib/music_library_web/components/record_components.ex:149
+#: lib/music_library_web/components/record_components.ex:169
#, elixir-autogen, elixir-format
msgid "View on MusicBrainz"
msgstr ""
@@ -356,7 +358,7 @@ msgid "Wishlisted"
msgstr ""
#: lib/music_library_web/components/record_components.ex:53
-#: lib/music_library_web/components/record_components.ex:79
+#: lib/music_library_web/components/record_components.ex:92
#, elixir-autogen, elixir-format
msgid "Number of included records"
msgstr ""
diff --git a/test/music_library_web/live/collection_live/index_test.exs b/test/music_library_web/live/collection_live/index_test.exs
index 1f8472b8..77a81eaa 100644
--- a/test/music_library_web/live/collection_live/index_test.exs
+++ b/test/music_library_web/live/collection_live/index_test.exs
@@ -69,6 +69,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
assert record_row_html =~ Record.type_long_label(record.type)
assert record_row_html =~ record.release
assert record_row_html =~ ~p"/covers/#{record.id}?vsn=#{record.cover_hash}"
+ assert record_row_html =~ Record.format_purchased_at(record.purchased_at)
for artist <- record.artists do
assert record_row_html =~ escape(artist.name)