forked from shibao/cannery
rename ammo_type type to class
This commit is contained in:
@ -10,11 +10,11 @@ defmodule CanneryWeb.RangeLive.Index do
|
||||
|
||||
@impl true
|
||||
def mount(%{"search" => search}, _session, socket) do
|
||||
{:ok, socket |> assign(type: :all, search: search) |> display_shot_groups()}
|
||||
{:ok, socket |> assign(class: :all, search: search) |> display_shot_groups()}
|
||||
end
|
||||
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket |> assign(type: :all, search: nil) |> display_shot_groups()}
|
||||
{:ok, socket |> assign(class: :all, search: nil) |> display_shot_groups()}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@ -102,27 +102,27 @@ defmodule CanneryWeb.RangeLive.Index do
|
||||
{:noreply, socket |> push_patch(to: Routes.range_index_path(Endpoint, :search, search_term))}
|
||||
end
|
||||
|
||||
def handle_event("change_type", %{"ammo_type" => %{"type" => "rifle"}}, socket) do
|
||||
{:noreply, socket |> assign(:type, :rifle) |> display_shot_groups()}
|
||||
def handle_event("change_class", %{"ammo_type" => %{"class" => "rifle"}}, socket) do
|
||||
{:noreply, socket |> assign(:class, :rifle) |> display_shot_groups()}
|
||||
end
|
||||
|
||||
def handle_event("change_type", %{"ammo_type" => %{"type" => "shotgun"}}, socket) do
|
||||
{:noreply, socket |> assign(:type, :shotgun) |> display_shot_groups()}
|
||||
def handle_event("change_class", %{"ammo_type" => %{"class" => "shotgun"}}, socket) do
|
||||
{:noreply, socket |> assign(:class, :shotgun) |> display_shot_groups()}
|
||||
end
|
||||
|
||||
def handle_event("change_type", %{"ammo_type" => %{"type" => "pistol"}}, socket) do
|
||||
{:noreply, socket |> assign(:type, :pistol) |> display_shot_groups()}
|
||||
def handle_event("change_class", %{"ammo_type" => %{"class" => "pistol"}}, socket) do
|
||||
{:noreply, socket |> assign(:class, :pistol) |> display_shot_groups()}
|
||||
end
|
||||
|
||||
def handle_event("change_type", %{"ammo_type" => %{"type" => _all}}, socket) do
|
||||
{:noreply, socket |> assign(:type, :all) |> display_shot_groups()}
|
||||
def handle_event("change_class", %{"ammo_type" => %{"class" => _all}}, socket) do
|
||||
{:noreply, socket |> assign(:class, :all) |> display_shot_groups()}
|
||||
end
|
||||
|
||||
@spec display_shot_groups(Socket.t()) :: Socket.t()
|
||||
defp display_shot_groups(
|
||||
%{assigns: %{type: type, search: search, current_user: current_user}} = socket
|
||||
%{assigns: %{class: class, search: search, current_user: current_user}} = socket
|
||||
) do
|
||||
shot_groups = ActivityLog.list_shot_groups(search, type, current_user)
|
||||
shot_groups = ActivityLog.list_shot_groups(search, class, current_user)
|
||||
ammo_groups = Ammo.list_staged_ammo_groups(current_user)
|
||||
chart_data = shot_groups |> get_chart_data_for_shot_group()
|
||||
original_counts = ammo_groups |> Ammo.get_original_counts(current_user)
|
||||
|
@ -79,15 +79,15 @@
|
||||
:let={f}
|
||||
for={%{}}
|
||||
as={:ammo_type}
|
||||
phx-change="change_type"
|
||||
phx-submit="change_type"
|
||||
phx-change="change_class"
|
||||
phx-submit="change_class"
|
||||
class="flex items-center"
|
||||
>
|
||||
<%= label(f, :type, gettext("Type"), class: "title text-primary-600 text-lg text-center") %>
|
||||
<%= label(f, :class, gettext("Class"), class: "title text-primary-600 text-lg text-center") %>
|
||||
|
||||
<%= select(
|
||||
f,
|
||||
:type,
|
||||
:class,
|
||||
[
|
||||
{gettext("All"), :all},
|
||||
{gettext("Rifle"), :rifle},
|
||||
@ -95,7 +95,7 @@
|
||||
{gettext("Pistol"), :pistol}
|
||||
],
|
||||
class: "mx-2 my-1 min-w-md input input-primary",
|
||||
value: @type
|
||||
value: @class
|
||||
) %>
|
||||
</.form>
|
||||
|
||||
|
Reference in New Issue
Block a user