diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8e830980..91f9d25a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,8 +1,9 @@
# v0.5.5
- Update translations
- Make ammo index page a bit more compact
-- Add ammo count to ammo type index page
+- Make ammo catalog page include ammo count
- Make ammo type show page a bit more compact
+- Make ammo type show page include container names for each ammo
- Make container show page a bit more compact
- Forgot to add the logo as the favicon whoops
diff --git a/lib/cannery_web/components/ammo_group_card.ex b/lib/cannery_web/components/ammo_group_card.ex
index 25635acf..b993203b 100644
--- a/lib/cannery_web/components/ammo_group_card.ex
+++ b/lib/cannery_web/components/ammo_group_card.ex
@@ -7,8 +7,13 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
alias Cannery.Repo
alias CanneryWeb.Endpoint
- def ammo_group_card(assigns) do
- assigns = assigns |> assign(:ammo_group, assigns.ammo_group |> Repo.preload(:ammo_type))
+ def ammo_group_card(%{ammo_group: ammo_group} = assigns) do
+ assigns =
+ %{show_container: show_container} = assigns |> assign_new(:show_container, fn -> false end)
+
+ preloads = if show_container, do: [:ammo_type, :container], else: [:ammo_type]
+ ammo_group = ammo_group |> Repo.preload(preloads)
+ assigns = assigns |> assign(:ammo_group, ammo_group)
~H"""
- <%= live_redirect to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group),
+ <%= live_patch to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group),
class: "mb-2 link" do %>
<%= @ammo_group.ammo_type.name %>
@@ -50,6 +55,17 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
) %>
<% end %>
+
+ <%= if @show_container and @ammo_group.container do %>
+
+ <%= gettext("Container:") %>
+
+ <%= live_patch to: Routes.container_show_path(Endpoint, :show, @ammo_group.container),
+ class: "link" do %>
+ <%= @ammo_group.container.name %>
+ <% end %>
+
+ <% end %>
<%= if assigns |> Map.has_key?(:inner_block) do %>
diff --git a/lib/cannery_web/live/ammo_type_live/show.html.heex b/lib/cannery_web/live/ammo_type_live/show.html.heex
index 18388252..8416a4ee 100644
--- a/lib/cannery_web/live/ammo_type_live/show.html.heex
+++ b/lib/cannery_web/live/ammo_type_live/show.html.heex
@@ -122,7 +122,7 @@
<% else %>
<%= for ammo_group <- @ammo_groups do %>
- <.ammo_group_card ammo_group={ammo_group} />
+ <.ammo_group_card ammo_group={ammo_group} show_container={true} />
<% end %>
<% end %>
diff --git a/priv/gettext/de/LC_MESSAGES/default.po b/priv/gettext/de/LC_MESSAGES/default.po
index adec7558..396e2401 100644
--- a/priv/gettext/de/LC_MESSAGES/default.po
+++ b/priv/gettext/de/LC_MESSAGES/default.po
@@ -144,7 +144,7 @@ msgid "Count"
msgstr "Anzahl"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:29
+#: lib/cannery_web/components/ammo_group_card.ex:34
#: lib/cannery_web/live/ammo_group_live/show.html.heex:8
msgid "Count:"
msgstr "Anzahl:"
@@ -352,7 +352,7 @@ msgid "Notes"
msgstr "Bemerkungen"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:35
+#: lib/cannery_web/components/ammo_group_card.ex:40
#: lib/cannery_web/live/ammo_group_live/show.html.heex:24
msgid "Notes:"
msgstr "Bemerkungen:"
@@ -376,7 +376,7 @@ msgid "Price paid"
msgstr "Kaufpreis"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:47
+#: lib/cannery_web/components/ammo_group_card.ex:52
msgid "Price paid:"
msgstr "Kaufpreis:"
@@ -616,7 +616,7 @@ msgid "Shot log"
msgstr "Schießkladde"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:48
+#: lib/cannery_web/components/ammo_group_card.ex:53
#: lib/cannery_web/live/ammo_group_live/index.ex:125
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
@@ -829,7 +829,7 @@ msgid "Added on"
msgstr "Hinzugefügt am"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:41
+#: lib/cannery_web/components/ammo_group_card.ex:46
#: lib/cannery_web/live/ammo_group_live/show.html.heex:30
#: lib/cannery_web/live/ammo_type_live/show.html.heex:90
msgid "Added on:"
@@ -940,3 +940,8 @@ msgstr ""
#: lib/cannery_web/live/ammo_type_live/index.ex:87
msgid "Total # of ammo"
msgstr "Summe aller Patronen"
+
+#, elixir-autogen, elixir-format, fuzzy
+#: lib/cannery_web/components/ammo_group_card.ex:61
+msgid "Container:"
+msgstr "Behälter"
diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot
index 376426a7..b74a1ac6 100644
--- a/priv/gettext/default.pot
+++ b/priv/gettext/default.pot
@@ -129,7 +129,7 @@ msgid "Count"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:29
+#: lib/cannery_web/components/ammo_group_card.ex:34
#: lib/cannery_web/live/ammo_group_live/show.html.heex:8
msgid "Count:"
msgstr ""
@@ -337,7 +337,7 @@ msgid "Notes"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:35
+#: lib/cannery_web/components/ammo_group_card.ex:40
#: lib/cannery_web/live/ammo_group_live/show.html.heex:24
msgid "Notes:"
msgstr ""
@@ -361,7 +361,7 @@ msgid "Price paid"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:47
+#: lib/cannery_web/components/ammo_group_card.ex:52
msgid "Price paid:"
msgstr ""
@@ -599,7 +599,7 @@ msgid "Shot log"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:48
+#: lib/cannery_web/components/ammo_group_card.ex:53
#: lib/cannery_web/live/ammo_group_live/index.ex:125
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
@@ -812,7 +812,7 @@ msgid "Added on"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:41
+#: lib/cannery_web/components/ammo_group_card.ex:46
#: lib/cannery_web/live/ammo_group_live/show.html.heex:30
#: lib/cannery_web/live/ammo_type_live/show.html.heex:90
msgid "Added on:"
@@ -923,3 +923,8 @@ msgstr ""
#: lib/cannery_web/live/ammo_type_live/index.ex:87
msgid "Total # of ammo"
msgstr ""
+
+#, elixir-autogen, elixir-format
+#: lib/cannery_web/components/ammo_group_card.ex:61
+msgid "Container:"
+msgstr ""
diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po
index 0f252e7d..06f8046d 100644
--- a/priv/gettext/en/LC_MESSAGES/default.po
+++ b/priv/gettext/en/LC_MESSAGES/default.po
@@ -130,7 +130,7 @@ msgid "Count"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:29
+#: lib/cannery_web/components/ammo_group_card.ex:34
#: lib/cannery_web/live/ammo_group_live/show.html.heex:8
msgid "Count:"
msgstr ""
@@ -338,7 +338,7 @@ msgid "Notes"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:35
+#: lib/cannery_web/components/ammo_group_card.ex:40
#: lib/cannery_web/live/ammo_group_live/show.html.heex:24
msgid "Notes:"
msgstr ""
@@ -362,7 +362,7 @@ msgid "Price paid"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:47
+#: lib/cannery_web/components/ammo_group_card.ex:52
msgid "Price paid:"
msgstr ""
@@ -600,7 +600,7 @@ msgid "Shot log"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:48
+#: lib/cannery_web/components/ammo_group_card.ex:53
#: lib/cannery_web/live/ammo_group_live/index.ex:125
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
@@ -813,7 +813,7 @@ msgid "Added on"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:41
+#: lib/cannery_web/components/ammo_group_card.ex:46
#: lib/cannery_web/live/ammo_group_live/show.html.heex:30
#: lib/cannery_web/live/ammo_type_live/show.html.heex:90
msgid "Added on:"
@@ -924,3 +924,8 @@ msgstr ""
#: lib/cannery_web/live/ammo_type_live/index.ex:87
msgid "Total # of ammo"
msgstr ""
+
+#, elixir-autogen, elixir-format, fuzzy
+#: lib/cannery_web/components/ammo_group_card.ex:61
+msgid "Container:"
+msgstr ""
diff --git a/priv/gettext/es/LC_MESSAGES/default.po b/priv/gettext/es/LC_MESSAGES/default.po
index 1ad3a809..c1d8fae7 100644
--- a/priv/gettext/es/LC_MESSAGES/default.po
+++ b/priv/gettext/es/LC_MESSAGES/default.po
@@ -144,7 +144,7 @@ msgid "Count"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:29
+#: lib/cannery_web/components/ammo_group_card.ex:34
#: lib/cannery_web/live/ammo_group_live/show.html.heex:8
msgid "Count:"
msgstr ""
@@ -352,7 +352,7 @@ msgid "Notes"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:35
+#: lib/cannery_web/components/ammo_group_card.ex:40
#: lib/cannery_web/live/ammo_group_live/show.html.heex:24
msgid "Notes:"
msgstr ""
@@ -376,7 +376,7 @@ msgid "Price paid"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:47
+#: lib/cannery_web/components/ammo_group_card.ex:52
msgid "Price paid:"
msgstr ""
@@ -614,7 +614,7 @@ msgid "Shot log"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:48
+#: lib/cannery_web/components/ammo_group_card.ex:53
#: lib/cannery_web/live/ammo_group_live/index.ex:125
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
@@ -827,7 +827,7 @@ msgid "Added on"
msgstr ""
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:41
+#: lib/cannery_web/components/ammo_group_card.ex:46
#: lib/cannery_web/live/ammo_group_live/show.html.heex:30
#: lib/cannery_web/live/ammo_type_live/show.html.heex:90
msgid "Added on:"
@@ -938,3 +938,8 @@ msgstr ""
#: lib/cannery_web/live/ammo_type_live/index.ex:87
msgid "Total # of ammo"
msgstr ""
+
+#, elixir-autogen, elixir-format, fuzzy
+#: lib/cannery_web/components/ammo_group_card.ex:61
+msgid "Container:"
+msgstr ""
diff --git a/priv/gettext/fr/LC_MESSAGES/default.po b/priv/gettext/fr/LC_MESSAGES/default.po
index 469a51a1..61a49954 100644
--- a/priv/gettext/fr/LC_MESSAGES/default.po
+++ b/priv/gettext/fr/LC_MESSAGES/default.po
@@ -144,7 +144,7 @@ msgid "Count"
msgstr "Quantité"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:29
+#: lib/cannery_web/components/ammo_group_card.ex:34
#: lib/cannery_web/live/ammo_group_live/show.html.heex:8
msgid "Count:"
msgstr "Quantité :"
@@ -352,7 +352,7 @@ msgid "Notes"
msgstr "Notes"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:35
+#: lib/cannery_web/components/ammo_group_card.ex:40
#: lib/cannery_web/live/ammo_group_live/show.html.heex:24
msgid "Notes:"
msgstr "Notes :"
@@ -376,7 +376,7 @@ msgid "Price paid"
msgstr "Prix payé"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:47
+#: lib/cannery_web/components/ammo_group_card.ex:52
msgid "Price paid:"
msgstr "Prix payé :"
@@ -618,7 +618,7 @@ msgid "Shot log"
msgstr "Évènements de tir"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:48
+#: lib/cannery_web/components/ammo_group_card.ex:53
#: lib/cannery_web/live/ammo_group_live/index.ex:125
#: lib/cannery_web/live/ammo_group_live/show.html.heex:37
#: lib/cannery_web/live/ammo_group_live/show.html.heex:44
@@ -831,7 +831,7 @@ msgid "Added on"
msgstr "Ajouté le"
#, elixir-autogen, elixir-format
-#: lib/cannery_web/components/ammo_group_card.ex:41
+#: lib/cannery_web/components/ammo_group_card.ex:46
#: lib/cannery_web/live/ammo_group_live/show.html.heex:30
#: lib/cannery_web/live/ammo_type_live/show.html.heex:90
msgid "Added on:"
@@ -942,3 +942,8 @@ msgstr ""
#: lib/cannery_web/live/ammo_type_live/index.ex:87
msgid "Total # of ammo"
msgstr "Quantité de cartouches"
+
+#, elixir-autogen, elixir-format, fuzzy
+#: lib/cannery_web/components/ammo_group_card.ex:61
+msgid "Container:"
+msgstr "Conteneur"