upgrade to phoenix 1.7

This commit is contained in:
2023-04-14 23:34:11 -04:00
parent 1796fb822f
commit 1037f37be2
138 changed files with 2304 additions and 2252 deletions

View File

@ -113,13 +113,11 @@ defmodule CanneryWeb.PackLive.Index do
end
def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do
{:noreply, socket |> push_patch(to: Routes.pack_index_path(Endpoint, :index))}
{:noreply, socket |> push_patch(to: ~p"/ammo")}
end
def handle_event("search", %{"search" => %{"search_term" => search_term}}, socket) do
socket = socket |> push_patch(to: Routes.pack_index_path(Endpoint, :search, search_term))
{:noreply, socket}
{:noreply, socket |> push_patch(to: ~p"/ammo/search/#{search_term}")}
end
def handle_event("change_class", %{"type" => %{"class" => "rifle"}}, socket) do

View File

@ -10,7 +10,7 @@
<%= dgettext("prompts", "You'll need to") %>
</h2>
<.link navigate={Routes.container_index_path(Endpoint, :new)} class="btn btn-primary">
<.link navigate={~p"/containers/new"} class="btn btn-primary">
<%= dgettext("actions", "add a container first") %>
</.link>
</div>
@ -20,7 +20,7 @@
<%= dgettext("prompts", "You'll need to") %>
</h2>
<.link navigate={Routes.type_index_path(Endpoint, :new)} class="btn btn-primary">
<.link navigate={~p"/catalog/new"} class="btn btn-primary">
<%= dgettext("actions", "add a type first") %>
</.link>
</div>
@ -30,11 +30,11 @@
<%= display_emoji("😔") %>
</h2>
<.link patch={Routes.pack_index_path(Endpoint, :new)} class="btn btn-primary">
<.link patch={~p"/ammo/new"} class="btn btn-primary">
<%= dgettext("actions", "Add your first box!") %>
</.link>
<% true -> %>
<.link patch={Routes.pack_index_path(Endpoint, :new)} class="btn btn-primary">
<.link patch={~p"/ammo/new"} class="btn btn-primary">
<%= dgettext("actions", "Add Ammo") %>
</.link>
@ -103,7 +103,7 @@
show_used={@show_used}
>
<:type :let={%{name: type_name} = type}>
<.link navigate={Routes.type_show_path(Endpoint, :show, type)} class="link">
<.link navigate={~p"/type/#{type}"} class="link">
<%= type_name %>
</.link>
</:type>
@ -121,7 +121,7 @@
</button>
<.link
patch={Routes.pack_index_path(Endpoint, :add_shot_record, pack)}
patch={~p"/ammo/add_shot_record/#{pack}"}
class="mx-2 my-1 text-sm btn btn-primary"
>
<%= dgettext("actions", "Record shots") %>
@ -130,17 +130,11 @@
</:range>
<:container :let={{pack, %{name: container_name} = container}}>
<div class="min-w-20 py-2 px-4 h-full flex flew-wrap justify-center items-center">
<.link
navigate={Routes.container_show_path(Endpoint, :show, container)}
class="mx-2 my-1 link"
>
<.link navigate={~p"/container/#{container}"} class="mx-2 my-1 link">
<%= container_name %>
</.link>
<.link
patch={Routes.pack_index_path(Endpoint, :move, pack)}
class="mx-2 my-1 text-sm btn btn-primary"
>
<.link patch={~p"/ammo/move/#{pack}"} class="mx-2 my-1 text-sm btn btn-primary">
<%= dgettext("actions", "Move ammo") %>
</.link>
</div>
@ -148,7 +142,7 @@
<:actions :let={%{count: pack_count} = pack}>
<div class="py-2 px-4 h-full space-x-4 flex justify-center items-center">
<.link
navigate={Routes.pack_show_path(Endpoint, :show, pack)}
navigate={~p"/ammo/show/#{pack}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "View pack of %{pack_count} bullets", pack_count: pack_count)
@ -158,7 +152,7 @@
</.link>
<.link
patch={Routes.pack_index_path(Endpoint, :edit, pack)}
patch={~p"/ammo/edit/#{pack}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Edit pack of %{pack_count} bullets", pack_count: pack_count)
@ -168,7 +162,7 @@
</.link>
<.link
patch={Routes.pack_index_path(Endpoint, :clone, pack)}
patch={~p"/ammo/clone/#{pack}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Clone pack of %{pack_count} bullets",
@ -202,38 +196,38 @@
<%= case @live_action do %>
<% create when create in [:new, :edit, :clone] -> %>
<.modal return_to={Routes.pack_index_path(Endpoint, :index)}>
<.modal return_to={~p"/ammo"}>
<.live_component
module={CanneryWeb.PackLive.FormComponent}
id={@pack.id || :new}
title={@page_title}
action={@live_action}
pack={@pack}
return_to={Routes.pack_index_path(Endpoint, :index)}
return_to={~p"/ammo"}
current_user={@current_user}
/>
</.modal>
<% :add_shot_record -> %>
<.modal return_to={Routes.pack_index_path(Endpoint, :index)}>
<.modal return_to={~p"/ammo"}>
<.live_component
module={CanneryWeb.Components.AddShotRecordComponent}
id={:new}
title={@page_title}
action={@live_action}
pack={@pack}
return_to={Routes.pack_index_path(Endpoint, :index)}
return_to={~p"/ammo"}
current_user={@current_user}
/>
</.modal>
<% :move -> %>
<.modal return_to={Routes.pack_index_path(Endpoint, :index)}>
<.modal return_to={~p"/ammo"}>
<.live_component
module={CanneryWeb.Components.MovePackComponent}
id={@pack.id}
title={@page_title}
action={@live_action}
pack={@pack}
return_to={Routes.pack_index_path(Endpoint, :index)}
return_to={~p"/ammo"}
current_user={@current_user}
/>
</.modal>

View File

@ -7,7 +7,6 @@ defmodule CanneryWeb.PackLive.Show do
alias Cannery.{ActivityLog, ActivityLog.ShotRecord}
alias Cannery.{Ammo, Ammo.Pack}
alias Cannery.{ComparableDate, Containers}
alias CanneryWeb.Endpoint
alias Phoenix.LiveView.Socket
@impl true
@ -53,7 +52,7 @@ defmodule CanneryWeb.PackLive.Show do
pack |> Ammo.delete_pack!(current_user)
prompt = dgettext("prompts", "Ammo deleted succesfully")
redirect_to = Routes.pack_index_path(socket, :index)
redirect_to = ~p"/ammo"
{:noreply, socket |> put_flash(:info, prompt) |> push_navigate(to: redirect_to)}
end
@ -139,7 +138,7 @@ defmodule CanneryWeb.PackLive.Show do
~H"""
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
<.link
patch={Routes.pack_show_path(Endpoint, :edit_shot_record, @pack, @shot_record)}
patch={~p"/ammo/show/#{@pack}/edit/#{@shot_record}"}
class="text-primary-600 link"
aria-label={
dgettext("actions", "Edit shot record of %{shot_record_count} shots",

View File

@ -48,15 +48,12 @@
<div class="flex flex-col justify-center items-center">
<div class="flex flex-wrap justify-center items-center text-primary-600">
<.link
navigate={Routes.type_show_path(Endpoint, :show, @pack.type)}
class="mx-4 my-2 btn btn-primary"
>
<.link navigate={~p"/type/#{@pack.type}"} class="mx-4 my-2 btn btn-primary">
<%= dgettext("actions", "View in Catalog") %>
</.link>
<.link
patch={Routes.pack_show_path(Endpoint, :edit, @pack)}
patch={~p"/ammo/show/edit/#{@pack}"}
class="mx-4 my-2 text-primary-600 link"
aria-label={
dgettext("actions", "Edit pack of %{pack_count} bullets", pack_count: @pack.count)
@ -85,14 +82,11 @@
else: dgettext("actions", "Stage for range") %>
</button>
<.link patch={Routes.pack_show_path(Endpoint, :move, @pack)} class="btn btn-primary">
<.link patch={~p"/ammo/show/move/#{@pack}"} class="btn btn-primary">
<%= dgettext("actions", "Move ammo") %>
</.link>
<.link
patch={Routes.pack_show_path(Endpoint, :add_shot_record, @pack)}
class="mx-4 my-2 btn btn-primary"
>
<.link patch={~p"/ammo/show/add_shot_record/#{@pack}"} class="mx-4 my-2 btn btn-primary">
<%= dgettext("actions", "Record shots") %>
</.link>
</div>
@ -130,50 +124,50 @@
<%= case @live_action do %>
<% :edit -> %>
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
<.modal return_to={~p"/ammo/show/#{@pack}"}>
<.live_component
module={CanneryWeb.PackLive.FormComponent}
id={@pack.id}
title={@page_title}
action={@live_action}
pack={@pack}
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
return_to={~p"/ammo/show/#{@pack}"}
current_user={@current_user}
/>
</.modal>
<% :edit_shot_record -> %>
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
<.modal return_to={~p"/ammo/show/#{@pack}"}>
<.live_component
module={CanneryWeb.RangeLive.FormComponent}
id={@shot_record.id}
title={@page_title}
action={@live_action}
shot_record={@shot_record}
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
return_to={~p"/ammo/show/#{@pack}"}
current_user={@current_user}
/>
</.modal>
<% :add_shot_record -> %>
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
<.modal return_to={~p"/ammo/show/#{@pack}"}>
<.live_component
module={CanneryWeb.Components.AddShotRecordComponent}
id={:new}
title={@page_title}
action={@live_action}
pack={@pack}
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
return_to={~p"/ammo/show/#{@pack}"}
current_user={@current_user}
/>
</.modal>
<% :move -> %>
<.modal return_to={Routes.pack_show_path(Endpoint, :show, @pack)}>
<.modal return_to={~p"/ammo/show/#{@pack}"}>
<.live_component
module={CanneryWeb.Components.MovePackComponent}
id={@pack.id}
title={@page_title}
action={@live_action}
pack={@pack}
return_to={Routes.pack_show_path(Endpoint, :show, @pack)}
return_to={~p"/ammo/show/#{@pack}"}
current_user={@current_user}
/>
</.modal>