})
~p"/images/cover-not-found.png" <> "';"}
@@ -272,7 +275,8 @@ defmodule MusicLibraryWeb.Components.AddRecord do
class="mr-2 inline-flex items-center gap-1 rounded-full bg-emerald-100 dark:bg-emerald-500/10 text-emerald-700 dark:text-emerald-300 text-xs font-medium px-2 py-0.5"
>
<.icon name="hero-check" class="size-3" aria-hidden="true" data-slot="icon" />
- {gettext("In cart · %{format}", format: format_label(@cart_format))}
+
1}>{length(@cart_formats)}
+
{gettext("In cart")}
<.dropdown id={"actions-#{@release_group.id}"} placement="bottom-end">
@@ -615,11 +619,10 @@ defmodule MusicLibraryWeb.Components.AddRecord do
Enum.any?(cart_pairs, fn {id, _format} -> id == rg_id end)
end
- defp cart_format(cart, rg_id) do
- case Enum.find(cart, &(&1.release_group_id == rg_id)) do
- nil -> nil
- item -> item.format
- end
+ defp cart_formats(cart, rg_id) do
+ cart
+ |> Enum.filter(&(&1.release_group_id == rg_id))
+ |> Enum.map(& &1.format)
end
defp notify_parent(msg), do: send(self(), {__MODULE__, msg})
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot
index 7d60f26a..52a7f6b5 100644
--- a/priv/gettext/default.pot
+++ b/priv/gettext/default.pot
@@ -2497,11 +2497,6 @@ msgid_plural "Import %{count} records"
msgstr[0] ""
msgstr[1] ""
-#: lib/music_library_web/components/add_record.ex
-#, elixir-autogen, elixir-format
-msgid "In cart · %{format}"
-msgstr ""
-
#: lib/music_library_web/components/add_record.ex
#, elixir-autogen, elixir-format
msgid "Toggle cart"
@@ -2516,3 +2511,8 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Error queuing records for import"
msgstr ""
+
+#: lib/music_library_web/components/add_record.ex
+#, elixir-autogen, elixir-format
+msgid "In cart"
+msgstr ""
diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po
index f4cad4ac..47cfa1c4 100644
--- a/priv/gettext/en/LC_MESSAGES/default.po
+++ b/priv/gettext/en/LC_MESSAGES/default.po
@@ -2497,11 +2497,6 @@ msgid_plural "Import %{count} records"
msgstr[0] ""
msgstr[1] ""
-#: lib/music_library_web/components/add_record.ex
-#, elixir-autogen, elixir-format
-msgid "In cart · %{format}"
-msgstr ""
-
#: lib/music_library_web/components/add_record.ex
#, elixir-autogen, elixir-format
msgid "Toggle cart"
@@ -2516,3 +2511,8 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "Error queuing records for import"
msgstr ""
+
+#: lib/music_library_web/components/add_record.ex
+#, elixir-autogen, elixir-format
+msgid "In cart"
+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 cc7650e6..44195181 100644
--- a/test/music_library_web/live/collection_live/index_test.exs
+++ b/test/music_library_web/live/collection_live/index_test.exs
@@ -293,8 +293,10 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> visit(~p"/collection/import")
|> fill_in("Search for a record", with: "Marillion Marbles")
|> click_link("#musicbrainz_#{first_id} a", "CD")
- |> assert_has("#musicbrainz_#{first_id} span", text: "In cart · CD")
+ |> assert_has("#musicbrainz_#{first_id} span", text: "In cart")
|> assert_has("#cart-items li", count: 1)
+ |> click_link("#musicbrainz_#{first_id} a", "Vinyl")
+ |> assert_has("#musicbrainz_#{first_id} span", text: "2 In cart")
assert MusicLibrary.Repo.all(Record) == []
refute_enqueued(worker: ImportFromMusicbrainzReleaseGroup)
@@ -370,7 +372,7 @@ defmodule MusicLibraryWeb.CollectionLive.IndexTest do
|> LVT.element("#cart-items form")
|> LVT.render_change(%{"format" => "vinyl"})
- assert LVT.render(view) =~ "In cart · Vinyl"
+ assert LVT.render(view) =~ "In cart"
end
test "rejects change_format when the resulting pair is already in the cart", %{conn: conn} do