From 2e0bb861f1904015b8d9f839904d79c0362c7d2e Mon Sep 17 00:00:00 2001 From: shibao Date: Sun, 6 Nov 2022 23:30:16 -0500 Subject: [PATCH] show container name in ammo type listing --- CHANGELOG.md | 3 ++- lib/cannery_web/components/ammo_group_card.ex | 22 ++++++++++++++++--- .../live/ammo_type_live/show.html.heex | 2 +- priv/gettext/de/LC_MESSAGES/default.po | 15 ++++++++----- priv/gettext/default.pot | 15 ++++++++----- priv/gettext/en/LC_MESSAGES/default.po | 15 ++++++++----- priv/gettext/es/LC_MESSAGES/default.po | 15 ++++++++----- priv/gettext/fr/LC_MESSAGES/default.po | 15 ++++++++----- 8 files changed, 72 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e83098..91f9d25 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 25635ac..b993203 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 1838825..8416a4e 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 adec755..396e240 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 376426a..b74a1ac 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 0f252e7..06f8046 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 1ad3a80..c1d8fae 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 469a51a..61a4995 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"