upgrade to phoenix 1.7
This commit is contained in:
		| @@ -105,12 +105,11 @@ defmodule CanneryWeb.ContainerLive.Index do | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do | ||||
|     {:noreply, socket |> push_patch(to: Routes.container_index_path(Endpoint, :index))} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/containers")} | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => search_term}}, socket) do | ||||
|     {:noreply, | ||||
|      socket |> push_patch(to: Routes.container_index_path(Endpoint, :search, search_term))} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/containers/search/#{search_term}")} | ||||
|   end | ||||
|  | ||||
|   defp display_containers(%{assigns: %{search: search, current_user: current_user}} = socket) do | ||||
|   | ||||
| @@ -9,11 +9,11 @@ | ||||
|       <%= display_emoji("😔") %> | ||||
|     </h2> | ||||
|  | ||||
|     <.link patch={Routes.container_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/containers/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Add your first container!") %> | ||||
|     </.link> | ||||
|   <% else %> | ||||
|     <.link patch={Routes.container_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/containers/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "New Container") %> | ||||
|     </.link> | ||||
|  | ||||
| @@ -59,7 +59,7 @@ | ||||
|           <:tag_actions :let={container}> | ||||
|             <div class="mx-4 my-2"> | ||||
|               <.link | ||||
|                 patch={Routes.container_index_path(Endpoint, :edit_tags, container)} | ||||
|                 patch={~p"/containers/edit_tags/#{container}"} | ||||
|                 class="text-primary-600 link" | ||||
|                 aria-label={ | ||||
|                   dgettext("actions", "Tag %{container_name}", container_name: container.name) | ||||
| @@ -71,7 +71,7 @@ | ||||
|           </:tag_actions> | ||||
|           <:actions :let={container}> | ||||
|             <.link | ||||
|               patch={Routes.container_index_path(Endpoint, :edit, container)} | ||||
|               patch={~p"/containers/edit/#{container}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={ | ||||
|                 dgettext("actions", "Edit %{container_name}", container_name: container.name) | ||||
| @@ -81,7 +81,7 @@ | ||||
|             </.link> | ||||
|  | ||||
|             <.link | ||||
|               patch={Routes.container_index_path(Endpoint, :clone, container)} | ||||
|               patch={~p"/containers/clone/#{container}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={ | ||||
|                 dgettext("actions", "Clone %{container_name}", container_name: container.name) | ||||
| @@ -118,7 +118,7 @@ | ||||
|             <:tag_actions> | ||||
|               <div class="mx-4 my-2"> | ||||
|                 <.link | ||||
|                   patch={Routes.container_index_path(Endpoint, :edit_tags, container)} | ||||
|                   patch={~p"/containers/edit_tags/#{container}"} | ||||
|                   class="text-primary-600 link" | ||||
|                   aria-label={ | ||||
|                     dgettext("actions", "Tag %{container_name}", container_name: container.name) | ||||
| @@ -129,7 +129,7 @@ | ||||
|               </div> | ||||
|             </:tag_actions> | ||||
|             <.link | ||||
|               patch={Routes.container_index_path(Endpoint, :edit, container)} | ||||
|               patch={~p"/containers/edit/#{container}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={ | ||||
|                 dgettext("actions", "Edit %{container_name}", container_name: container.name) | ||||
| @@ -139,7 +139,7 @@ | ||||
|             </.link> | ||||
|  | ||||
|             <.link | ||||
|               patch={Routes.container_index_path(Endpoint, :clone, container)} | ||||
|               patch={~p"/containers/clone/#{container}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={ | ||||
|                 dgettext("actions", "Clone %{container_name}", container_name: container.name) | ||||
| @@ -173,26 +173,26 @@ | ||||
|  | ||||
| <%= case @live_action do %> | ||||
|   <% modifying when modifying in [:new, :edit, :clone] -> %> | ||||
|     <.modal return_to={Routes.container_index_path(Endpoint, :index)}> | ||||
|     <.modal return_to={~p"/containers"}> | ||||
|       <.live_component | ||||
|         module={CanneryWeb.ContainerLive.FormComponent} | ||||
|         id={@container.id || :new} | ||||
|         title={@page_title} | ||||
|         action={@live_action} | ||||
|         container={@container} | ||||
|         return_to={Routes.container_index_path(Endpoint, :index)} | ||||
|         return_to={~p"/containers"} | ||||
|         current_user={@current_user} | ||||
|       /> | ||||
|     </.modal> | ||||
|   <% :edit_tags -> %> | ||||
|     <.modal return_to={Routes.container_index_path(Endpoint, :index)}> | ||||
|     <.modal return_to={~p"/containers"}> | ||||
|       <.live_component | ||||
|         module={CanneryWeb.ContainerLive.EditTagsComponent} | ||||
|         id={@container.id} | ||||
|         title={@page_title} | ||||
|         action={@live_action} | ||||
|         container={@container} | ||||
|         current_path={Routes.container_index_path(Endpoint, :edit_tags, @container)} | ||||
|         current_path={~p"/containers/edit_tags/#{@container}"} | ||||
|         current_user={@current_user} | ||||
|       /> | ||||
|     </.modal> | ||||
|   | ||||
| @@ -5,7 +5,6 @@ defmodule CanneryWeb.ContainerLive.Show do | ||||
|  | ||||
|   use CanneryWeb, :live_view | ||||
|   alias Cannery.{Accounts.User, ActivityLog, Ammo, Containers, Containers.Container} | ||||
|   alias CanneryWeb.Endpoint | ||||
|   alias Ecto.Changeset | ||||
|   alias Phoenix.LiveView.Socket | ||||
|  | ||||
| @@ -59,10 +58,7 @@ defmodule CanneryWeb.ContainerLive.Show do | ||||
|       |> case do | ||||
|         {:ok, %{name: container_name}} -> | ||||
|           prompt = dgettext("prompts", "%{name} has been deleted", name: container_name) | ||||
|  | ||||
|           socket | ||||
|           |> put_flash(:info, prompt) | ||||
|           |> push_navigate(to: Routes.container_index_path(socket, :index)) | ||||
|           socket |> put_flash(:info, prompt) |> push_navigate(to: ~p"/containers") | ||||
|  | ||||
|         {:error, %{action: :delete, errors: [packs: _error], valid?: false} = changeset} -> | ||||
|           packs_error = changeset |> changeset_errors(:packs) |> Enum.join(", ") | ||||
|   | ||||
| @@ -30,7 +30,7 @@ | ||||
|  | ||||
|   <div class="flex space-x-4 justify-center items-center text-primary-600"> | ||||
|     <.link | ||||
|       patch={Routes.container_show_path(Endpoint, :edit, @container)} | ||||
|       patch={~p"/container/edit/#{@container}"} | ||||
|       class="text-primary-600 link" | ||||
|       aria-label={dgettext("actions", "Edit %{container_name}", container_name: @container.name)} | ||||
|     > | ||||
| @@ -61,10 +61,7 @@ | ||||
|         <%= display_emoji("😔") %> | ||||
|       </h2> | ||||
|  | ||||
|       <.link | ||||
|         patch={Routes.container_show_path(Endpoint, :edit_tags, @container)} | ||||
|         class="btn btn-primary" | ||||
|       > | ||||
|       <.link patch={~p"/container/edit_tags/#{@container}"} class="btn btn-primary"> | ||||
|         <%= dgettext("actions", "Why not add one?") %> | ||||
|       </.link> | ||||
|     </div> | ||||
| @@ -73,10 +70,7 @@ | ||||
|       <.simple_tag_card :for={tag <- @container.tags} tag={tag} /> | ||||
|  | ||||
|       <div class="mx-4 my-2"> | ||||
|         <.link | ||||
|           patch={Routes.container_show_path(Endpoint, :edit_tags, @container)} | ||||
|           class="text-primary-600 link" | ||||
|         > | ||||
|         <.link patch={~p"/container/edit_tags/#{@container}"} class="text-primary-600 link"> | ||||
|           <i class="fa-fw fa-lg fas fa-tags"></i> | ||||
|         </.link> | ||||
|       </div> | ||||
| @@ -132,7 +126,7 @@ | ||||
|           show_used={false} | ||||
|         > | ||||
|           <: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> | ||||
| @@ -155,27 +149,27 @@ | ||||
|  | ||||
| <%= case @live_action do %> | ||||
|   <% :edit -> %> | ||||
|     <.modal return_to={Routes.container_show_path(Endpoint, :show, @container)}> | ||||
|     <.modal return_to={~p"/container/#{@container}"}> | ||||
|       <.live_component | ||||
|         module={CanneryWeb.ContainerLive.FormComponent} | ||||
|         id={@container.id} | ||||
|         title={@page_title} | ||||
|         action={@live_action} | ||||
|         container={@container} | ||||
|         return_to={Routes.container_show_path(Endpoint, :show, @container)} | ||||
|         return_to={~p"/container/#{@container}"} | ||||
|         current_user={@current_user} | ||||
|       /> | ||||
|     </.modal> | ||||
|   <% :edit_tags -> %> | ||||
|     <.modal return_to={Routes.container_show_path(Endpoint, :show, @container)}> | ||||
|     <.modal return_to={~p"/container/#{@container}"}> | ||||
|       <.live_component | ||||
|         module={CanneryWeb.ContainerLive.EditTagsComponent} | ||||
|         id={@container.id} | ||||
|         title={@page_title} | ||||
|         action={@live_action} | ||||
|         container={@container} | ||||
|         return_to={Routes.container_show_path(Endpoint, :show, @container)} | ||||
|         current_path={Routes.container_show_path(Endpoint, :edit_tags, @container)} | ||||
|         return_to={~p"/container/#{@container}"} | ||||
|         current_path={~p"/container/edit_tags/#{@container}"} | ||||
|         current_user={@current_user} | ||||
|       /> | ||||
|     </.modal> | ||||
|   | ||||
| @@ -5,7 +5,6 @@ defmodule CanneryWeb.HomeLive do | ||||
|  | ||||
|   use CanneryWeb, :live_view | ||||
|   alias Cannery.Accounts | ||||
|   alias CanneryWeb.Endpoint | ||||
|  | ||||
|   @version Mix.Project.config()[:version] | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| <div class="mx-auto px-8 sm:px-16 flex flex-col justify-center items-center text-center space-y-4 max-w-3xl"> | ||||
|   <img | ||||
|     src={Routes.static_path(Endpoint, "/images/cannery.svg")} | ||||
|     src={~p"/images/cannery.svg"} | ||||
|     alt={gettext("Cannery logo")} | ||||
|     class="inline-block w-32 hover:-mt-2 hover:mb-2 transition-all duration-500 ease-in-out" | ||||
|     title={gettext("isn't he cute >:3")} | ||||
| @@ -59,7 +59,7 @@ | ||||
|       </b> | ||||
|       <p> | ||||
|         <%= if @admins |> Enum.empty?() do %> | ||||
|           <.link href={Routes.user_registration_path(Endpoint, :new)} class="hover:underline"> | ||||
|           <.link href={~p"/users/register"} class="hover:underline"> | ||||
|             <%= dgettext("prompts", "Register to setup Cannery") %> | ||||
|           </.link> | ||||
|         <% else %> | ||||
|   | ||||
| @@ -9,11 +9,11 @@ | ||||
|       <%= display_emoji("😔") %> | ||||
|     </h1> | ||||
|  | ||||
|     <.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/invites/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Invite someone new!") %> | ||||
|     </.link> | ||||
|   <% else %> | ||||
|     <.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/invites/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Create Invite") %> | ||||
|     </.link> | ||||
|   <% end %> | ||||
| @@ -40,7 +40,7 @@ | ||||
|         </form> | ||||
|       </:code_actions> | ||||
|       <.link | ||||
|         patch={Routes.invite_index_path(Endpoint, :edit, invite)} | ||||
|         patch={~p"/invites/#{invite}/edit"} | ||||
|         class="text-primary-600 link" | ||||
|         aria-label={ | ||||
|           dgettext("actions", "Edit invite for %{invite_name}", invite_name: invite.name) | ||||
| @@ -149,14 +149,14 @@ | ||||
|   <% end %> | ||||
| </div> | ||||
|  | ||||
| <.modal :if={@live_action in [:new, :edit]} return_to={Routes.invite_index_path(Endpoint, :index)}> | ||||
| <.modal :if={@live_action in [:new, :edit]} return_to={~p"/invites"}> | ||||
|   <.live_component | ||||
|     module={CanneryWeb.InviteLive.FormComponent} | ||||
|     id={@invite.id || :new} | ||||
|     title={@page_title} | ||||
|     action={@live_action} | ||||
|     invite={@invite} | ||||
|     return_to={Routes.invite_index_path(Endpoint, :index)} | ||||
|     return_to={~p"/invites"} | ||||
|     current_user={@current_user} | ||||
|   /> | ||||
| </.modal> | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
| @@ -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> | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
| @@ -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> | ||||
|   | ||||
| @@ -5,7 +5,6 @@ defmodule CanneryWeb.RangeLive.Index do | ||||
|  | ||||
|   use CanneryWeb, :live_view | ||||
|   alias Cannery.{ActivityLog, ActivityLog.ShotRecord, Ammo} | ||||
|   alias CanneryWeb.Endpoint | ||||
|   alias Phoenix.LiveView.Socket | ||||
|  | ||||
|   @impl true | ||||
| @@ -94,11 +93,11 @@ defmodule CanneryWeb.RangeLive.Index do | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do | ||||
|     {:noreply, socket |> push_patch(to: Routes.range_index_path(Endpoint, :index))} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/range")} | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => search_term}}, socket) do | ||||
|     {:noreply, socket |> push_patch(to: Routes.range_index_path(Endpoint, :search, search_term))} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/range/search/#{search_term}")} | ||||
|   end | ||||
|  | ||||
|   def handle_event("change_class", %{"type" => %{"class" => "rifle"}}, socket) do | ||||
|   | ||||
| @@ -9,11 +9,11 @@ | ||||
|       <%= display_emoji("😔") %> | ||||
|     </h1> | ||||
|  | ||||
|     <.link navigate={Routes.pack_index_path(Endpoint, :index)} class="btn btn-primary"> | ||||
|     <.link navigate={~p"/ammo"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Why not get some ready to shoot?") %> | ||||
|     </.link> | ||||
|   <% else %> | ||||
|     <.link navigate={Routes.pack_index_path(Endpoint, :index)} class="btn btn-primary"> | ||||
|     <.link navigate={~p"/ammo"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Stage ammo") %> | ||||
|     </.link> | ||||
|  | ||||
| @@ -38,10 +38,7 @@ | ||||
|             else: dgettext("actions", "Stage for range") %> | ||||
|         </button> | ||||
|  | ||||
|         <.link | ||||
|           patch={Routes.range_index_path(Endpoint, :add_shot_record, pack)} | ||||
|           class="btn btn-primary" | ||||
|         > | ||||
|         <.link patch={~p"/range/add_shot_record/#{pack}"} class="btn btn-primary"> | ||||
|           <%= dgettext("actions", "Record shots") %> | ||||
|         </.link> | ||||
|       </.pack_card> | ||||
| @@ -132,7 +129,7 @@ | ||||
|         <:actions :let={shot_record}> | ||||
|           <div class="px-4 py-2 space-x-4 flex justify-center items-center"> | ||||
|             <.link | ||||
|               patch={Routes.range_index_path(Endpoint, :edit, shot_record)} | ||||
|               patch={~p"/range/edit/#{shot_record}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={ | ||||
|                 dgettext("actions", "Edit shot record of %{shot_record_count} shots", | ||||
| @@ -168,26 +165,26 @@ | ||||
|  | ||||
| <%= case @live_action do %> | ||||
|   <% :edit -> %> | ||||
|     <.modal return_to={Routes.range_index_path(Endpoint, :index)}> | ||||
|     <.modal return_to={~p"/range"}> | ||||
|       <.live_component | ||||
|         module={CanneryWeb.RangeLive.FormComponent} | ||||
|         id={@shot_record.id} | ||||
|         title={@page_title} | ||||
|         action={@live_action} | ||||
|         shot_record={@shot_record} | ||||
|         return_to={Routes.range_index_path(Endpoint, :index)} | ||||
|         return_to={~p"/range"} | ||||
|         current_user={@current_user} | ||||
|       /> | ||||
|     </.modal> | ||||
|   <% :add_shot_record -> %> | ||||
|     <.modal return_to={Routes.range_index_path(Endpoint, :index)}> | ||||
|     <.modal return_to={~p"/range"}> | ||||
|       <.live_component | ||||
|         module={CanneryWeb.Components.AddShotRecordComponent} | ||||
|         id={:new} | ||||
|         title={@page_title} | ||||
|         action={@live_action} | ||||
|         pack={@pack} | ||||
|         return_to={Routes.range_index_path(Endpoint, :index)} | ||||
|         return_to={~p"/range"} | ||||
|         current_user={@current_user} | ||||
|       /> | ||||
|     </.modal> | ||||
|   | ||||
| @@ -5,7 +5,7 @@ defmodule CanneryWeb.TagLive.Index do | ||||
|  | ||||
|   use CanneryWeb, :live_view | ||||
|   alias Cannery.{Containers, Containers.Tag} | ||||
|   alias CanneryWeb.ViewHelpers | ||||
|   alias CanneryWeb.HTMLHelpers | ||||
|  | ||||
|   @impl true | ||||
|   def mount(%{"search" => search}, _session, socket) do | ||||
| @@ -33,7 +33,7 @@ defmodule CanneryWeb.TagLive.Index do | ||||
|     socket | ||||
|     |> assign( | ||||
|       page_title: gettext("New Tag"), | ||||
|       tag: %Tag{bg_color: ViewHelpers.random_color(), text_color: "#ffffff"} | ||||
|       tag: %Tag{bg_color: HTMLHelpers.random_color(), text_color: "#ffffff"} | ||||
|     ) | ||||
|   end | ||||
|  | ||||
| @@ -67,11 +67,11 @@ defmodule CanneryWeb.TagLive.Index do | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do | ||||
|     {:noreply, socket |> push_patch(to: Routes.tag_index_path(Endpoint, :index))} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/tags")} | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => search_term}}, socket) do | ||||
|     {:noreply, socket |> push_patch(to: Routes.tag_index_path(Endpoint, :search, search_term))} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/tags/search/#{search_term}")} | ||||
|   end | ||||
|  | ||||
|   defp display_tags(%{assigns: %{search: search, current_user: current_user}} = socket) do | ||||
|   | ||||
| @@ -11,11 +11,11 @@ | ||||
|       <%= display_emoji("😔") %> | ||||
|     </h2> | ||||
|  | ||||
|     <.link patch={Routes.tag_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/tags/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Make your first tag!") %> | ||||
|     </.link> | ||||
|   <% else %> | ||||
|     <.link patch={Routes.tag_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/tags/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "New Tag") %> | ||||
|     </.link> | ||||
|  | ||||
| @@ -47,7 +47,7 @@ | ||||
|       <div class="flex flex-row flex-wrap justify-center items-stretch"> | ||||
|         <.tag_card :for={tag <- @tags} tag={tag}> | ||||
|           <.link | ||||
|             patch={Routes.tag_index_path(Endpoint, :edit, tag)} | ||||
|             patch={~p"/tags/edit/#{tag}"} | ||||
|             class="text-primary-600 link" | ||||
|             aria-label={dgettext("actions", "Edit %{tag_name}", tag_name: tag.name)} | ||||
|           > | ||||
| @@ -72,14 +72,14 @@ | ||||
|   <% end %> | ||||
| </div> | ||||
|  | ||||
| <.modal :if={@live_action in [:new, :edit]} return_to={Routes.tag_index_path(Endpoint, :index)}> | ||||
| <.modal :if={@live_action in [:new, :edit]} return_to={~p"/tags"}> | ||||
|   <.live_component | ||||
|     module={CanneryWeb.TagLive.FormComponent} | ||||
|     id={@tag.id || :new} | ||||
|     title={@page_title} | ||||
|     action={@live_action} | ||||
|     tag={@tag} | ||||
|     return_to={Routes.tag_index_path(Endpoint, :index)} | ||||
|     return_to={~p"/tags"} | ||||
|     current_user={@current_user} | ||||
|   /> | ||||
| </.modal> | ||||
|   | ||||
| @@ -78,12 +78,11 @@ defmodule CanneryWeb.TypeLive.Index do | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => ""}}, socket) do | ||||
|     {:noreply, socket |> push_patch(to: Routes.type_index_path(Endpoint, :index))} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/catalog")} | ||||
|   end | ||||
|  | ||||
|   def handle_event("search", %{"search" => %{"search_term" => search_term}}, socket) do | ||||
|     search_path = Routes.type_index_path(Endpoint, :search, search_term) | ||||
|     {:noreply, socket |> push_patch(to: search_path)} | ||||
|     {:noreply, socket |> push_patch(to: ~p"/catalog/search/#{search_term}")} | ||||
|   end | ||||
|  | ||||
|   def handle_event("change_class", %{"type" => %{"class" => "rifle"}}, socket) do | ||||
|   | ||||
| @@ -9,11 +9,11 @@ | ||||
|       <%= display_emoji("😔") %> | ||||
|     </h2> | ||||
|  | ||||
|     <.link patch={Routes.type_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/catalog/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "Add your first type!") %> | ||||
|     </.link> | ||||
|   <% else %> | ||||
|     <.link patch={Routes.type_index_path(Endpoint, :new)} class="btn btn-primary"> | ||||
|     <.link patch={~p"/catalog/new"} class="btn btn-primary"> | ||||
|       <%= dgettext("actions", "New Type") %> | ||||
|     </.link> | ||||
|  | ||||
| @@ -84,7 +84,7 @@ | ||||
|         <:actions :let={type}> | ||||
|           <div class="px-4 py-2 space-x-4 flex justify-center items-center"> | ||||
|             <.link | ||||
|               navigate={Routes.type_show_path(Endpoint, :show, type)} | ||||
|               navigate={~p"/type/#{type}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={dgettext("actions", "View %{type_name}", type_name: type.name)} | ||||
|             > | ||||
| @@ -92,7 +92,7 @@ | ||||
|             </.link> | ||||
|  | ||||
|             <.link | ||||
|               patch={Routes.type_index_path(Endpoint, :edit, type)} | ||||
|               patch={~p"/catalog/edit/#{type}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={dgettext("actions", "Edit %{type_name}", type_name: type.name)} | ||||
|             > | ||||
| @@ -100,7 +100,7 @@ | ||||
|             </.link> | ||||
|  | ||||
|             <.link | ||||
|               patch={Routes.type_index_path(Endpoint, :clone, type)} | ||||
|               patch={~p"/catalog/clone/#{type}"} | ||||
|               class="text-primary-600 link" | ||||
|               aria-label={dgettext("actions", "Clone %{type_name}", type_name: type.name)} | ||||
|             > | ||||
| @@ -130,17 +130,14 @@ | ||||
|   <% end %> | ||||
| </div> | ||||
|  | ||||
| <.modal | ||||
|   :if={@live_action in [:new, :edit, :clone]} | ||||
|   return_to={Routes.type_index_path(Endpoint, :index)} | ||||
| > | ||||
| <.modal :if={@live_action in [:new, :edit, :clone]} return_to={~p"/catalog"}> | ||||
|   <.live_component | ||||
|     module={CanneryWeb.TypeLive.FormComponent} | ||||
|     id={@type.id || :new} | ||||
|     title={@page_title} | ||||
|     action={@live_action} | ||||
|     type={@type} | ||||
|     return_to={Routes.type_index_path(Endpoint, :index)} | ||||
|     return_to={~p"/catalog"} | ||||
|     current_user={@current_user} | ||||
|     } | ||||
|   /> | ||||
|   | ||||
| @@ -5,7 +5,6 @@ defmodule CanneryWeb.TypeLive.Show do | ||||
|  | ||||
|   use CanneryWeb, :live_view | ||||
|   alias Cannery.{ActivityLog, Ammo, Ammo.Type, Containers} | ||||
|   alias CanneryWeb.Endpoint | ||||
|  | ||||
|   @impl true | ||||
|   def mount(_params, _session, socket), | ||||
| @@ -25,7 +24,7 @@ defmodule CanneryWeb.TypeLive.Show do | ||||
|     %{name: type_name} = type |> Ammo.delete_type!(current_user) | ||||
|  | ||||
|     prompt = dgettext("prompts", "%{name} deleted succesfully", name: type_name) | ||||
|     redirect_to = Routes.type_index_path(socket, :index) | ||||
|     redirect_to = ~p"/catalog" | ||||
|  | ||||
|     {:noreply, socket |> put_flash(:info, prompt) |> push_navigate(to: redirect_to)} | ||||
|   end | ||||
|   | ||||
| @@ -14,7 +14,7 @@ | ||||
|  | ||||
|   <div class="flex space-x-4 justify-center items-center text-primary-600"> | ||||
|     <.link | ||||
|       patch={Routes.type_show_path(Endpoint, :edit, @type)} | ||||
|       patch={~p"/type/#{@type}/edit"} | ||||
|       class="text-primary-600 link" | ||||
|       aria-label={dgettext("actions", "Edit %{type_name}", type_name: @type.name)} | ||||
|     > | ||||
| @@ -188,17 +188,14 @@ | ||||
|           show_used={@show_used} | ||||
|         > | ||||
|           <:container :let={{_pack, %{name: container_name} = container}}> | ||||
|             <.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> | ||||
|           </:container> | ||||
|           <: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) | ||||
| @@ -226,14 +223,14 @@ | ||||
|   </div> | ||||
| </div> | ||||
|  | ||||
| <.modal :if={@live_action == :edit} return_to={Routes.type_show_path(Endpoint, :show, @type)}> | ||||
| <.modal :if={@live_action == :edit} return_to={~p"/type/#{@type}"}> | ||||
|   <.live_component | ||||
|     module={CanneryWeb.TypeLive.FormComponent} | ||||
|     id={@type.id} | ||||
|     title={@page_title} | ||||
|     action={@live_action} | ||||
|     type={@type} | ||||
|     return_to={Routes.type_show_path(Endpoint, :show, @type)} | ||||
|     return_to={~p"/type/#{@type}"} | ||||
|     current_user={@current_user} | ||||
|   /> | ||||
| </.modal> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user