add created date to ammo groups

This commit is contained in:
shibao 2022-05-05 21:43:03 -04:00
parent 4791a2849e
commit ce7223597c
3 changed files with 20 additions and 0 deletions

View File

@ -37,6 +37,11 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
</span> </span>
<% end %> <% end %>
<span class="rounded-lg title text-lg">
<%= gettext("Added on:") %>
<%= @ammo_group.inserted_at |> display_datetime() %>
</span>
<%= if @ammo_group.price_paid do %> <%= if @ammo_group.price_paid do %>
<span class="rounded-lg title text-lg"> <span class="rounded-lg title text-lg">
<%= gettext("Price paid:") %> <%= gettext("Price paid:") %>

View File

@ -83,6 +83,7 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
%{label: gettext("% left"), key: "remaining"}, %{label: gettext("% left"), key: "remaining"},
%{label: gettext("Range"), key: "range"}, %{label: gettext("Range"), key: "range"},
%{label: gettext("Container"), key: "container"}, %{label: gettext("Container"), key: "container"},
%{label: gettext("Added on"), key: "added_on"},
%{label: nil, key: "actions", sortable: false} %{label: nil, key: "actions", sortable: false}
] ]
@ -116,6 +117,15 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
defp get_value_for_key("price_paid", %{price_paid: price_paid}), defp get_value_for_key("price_paid", %{price_paid: price_paid}),
do: gettext("$%{amount}", amount: price_paid |> :erlang.float_to_binary(decimals: 2)) do: gettext("$%{amount}", amount: price_paid |> :erlang.float_to_binary(decimals: 2))
defp get_value_for_key("added_on", %{inserted_at: inserted_at}) do
assigns = %{inserted_at: inserted_at}
{inserted_at,
~H"""
<%= @inserted_at |> display_datetime() %>
"""}
end
defp get_value_for_key("range", %{staged: staged} = ammo_group) do defp get_value_for_key("range", %{staged: staged} = ammo_group) do
assigns = %{ammo_group: ammo_group} assigns = %{ammo_group: ammo_group}

View File

@ -26,6 +26,11 @@
</span> </span>
<% end %> <% end %>
<span class="rounded-lg title text-lg">
<%= gettext("Added on:") %>
<%= @ammo_group.inserted_at |> display_datetime() %>
</span>
<%= if @ammo_group.price_paid do %> <%= if @ammo_group.price_paid do %>
<span class="rounded-lg title text-lg"> <span class="rounded-lg title text-lg">
<%= gettext("Original cost:") %> <%= gettext("Original cost:") %>