forked from shibao/cannery
add pack and round count to containers
This commit is contained in:
parent
11b1ae9980
commit
9a1a104c6d
@ -1,7 +1,8 @@
|
|||||||
# v0.5.4
|
# v0.5.4
|
||||||
- Rename "Ammo" tab to "Catalog", and "Manage" tab is now "Ammo"
|
- Rename "Ammo" tab to "Catalog", and "Manage" tab is now "Ammo"
|
||||||
- Ammo groups are now just referred to as Ammo
|
- Ammo groups are now just referred to as Ammo or "Packs"
|
||||||
- URL paths now reflect new names
|
- URL paths now reflect new names
|
||||||
|
- Add pack and round count to container information
|
||||||
|
|
||||||
# v0.5.3
|
# v0.5.3
|
||||||
- Update French translation: Thank you [duponin](https://udongein.xyz/users/duponin)!
|
- Update French translation: Thank you [duponin](https://udongein.xyz/users/duponin)!
|
||||||
|
@ -207,6 +207,18 @@ defmodule Cannery.Containers do
|
|||||||
if count == 0, do: raise("could not delete container tag"), else: count
|
if count == 0, do: raise("could not delete container tag"), else: count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Returns number of rounds in container. If data is already preloaded, then
|
||||||
|
there will be no db hit.
|
||||||
|
"""
|
||||||
|
@spec get_container_ammo_group_count!(Container.t()) :: non_neg_integer()
|
||||||
|
def get_container_ammo_group_count!(%Container{} = container) do
|
||||||
|
container
|
||||||
|
|> Repo.preload(:ammo_groups)
|
||||||
|
|> Map.fetch!(:ammo_groups)
|
||||||
|
|> Enum.count()
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Returns number of rounds in container. If data is already preloaded, then
|
Returns number of rounds in container. If data is already preloaded, then
|
||||||
there will be no db hit.
|
there will be no db hit.
|
||||||
|
@ -45,7 +45,12 @@ defmodule CanneryWeb.Components.ContainerCard do
|
|||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= if @container.ammo_groups do %>
|
<%= unless @container.ammo_groups |> Enum.empty?() do %>
|
||||||
|
<span class="rounded-lg title text-lg">
|
||||||
|
<%= gettext("Packs:") %>
|
||||||
|
<%= @container |> Containers.get_container_ammo_group_count!() %>
|
||||||
|
</span>
|
||||||
|
|
||||||
<span class="rounded-lg title text-lg">
|
<span class="rounded-lg title text-lg">
|
||||||
<%= gettext("Rounds:") %>
|
<%= gettext("Rounds:") %>
|
||||||
<%= @container |> Containers.get_container_rounds!() %>
|
<%= @container |> Containers.get_container_rounds!() %>
|
||||||
|
@ -22,6 +22,18 @@
|
|||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= unless @container.ammo_groups |> Enum.empty?() do %>
|
||||||
|
<span class="rounded-lg title text-lg">
|
||||||
|
<%= gettext("Packs:") %>
|
||||||
|
<%= @container |> Containers.get_container_ammo_group_count!() %>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="rounded-lg title text-lg">
|
||||||
|
<%= gettext("Rounds:") %>
|
||||||
|
<%= @container |> Containers.get_container_rounds!() %>
|
||||||
|
</span>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="flex space-x-4 justify-center items-center text-primary-600">
|
<div class="flex space-x-4 justify-center items-center text-primary-600">
|
||||||
<%= live_patch to: Routes.container_show_path(Endpoint, :edit, @container),
|
<%= live_patch to: Routes.container_show_path(Endpoint, :edit, @container),
|
||||||
class: "text-primary-600 link",
|
class: "text-primary-600 link",
|
||||||
|
Loading…
Reference in New Issue
Block a user