diff --git a/lib/cannery_web/live/range_live/index.ex b/lib/cannery_web/live/range_live/index.ex index e0f6e64c..27a0e735 100644 --- a/lib/cannery_web/live/range_live/index.ex +++ b/lib/cannery_web/live/range_live/index.ex @@ -77,6 +77,65 @@ defmodule CanneryWeb.RangeLive.Index do ActivityLog.list_shot_groups(current_user) |> Repo.preload(ammo_group: :ammo_type) ammo_groups = Ammo.list_staged_ammo_groups(current_user) - socket |> assign(shot_groups: shot_groups, ammo_groups: ammo_groups) + + columns = [ + %{label: gettext("Ammo"), key: "name"}, + %{label: gettext("Rounds shot"), key: "count"}, + %{label: gettext("Notes"), key: "notes"}, + %{label: gettext("Date"), key: "date"}, + %{label: nil, key: "actions", sortable: false} + ] + + rows = + shot_groups + |> Enum.map(fn %{date: date} = shot_group -> + assigns = %{shot_group: shot_group} + + columns + |> Enum.into(%{}, fn %{key: key} -> + value = + case key do + "name" -> + {shot_group.ammo_group.ammo_type.name, + live_patch(shot_group.ammo_group.ammo_type.name, + to: Routes.ammo_group_show_path(Endpoint, :show, shot_group.ammo_group), + class: "link" + )} + + "date" -> + date |> display_date() + + "actions" -> + ~H""" +
- <%= gettext("Ammo") %> - | -- <%= gettext("Rounds shot") %> - | -- <%= gettext("Notes") %> - | -- <%= gettext("Date") %> - | - -- |
---|---|---|---|---|
- <%= live_patch(shot_group.ammo_group.ammo_type.name, - to: Routes.ammo_group_show_path(Endpoint, :show, shot_group.ammo_group), - class: "link" - ) %> - | -- <%= shot_group.count %> - | -- <%= shot_group.notes %> - | -- <%= shot_group.date |> display_date() %> - | - -
-
- <%= live_patch to: Routes.range_index_path(Endpoint, :edit, shot_group),
- class: "text-primary-600 link",
- data: [qa: "edit-#{shot_group.id}"] do %>
-
- <% end %>
-
- <%= link to: "#",
- class: "text-primary-600 link",
- phx_click: "delete",
- phx_value_id: shot_group.id,
- data: [
- confirm: dgettext("prompts", "Are you sure you want to delete this shot record?"),
- qa: "delete-#{shot_group.id}"
- ] do %>
-
- <% end %>
-
- |
-