remove :table path
This commit is contained in:
parent
213dcca973
commit
40e4f6fe0a
@ -1,5 +1,6 @@
|
||||
# v0.8.6
|
||||
- Fix duplicate entries showing up
|
||||
- Show ammo groups under a type in a table by default
|
||||
|
||||
# v0.8.5
|
||||
- Add link in readme to github mirror
|
||||
|
@ -30,17 +30,12 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
|
||||
]
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, %{assigns: %{live_action: live_action}} = socket),
|
||||
do: {:ok, socket |> assign(show_used: false, view_table: live_action == :table)}
|
||||
def mount(_params, _session, socket),
|
||||
do: {:ok, socket |> assign(show_used: false, view_table: true)}
|
||||
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _params, %{assigns: %{live_action: live_action}} = socket) do
|
||||
socket =
|
||||
socket
|
||||
|> assign(view_table: live_action == :table)
|
||||
|> display_ammo_type(id)
|
||||
|
||||
{:noreply, socket}
|
||||
def handle_params(%{"id" => id}, _params, socket) do
|
||||
{:noreply, socket |> display_ammo_type(id)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@ -61,23 +56,14 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
|
||||
{:noreply, socket |> assign(:show_used, !show_used) |> display_ammo_type()}
|
||||
end
|
||||
|
||||
def handle_event(
|
||||
"toggle_table",
|
||||
_params,
|
||||
%{assigns: %{view_table: view_table, ammo_type: ammo_type}} = socket
|
||||
) do
|
||||
new_path =
|
||||
if view_table,
|
||||
do: Routes.ammo_type_show_path(Endpoint, :show, ammo_type),
|
||||
else: Routes.ammo_type_show_path(Endpoint, :table, ammo_type)
|
||||
|
||||
{:noreply, socket |> push_patch(to: new_path)}
|
||||
def handle_event("toggle_table", _params, %{assigns: %{view_table: view_table}} = socket) do
|
||||
{:noreply, socket |> assign(:view_table, !view_table)}
|
||||
end
|
||||
|
||||
defp display_ammo_type(
|
||||
%{assigns: %{live_action: live_action, current_user: current_user, show_used: show_used}} =
|
||||
socket,
|
||||
%AmmoType{} = ammo_type
|
||||
%AmmoType{name: ammo_type_name} = ammo_type
|
||||
) do
|
||||
fields_to_display =
|
||||
@fields_list
|
||||
@ -112,9 +98,15 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
|
||||
[nil, nil, nil, nil, nil]
|
||||
end
|
||||
|
||||
page_title =
|
||||
case live_action do
|
||||
:show -> ammo_type_name
|
||||
:edit -> gettext("Edit %{ammo_type_name}", ammo_type_name: ammo_type_name)
|
||||
end
|
||||
|
||||
socket
|
||||
|> assign(
|
||||
page_title: page_title(live_action, ammo_type),
|
||||
page_title: page_title,
|
||||
ammo_type: ammo_type,
|
||||
ammo_groups: ammo_groups,
|
||||
cprs: ammo_groups |> Ammo.get_cprs(current_user),
|
||||
@ -142,10 +134,4 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
|
||||
|
||||
@spec display_currency(float()) :: String.t()
|
||||
defp display_currency(float), do: :erlang.float_to_binary(float, decimals: 2)
|
||||
|
||||
defp page_title(action, %{name: ammo_type_name}) when action in [:show, :table],
|
||||
do: ammo_type_name
|
||||
|
||||
defp page_title(:edit, %{name: ammo_type_name}),
|
||||
do: gettext("Edit %{ammo_type_name}", ammo_type_name: ammo_type_name)
|
||||
end
|
||||
|
@ -104,7 +104,7 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
|
||||
page_title =
|
||||
case live_action do
|
||||
action when action in [:show, :table] -> container_name
|
||||
:show -> container_name
|
||||
:edit -> gettext("Edit %{name}", name: container_name)
|
||||
:edit_tags -> gettext("Edit %{name} tags", name: container_name)
|
||||
end
|
||||
|
@ -77,7 +77,6 @@ defmodule CanneryWeb.Router do
|
||||
|
||||
live "/type/:id", AmmoTypeLive.Show, :show
|
||||
live "/type/:id/edit", AmmoTypeLive.Show, :edit
|
||||
live "/type/:id/table", AmmoTypeLive.Show, :table
|
||||
|
||||
live "/containers", ContainerLive.Index, :index
|
||||
live "/containers/new", ContainerLive.Index, :new
|
||||
|
@ -991,7 +991,7 @@ msgid "Average CPR"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:28
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:150
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:104
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Edit %{ammo_type_name}"
|
||||
msgstr "%{name} bearbeiten"
|
||||
|
@ -32,7 +32,7 @@ msgid "%{name} created successfully"
|
||||
msgstr "%{name} erfolgreich erstellt"
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:72
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:54
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
|
@ -985,7 +985,7 @@ msgid "Average CPR"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:28
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:150
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:104
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit %{ammo_type_name}"
|
||||
msgstr ""
|
||||
|
@ -985,7 +985,7 @@ msgid "Average CPR"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:28
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:150
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:104
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Edit %{ammo_type_name}"
|
||||
msgstr ""
|
||||
|
@ -19,7 +19,7 @@ msgid "%{name} created successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:72
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:54
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
|
@ -993,7 +993,7 @@ msgid "Average CPR"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:28
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:150
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:104
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit %{ammo_type_name}"
|
||||
msgstr "Editar %{ammo_type_name}"
|
||||
|
@ -32,7 +32,7 @@ msgid "%{name} created successfully"
|
||||
msgstr "%{name} creado exitosamente"
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:72
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:54
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
|
@ -994,7 +994,7 @@ msgid "Average CPR"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:28
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:150
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:104
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Edit %{ammo_type_name}"
|
||||
msgstr "Éditer %{name}"
|
||||
|
@ -32,7 +32,7 @@ msgid "%{name} created successfully"
|
||||
msgstr "%{name} créé· avec succès"
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:72
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:54
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
|
@ -987,7 +987,7 @@ msgid "Average CPR"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:28
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:150
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:104
|
||||
#, elixir-autogen, elixir-format, fuzzy
|
||||
msgid "Edit %{ammo_type_name}"
|
||||
msgstr ""
|
||||
|
@ -30,7 +30,7 @@ msgid "%{name} created successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:72
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:54
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
|
@ -19,7 +19,7 @@ msgid "%{name} created successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/cannery_web/live/ammo_type_live/index.ex:72
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:54
|
||||
#: lib/cannery_web/live/ammo_type_live/show.ex:49
|
||||
#: lib/cannery_web/live/tag_live/index.ex:65
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{name} deleted succesfully"
|
||||
|
@ -310,8 +310,6 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
||||
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_table-label"}]/)
|
||||
|> render_click()
|
||||
|
||||
assert_patch(show_live, Routes.ammo_type_show_path(conn, :table, ammo_type))
|
||||
|
||||
assert html =~ "some ammo group"
|
||||
assert html =~ container_name
|
||||
end
|
||||
@ -346,8 +344,6 @@ defmodule CanneryWeb.AmmoTypeLiveTest do
|
||||
|> element(~s/input[type="checkbox"][aria-labelledby="toggle_table-label"}]/)
|
||||
|> render_click()
|
||||
|
||||
assert_patch(show_live, Routes.ammo_type_show_path(conn, :table, ammo_type))
|
||||
|
||||
assert html =~ dgettext("actions", "Show used")
|
||||
refute html =~ "some ammo group"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user