From ce7223597c04274ea2f0d5bd6d1c766482e75024 Mon Sep 17 00:00:00 2001 From: shibao Date: Thu, 5 May 2022 21:43:03 -0400 Subject: [PATCH] add created date to ammo groups --- lib/cannery_web/components/ammo_group_card.ex | 5 +++++ lib/cannery_web/live/ammo_group_live/index.ex | 10 ++++++++++ lib/cannery_web/live/ammo_group_live/show.html.heex | 5 +++++ 3 files changed, 20 insertions(+) diff --git a/lib/cannery_web/components/ammo_group_card.ex b/lib/cannery_web/components/ammo_group_card.ex index 3686cdc..25635ac 100644 --- a/lib/cannery_web/components/ammo_group_card.ex +++ b/lib/cannery_web/components/ammo_group_card.ex @@ -37,6 +37,11 @@ defmodule CanneryWeb.Components.AmmoGroupCard do <% end %> + + <%= gettext("Added on:") %> + <%= @ammo_group.inserted_at |> display_datetime() %> + + <%= if @ammo_group.price_paid do %> <%= gettext("Price paid:") %> diff --git a/lib/cannery_web/live/ammo_group_live/index.ex b/lib/cannery_web/live/ammo_group_live/index.ex index d4ee814..3b5e348 100644 --- a/lib/cannery_web/live/ammo_group_live/index.ex +++ b/lib/cannery_web/live/ammo_group_live/index.ex @@ -83,6 +83,7 @@ defmodule CanneryWeb.AmmoGroupLive.Index do %{label: gettext("% left"), key: "remaining"}, %{label: gettext("Range"), key: "range"}, %{label: gettext("Container"), key: "container"}, + %{label: gettext("Added on"), key: "added_on"}, %{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}), 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 assigns = %{ammo_group: ammo_group} diff --git a/lib/cannery_web/live/ammo_group_live/show.html.heex b/lib/cannery_web/live/ammo_group_live/show.html.heex index 0735bab..de64360 100644 --- a/lib/cannery_web/live/ammo_group_live/show.html.heex +++ b/lib/cannery_web/live/ammo_group_live/show.html.heex @@ -26,6 +26,11 @@ <% end %> + + <%= gettext("Added on:") %> + <%= @ammo_group.inserted_at |> display_datetime() %> + + <%= if @ammo_group.price_paid do %> <%= gettext("Original cost:") %>