update to liveview 0.18 and use elixir 1.14

This commit is contained in:
2022-11-07 22:36:38 -05:00
parent 239b15a782
commit 6b565abf93
79 changed files with 2410 additions and 2321 deletions

View File

@ -54,7 +54,7 @@ defmodule CanneryWeb.Components.AddShotGroupComponent do
|> case do
{:ok, _shot_group} ->
prompt = dgettext("prompts", "Shots recorded successfully")
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
{:error, %Ecto.Changeset{} = changeset} ->
socket |> assign(changeset: changeset)

View File

@ -4,7 +4,7 @@
</h2>
<.form
let={f}
:let={f}
for={@changeset}
id="shot-group-form"
class="flex flex-col space-y-4 sm:space-y-0 sm:grid sm:grid-cols-3 sm:gap-4 justify-center items-center"

View File

@ -22,12 +22,11 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
border border-gray-400 rounded-lg shadow-lg hover:shadow-md
transition-all duration-300 ease-in-out"
>
<%= live_patch to: Routes.ammo_group_show_path(Endpoint, :show, @ammo_group),
class: "mb-2 link" do %>
<.link patch={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)} class="mb-2 link">
<h1 class="title text-xl title-primary-500">
<%= @ammo_group.ammo_type.name %>
</h1>
<% end %>
</.link>
<div class="flex flex-col justify-center items-center">
<span class="rounded-lg title text-lg">
@ -67,10 +66,12 @@ defmodule CanneryWeb.Components.AmmoGroupCard do
<span class="rounded-lg title text-lg">
<%= gettext("Container:") %>
<%= live_patch to: Routes.container_show_path(Endpoint, :show, @ammo_group.container),
class: "link" do %>
<.link
patch={Routes.container_show_path(Endpoint, :show, @ammo_group.container)}
class="link"
>
<%= @ammo_group.container.name %>
<% end %>
</.link>
</span>
<% end %>
</div>

View File

@ -19,12 +19,11 @@ defmodule CanneryWeb.Components.ContainerCard do
transition-all duration-300 ease-in-out"
>
<div class="max-w-full mb-4 flex flex-col justify-center items-center space-y-2">
<%= live_redirect to: Routes.container_show_path(Endpoint, :show, @container),
class: "link" do %>
<.link navigate={Routes.container_show_path(Endpoint, :show, @container)} class="link">
<h1 class="px-4 py-2 rounded-lg title text-xl">
<%= @container.name %>
</h1>
<% end %>
</.link>
<%= if @container.desc do %>
<span class="rounded-lg title text-lg">

View File

@ -52,7 +52,7 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do
{:ok, _ammo_group} ->
prompt = dgettext("prompts", "Ammo moved to %{name} successfully", name: container_name)
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
{:error, %Ecto.Changeset{} = changeset} ->
socket |> assign(changeset: changeset)
@ -86,10 +86,9 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do
<%= display_emoji("😔") %>
</h2>
<%= live_patch(dgettext("actions", "Add another container!"),
to: Routes.container_index_path(Endpoint, :new),
class: "btn btn-primary"
) %>
<.link patch={Routes.container_index_path(Endpoint, :new)} class="btn btn-primary">
<%= dgettext("actions", "Add another container!") %>
</.link>
<% else %>
<.live_component
module={CanneryWeb.Components.TableComponent}
@ -122,7 +121,7 @@ defmodule CanneryWeb.Components.MoveAmmoGroupComponent do
class="btn btn-primary"
phx-click="move"
phx-target={@myself}
phx-value-container_id={container.id}
phx-value-container_id={@container.id}
>
<%= dgettext("actions", "Select") %>
</button>

View File

@ -16,16 +16,17 @@ defmodule CanneryWeb.Components.Topbar do
<nav role="navigation" class="mb-8 px-8 py-4 w-full bg-primary-400">
<div class="flex flex-col sm:flex-row justify-between items-center">
<div class="mb-4 sm:mb-0 sm:mr-8 flex flex-row justify-start items-center space-x-2">
<%= live_redirect to: Routes.live_path(Endpoint, HomeLive),
class: "inline mx-2 my-1 leading-5 text-xl text-white"
do %>
<.link
patch={Routes.live_path(Endpoint, HomeLive)}
class="inline mx-2 my-1 leading-5 text-xl text-white"
>
<img
src={Routes.static_path(Endpoint, "/images/cannery.svg")}
alt={gettext("Cannery logo")}
class="inline-block h-8 mx-1"
/>
<h1 class="inline hover:underline">Cannery</h1>
<% end %>
</.link>
<%= if @title_content do %>
<span class="mx-2 my-1">
@ -41,78 +42,100 @@ defmodule CanneryWeb.Components.Topbar do
text-lg text-white text-ellipsis">
<%= if @current_user do %>
<li class="mx-2 my-1">
<%= live_redirect(gettext("Tags"),
to: Routes.tag_index_path(Endpoint, :index),
class: "text-primary-600 text-white hover:underline"
) %>
<.link
patch={Routes.tag_index_path(Endpoint, :index)}
class="text-primary-600 text-white hover:underline"
>
<%= gettext("Tags") %>
</.link>
</li>
<li class="mx-2 my-1">
<%= live_redirect(gettext("Containers"),
to: Routes.container_index_path(Endpoint, :index),
class: "text-primary-600 text-white hover:underline"
) %>
<.link
patch={Routes.container_index_path(Endpoint, :index)}
class="text-primary-600 text-white hover:underline"
>
<%= gettext("Containers") %>
</.link>
</li>
<li class="mx-2 my-1">
<%= live_redirect(gettext("Catalog"),
to: Routes.ammo_type_index_path(Endpoint, :index),
class: "text-primary-600 text-white hover:underline"
) %>
<.link
patch={Routes.ammo_type_index_path(Endpoint, :index)}
class="text-primary-600 text-white hover:underline"
>
<%= gettext("Catalog") %>
</.link>
</li>
<li class="mx-2 my-1">
<%= live_redirect(gettext("Ammo"),
to: Routes.ammo_group_index_path(Endpoint, :index),
class: "text-primary-600 text-white hover:underline"
) %>
<.link
patch={Routes.ammo_group_index_path(Endpoint, :index)}
class="text-primary-600 text-white hover:underline"
>
<%= gettext("Ammo") %>
</.link>
</li>
<li class="mx-2 my-1">
<%= live_redirect(gettext("Range"),
to: Routes.range_index_path(Endpoint, :index),
class: "text-primary-600 text-white hover:underline"
) %>
<.link
patch={Routes.range_index_path(Endpoint, :index)}
class="text-primary-600 text-white hover:underline"
>
<%= gettext("Range") %>
</.link>
</li>
<%= if @current_user.role == :admin do %>
<li class="mx-2 my-1">
<%= live_redirect(gettext("Invites"),
to: Routes.invite_index_path(Endpoint, :index),
class: "text-primary-600 text-white hover:underline"
) %>
<.link
patch={Routes.invite_index_path(Endpoint, :index)}
class="text-primary-600 text-white hover:underline"
>
<%= gettext("Invites") %>
</.link>
</li>
<% end %>
<li class="mx-2 my-1">
<%= live_redirect(@current_user.email,
to: Routes.user_settings_path(Endpoint, :edit),
class: "text-primary-600 text-white hover:underline truncate"
) %>
<.link
patch={Routes.user_settings_path(Endpoint, :edit)}
class="text-primary-600 text-white hover:underline truncate"
>
<%= @current_user.email %>
</.link>
</li>
<li class="mx-2 my-1">
<%= link to: Routes.user_session_path(Endpoint, :delete),
method: :delete,
data: [confirm: dgettext("prompts", "Are you sure you want to log out?")] do %>
<.link
href={Routes.user_session_path(Endpoint, :delete)}
method="delete"
data-confirm={dgettext("prompts", "Are you sure you want to log out?")}
>
<i class="fas fa-sign-out-alt"></i>
<% end %>
</.link>
</li>
<%= if @current_user.role == :admin and function_exported?(Routes, :live_dashboard_path, 2) do %>
<li class="mx-2 my-1">
<%= live_redirect to: Routes.live_dashboard_path(Endpoint, :home),
class: "text-primary-600 text-white hover:underline" do %>
<.link
patch={Routes.live_dashboard_path(Endpoint, :home)}
class="text-primary-600 text-white hover:underline"
>
<i class="fas fa-gauge"></i>
<% end %>
</.link>
</li>
<% end %>
<% else %>
<%= if Accounts.allow_registration?() do %>
<li class="mx-2 my-1">
<%= live_redirect(dgettext("actions", "Register"),
to: Routes.user_registration_path(Endpoint, :new),
class: "text-primary-600 text-white hover:underline truncate"
) %>
<.link
patch={Routes.user_registration_path(Endpoint, :new)}
class="text-primary-600 text-white hover:underline truncate"
>
<%= dgettext("actions", "Register") %>
</.link>
</li>
<% end %>
<li class="mx-2 my-1">
<%= live_redirect(dgettext("actions", "Log in"),
to: Routes.user_session_path(Endpoint, :new),
class: "text-primary-600 text-white hover:underline truncate"
) %>
<.link
patch={Routes.user_session_path(Endpoint, :new)}
class="text-primary-600 text-white hover:underline truncate"
>
<%= dgettext("actions", "Log in") %>
</.link>
</li>
<% end %>
</ul>