forked from shibao/cannery
update to liveview 0.18 and use elixir 1.14
This commit is contained in:
@ -116,7 +116,7 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do
|
||||
case Ammo.update_ammo_group(ammo_group, ammo_group_params, current_user) do
|
||||
{:ok, _ammo_group} ->
|
||||
prompt = dgettext("prompts", "Ammo updated successfully")
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(:changeset, changeset)
|
||||
@ -181,7 +181,7 @@ defmodule CanneryWeb.AmmoGroupLive.FormComponent do
|
||||
count
|
||||
)
|
||||
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(changeset: changeset)
|
||||
|
@ -4,7 +4,7 @@
|
||||
</h2>
|
||||
|
||||
<.form
|
||||
let={f}
|
||||
:let={f}
|
||||
for={@changeset}
|
||||
id="ammo_group-form"
|
||||
phx-target={@myself}
|
||||
|
@ -129,11 +129,14 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
|
||||
|
||||
@spec get_value_for_key(atom(), AmmoGroup.t()) :: any()
|
||||
defp get_value_for_key(:ammo_type, %{ammo_type: ammo_type}) do
|
||||
assigns = %{ammo_type: ammo_type}
|
||||
|
||||
{ammo_type.name,
|
||||
live_patch(ammo_type.name,
|
||||
to: Routes.ammo_type_show_path(Endpoint, :show, ammo_type),
|
||||
class: "link"
|
||||
)}
|
||||
~H"""
|
||||
<.link patch={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)} class="link">
|
||||
<%= @ammo_type.name %>
|
||||
</.link>
|
||||
"""}
|
||||
end
|
||||
|
||||
defp get_value_for_key(:price_paid, %{price_paid: nil}), do: {"a", nil}
|
||||
@ -175,15 +178,17 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
|
||||
type="button"
|
||||
class="mx-2 my-1 text-sm btn btn-primary"
|
||||
phx-click="toggle_staged"
|
||||
phx-value-ammo_group_id={ammo_group.id}
|
||||
phx-value-ammo_group_id={@ammo_group.id}
|
||||
>
|
||||
<%= if ammo_group.staged, do: gettext("Unstage"), else: gettext("Stage") %>
|
||||
<%= if @ammo_group.staged, do: gettext("Unstage"), else: gettext("Stage") %>
|
||||
</button>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Record shots"),
|
||||
to: Routes.ammo_group_index_path(Endpoint, :add_shot_group, ammo_group),
|
||||
class: "mx-2 my-1 text-sm btn btn-primary"
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_index_path(Endpoint, :add_shot_group, @ammo_group)}
|
||||
class="mx-2 my-1 text-sm btn btn-primary"
|
||||
>
|
||||
<%= dgettext("actions", "Record shots") %>
|
||||
</.link>
|
||||
</div>
|
||||
"""}
|
||||
end
|
||||
@ -196,28 +201,32 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
|
||||
|
||||
~H"""
|
||||
<div class="py-2 px-4 h-full space-x-4 flex justify-center items-center">
|
||||
<%= live_redirect to: Routes.ammo_group_show_path(Endpoint, :show, ammo_group),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "view-#{ammo_group.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_show_path(Endpoint, :show, @ammo_group)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"view-#{@ammo_group.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-eye"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= live_patch to: Routes.ammo_group_index_path(Endpoint, :edit, ammo_group),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{ammo_group.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_index_path(Endpoint, :edit, @ammo_group)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{@ammo_group.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: ammo_group.id,
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete this ammo?"),
|
||||
qa: "delete-#{ammo_group.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete"
|
||||
phx-value-id={@ammo_group.id}
|
||||
data-confirm={dgettext("prompts", "Are you sure you want to delete this ammo?")}
|
||||
data-qa={"delete-#{@ammo_group.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
@ -230,17 +239,19 @@ defmodule CanneryWeb.AmmoGroupLive.Index do
|
||||
{container_name,
|
||||
~H"""
|
||||
<div class="min-w-20 py-2 px-4 h-full flex flew-wrap justify-center items-center">
|
||||
<%= live_patch(
|
||||
@ammo_group.container.name,
|
||||
to: Routes.container_show_path(Endpoint, :show, @ammo_group.container),
|
||||
class: "mx-2 my-1 link"
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.container_show_path(Endpoint, :show, @ammo_group.container)}
|
||||
class="mx-2 my-1 link"
|
||||
>
|
||||
<%= @ammo_group.container.name %>
|
||||
</.link>
|
||||
|
||||
<%= live_patch(
|
||||
gettext("Move ammo"),
|
||||
to: Routes.ammo_group_index_path(Endpoint, :move, @ammo_group),
|
||||
class: "mx-2 my-1 text-sm btn btn-primary"
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_index_path(Endpoint, :move, @ammo_group)}
|
||||
class="mx-2 my-1 text-sm btn btn-primary"
|
||||
>
|
||||
<%= gettext("Move ammo") %>
|
||||
</.link>
|
||||
</div>
|
||||
"""}
|
||||
end
|
||||
|
@ -17,10 +17,9 @@
|
||||
<%= dgettext("prompts", "You'll need to") %>
|
||||
</h2>
|
||||
|
||||
<%= live_patch(dgettext("actions", "add a container first"),
|
||||
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 a container first") %>
|
||||
</.link>
|
||||
</div>
|
||||
<% @ammo_types_count == 0 -> %>
|
||||
<div class="flex justify-center items-center">
|
||||
@ -28,21 +27,18 @@
|
||||
<%= dgettext("prompts", "You'll need to") %>
|
||||
</h2>
|
||||
|
||||
<%= live_patch(dgettext("actions", "add an ammo type first"),
|
||||
to: Routes.ammo_type_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.ammo_type_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "add an ammo type first") %>
|
||||
</.link>
|
||||
</div>
|
||||
<% @ammo_groups |> Enum.empty?() -> %>
|
||||
<%= live_patch(dgettext("actions", "Add your first box!"),
|
||||
to: Routes.ammo_group_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.ammo_group_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Add your first box!") %>
|
||||
</.link>
|
||||
<% true -> %>
|
||||
<%= live_patch(dgettext("actions", "Add Ammo"),
|
||||
to: Routes.ammo_group_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.ammo_group_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Add Ammo") %>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
||||
<%= unless @ammo_groups |> Enum.empty?() do %>
|
||||
|
@ -50,7 +50,7 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
|
||||
prompt = dgettext("prompts", "Ammo deleted succesfully")
|
||||
redirect_to = Routes.ammo_group_index_path(socket, :index)
|
||||
|
||||
{:noreply, socket |> put_flash(:info, prompt) |> push_redirect(to: redirect_to)}
|
||||
{:noreply, socket |> put_flash(:info, prompt) |> push_navigate(to: redirect_to)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@ -116,22 +116,24 @@ defmodule CanneryWeb.AmmoGroupLive.Show do
|
||||
:actions ->
|
||||
~H"""
|
||||
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
||||
<%= live_patch to: Routes.ammo_group_show_path(Endpoint, :edit_shot_group, @ammo_group, shot_group),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{shot_group.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_show_path(Endpoint, :edit_shot_group, @ammo_group, @shot_group)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{@shot_group.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_shot_group",
|
||||
phx_value_id: shot_group.id,
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete this shot record?"),
|
||||
qa: "delete-#{shot_group.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_shot_group"
|
||||
phx-value-id={@shot_group.id}
|
||||
data-confirm={dgettext("prompts", "Are you sure you want to delete this shot record?")}
|
||||
data-qa={"delete-#{@shot_group.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
"""
|
||||
|
||||
|
@ -52,27 +52,31 @@
|
||||
|
||||
<div class="flex flex-col justify-center items-center">
|
||||
<div class="flex flex-wrap justify-center items-center text-primary-600">
|
||||
<%= live_patch(dgettext("actions", "View in Catalog"),
|
||||
to: Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type),
|
||||
class: "mx-4 my-2 btn btn-primary",
|
||||
data: [qa: "details"]
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.ammo_type_show_path(Endpoint, :show, @ammo_group.ammo_type)}
|
||||
class="mx-4 my-2 btn btn-primary"
|
||||
data-qa="details"
|
||||
>
|
||||
<%= dgettext("actions", "View in Catalog") %>
|
||||
</.link>
|
||||
|
||||
<%= live_patch to: Routes.ammo_group_show_path(Endpoint, :edit, @ammo_group),
|
||||
class: "mx-4 my-2 text-primary-600 link",
|
||||
data: [qa: "edit"] do %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_show_path(Endpoint, :edit, @ammo_group)}
|
||||
class="mx-4 my-2 text-primary-600 link"
|
||||
data-qa="edit"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "mx-4 my-2 text-primary-600 link",
|
||||
phx_click: "delete",
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete this ammo?"),
|
||||
qa: "delete"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="mx-4 my-2 text-primary-600 link"
|
||||
phx-click="delete"
|
||||
data-confirm={dgettext("prompts", "Are you sure you want to delete this ammo?")}
|
||||
data-qa="delete"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap justify-center items-center text-primary-600">
|
||||
@ -82,16 +86,20 @@
|
||||
else: gettext("Stage for range") %>
|
||||
</button>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Move containers"),
|
||||
to: Routes.ammo_group_show_path(Endpoint, :move, @ammo_group),
|
||||
class: "btn btn-primary",
|
||||
data: [qa: "move"]
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_show_path(Endpoint, :move, @ammo_group)}
|
||||
class="btn btn-primary"
|
||||
data-qa="move"
|
||||
>
|
||||
<%= dgettext("actions", "Move containers") %>
|
||||
</.link>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Record shots"),
|
||||
to: Routes.ammo_group_show_path(Endpoint, :add_shot_group, @ammo_group),
|
||||
class: "mx-4 my-2 btn btn-primary"
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.ammo_group_show_path(Endpoint, :add_shot_group, @ammo_group)}
|
||||
class="mx-4 my-2 btn btn-primary"
|
||||
>
|
||||
<%= dgettext("actions", "Record shots") %>
|
||||
</.link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -65,7 +65,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do
|
||||
case Ammo.update_ammo_type(ammo_type, ammo_type_params, current_user) do
|
||||
{:ok, %{name: ammo_type_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} updated successfully", name: ammo_type_name)
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(:changeset, changeset)
|
||||
@ -83,7 +83,7 @@ defmodule CanneryWeb.AmmoTypeLive.FormComponent do
|
||||
case Ammo.create_ammo_type(ammo_type_params, current_user) do
|
||||
{:ok, %{name: ammo_type_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} created successfully", name: ammo_type_name)
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(changeset: changeset)
|
||||
|
@ -3,7 +3,7 @@
|
||||
<%= @title %>
|
||||
</h2>
|
||||
<.form
|
||||
let={f}
|
||||
:let={f}
|
||||
for={@changeset}
|
||||
id="ammo_type-form"
|
||||
phx-target={@myself}
|
||||
|
@ -123,11 +123,13 @@ defmodule CanneryWeb.AmmoTypeLive.Index do
|
||||
assigns = %{ammo_type: ammo_type}
|
||||
|
||||
~H"""
|
||||
<%= live_redirect to: Routes.ammo_type_show_path(Endpoint, :show, ammo_type),
|
||||
class: "link",
|
||||
data: [qa: "view-name-#{ammo_type.id}"] do %>
|
||||
<%= ammo_type.name %>
|
||||
<% end %>
|
||||
<.link
|
||||
patch={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}
|
||||
class="link"
|
||||
data-qa={"view-name-#{@ammo_type.id}"}
|
||||
>
|
||||
<%= @ammo_type.name %>
|
||||
</.link>
|
||||
"""
|
||||
end
|
||||
|
||||
@ -136,28 +138,38 @@ defmodule CanneryWeb.AmmoTypeLive.Index do
|
||||
|
||||
~H"""
|
||||
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
||||
<%= live_redirect to: Routes.ammo_type_show_path(Endpoint, :show, ammo_type),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "view-#{ammo_type.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.ammo_type_show_path(Endpoint, :show, @ammo_type)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"view-#{@ammo_type.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-eye"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= live_patch to: Routes.ammo_type_index_path(Endpoint, :edit, ammo_type),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{ammo_type.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.ammo_type_index_path(Endpoint, :edit, @ammo_type)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{@ammo_type.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: ammo_type.id,
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!", name: ammo_type.name),
|
||||
qa: "delete-#{ammo_type.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete"
|
||||
phx-value-id={@ammo_type.id}
|
||||
data-confirm={
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!",
|
||||
name: @ammo_type.name
|
||||
)
|
||||
}
|
||||
data-qa={"delete-#{@ammo_type.id}"}
|
||||
>
|
||||
<i class="fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
@ -9,15 +9,13 @@
|
||||
<%= display_emoji("😔") %>
|
||||
</h2>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Add your first type!"),
|
||||
to: Routes.ammo_type_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.ammo_type_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Add your first type!") %>
|
||||
</.link>
|
||||
<% else %>
|
||||
<%= live_patch(dgettext("actions", "New Ammo type"),
|
||||
to: Routes.ammo_type_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.ammo_type_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "New Ammo type") %>
|
||||
</.link>
|
||||
|
||||
<.live_component
|
||||
module={CanneryWeb.Components.TableComponent}
|
||||
|
@ -28,7 +28,7 @@ defmodule CanneryWeb.AmmoTypeLive.Show do
|
||||
prompt = dgettext("prompts", "%{name} deleted succesfully", name: ammo_type_name)
|
||||
redirect_to = Routes.ammo_type_index_path(socket, :index)
|
||||
|
||||
{:noreply, socket |> put_flash(:info, prompt) |> push_redirect(to: redirect_to)}
|
||||
{:noreply, socket |> put_flash(:info, prompt) |> push_navigate(to: redirect_to)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
@ -12,22 +12,29 @@
|
||||
<% end %>
|
||||
|
||||
<div class="flex space-x-4 justify-center items-center text-primary-600">
|
||||
<%= live_patch to: Routes.ammo_type_show_path(Endpoint, :edit, @ammo_type),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit"] do %>
|
||||
<.link
|
||||
patch={Routes.ammo_type_show_path(Endpoint, :edit, @ammo_type)}
|
||||
class="text-primary-600 link"
|
||||
data-qa="edit"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete",
|
||||
data: [
|
||||
confirm:
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!", name: @ammo_type.name),
|
||||
qa: "delete"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete"
|
||||
data-confirm={
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{name}? This will delete all %{name} type ammo as well!",
|
||||
name: @ammo_type.name
|
||||
)
|
||||
}
|
||||
data-qa="delete"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
|
||||
<hr class="hr" />
|
||||
|
@ -5,24 +5,25 @@
|
||||
|
||||
<div class="flex flex-wrap justify-center items-center">
|
||||
<%= for tag <- @container.tags do %>
|
||||
<%= link to: "#",
|
||||
class: "mx-2 my-1 px-4 py-2 rounded-lg title text-xl",
|
||||
style: "color: #{tag.text_color}; background-color: #{tag.bg_color}",
|
||||
phx_click: "delete",
|
||||
phx_value_tag_id: tag.id,
|
||||
phx_target: @myself,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to remove the %{tag_name} tag from %{container_name}?",
|
||||
tag_name: tag.name,
|
||||
container_name: @container.name
|
||||
)
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="mx-2 my-1 px-4 py-2 rounded-lg title text-xl"
|
||||
style={"color: #{tag.text_color}; background-color: #{tag.bg_color}"}
|
||||
phx-click="delete"
|
||||
phx-value-tag-id={tag.id}
|
||||
phx-target={@myself}
|
||||
data-confirm={
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to remove the %{tag_name} tag from %{container_name}?",
|
||||
tag_name: tag.name,
|
||||
container_name: @container.name
|
||||
)
|
||||
}
|
||||
>
|
||||
<%= tag.name %>
|
||||
<i class="fa-fw fa-sm fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
||||
<%= if @container.tags |> Enum.empty?() do %>
|
||||
@ -37,7 +38,7 @@
|
||||
<hr class="hr" />
|
||||
|
||||
<.form
|
||||
let={f}
|
||||
:let={f}
|
||||
for={:tag}
|
||||
id="add-tag-to-container-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"
|
||||
|
@ -65,7 +65,7 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
|
||||
case Containers.update_container(container, current_user, container_params) do
|
||||
{:ok, %{name: container_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} updated 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, %Changeset{} = changeset} ->
|
||||
socket |> assign(:changeset, changeset)
|
||||
@ -83,7 +83,7 @@ defmodule CanneryWeb.ContainerLive.FormComponent do
|
||||
case Containers.create_container(container_params, current_user) do
|
||||
{:ok, %{name: container_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} created 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, %Changeset{} = changeset} ->
|
||||
socket |> assign(changeset: changeset)
|
||||
|
@ -3,7 +3,7 @@
|
||||
<%= @title %>
|
||||
</h2>
|
||||
<.form
|
||||
let={f}
|
||||
:let={f}
|
||||
for={@changeset}
|
||||
id="container-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"
|
||||
|
@ -9,15 +9,13 @@
|
||||
<%= display_emoji("😔") %>
|
||||
</h2>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Add your first 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 your first container!") %>
|
||||
</.link>
|
||||
<% else %>
|
||||
<%= live_patch(dgettext("actions", "New 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", "New Container") %>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
||||
<div class="max-w-full flex flex-row flex-wrap justify-center items-center">
|
||||
@ -25,29 +23,34 @@
|
||||
<.container_card container={container}>
|
||||
<:tag_actions>
|
||||
<div class="mx-4 my-2">
|
||||
<%= live_patch to: Routes.container_index_path(Endpoint, :edit_tags, container),
|
||||
class: "text-primary-600 link" do %>
|
||||
<.link
|
||||
patch={Routes.container_index_path(Endpoint, :edit_tags, container)}
|
||||
class="text-primary-600 link"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-tags"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
</:tag_actions>
|
||||
<%= live_patch to: Routes.container_index_path(Endpoint, :edit, container),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{container.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.container_index_path(Endpoint, :edit, container)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{container.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: container.id,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}?", name: container.name),
|
||||
qa: "delete-#{container.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete"
|
||||
phx-value-id={container.id}
|
||||
data-confirm={
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}?", name: container.name)
|
||||
}
|
||||
data-qa={"delete-#{container.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</.container_card>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -62,7 +62,7 @@ defmodule CanneryWeb.ContainerLive.Show do
|
||||
|
||||
socket
|
||||
|> put_flash(:info, prompt)
|
||||
|> push_redirect(to: Routes.container_index_path(socket, :index))
|
||||
|> push_navigate(to: Routes.container_index_path(socket, :index))
|
||||
|
||||
{:error, %{action: :delete, errors: [ammo_groups: _error], valid?: false} = changeset} ->
|
||||
ammo_groups_error = changeset |> changeset_errors(:ammo_groups) |> Enum.join(", ")
|
||||
|
@ -35,22 +35,25 @@
|
||||
<% end %>
|
||||
|
||||
<div class="flex space-x-4 justify-center items-center text-primary-600">
|
||||
<%= live_patch to: Routes.container_show_path(Endpoint, :edit, @container),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit"] do %>
|
||||
<.link
|
||||
patch={Routes.container_show_path(Endpoint, :edit, @container)}
|
||||
class="text-primary-600 link"
|
||||
data-qa="edit"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_container",
|
||||
data: [
|
||||
confirm:
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}?", name: @container.name),
|
||||
qa: "delete"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_container"
|
||||
data-confirm={
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}?", name: @container.name)
|
||||
}
|
||||
data-qa="delete"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
|
||||
<hr class="mb-4 hr" />
|
||||
@ -62,10 +65,12 @@
|
||||
<%= display_emoji("😔") %>
|
||||
</h2>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Why not add one?"),
|
||||
to: Routes.container_show_path(Endpoint, :edit_tags, @container),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.container_show_path(Endpoint, :edit_tags, @container)}
|
||||
class="btn btn-primary"
|
||||
>
|
||||
<%= dgettext("actions", "Why not add one?") %>
|
||||
</.link>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="flex flex-wrap justify-center items-center">
|
||||
@ -74,10 +79,12 @@
|
||||
<% end %>
|
||||
|
||||
<div class="mx-4 my-2">
|
||||
<%= live_patch to: Routes.container_show_path(Endpoint, :edit_tags, @container),
|
||||
class: "text-primary-600 link" do %>
|
||||
<.link
|
||||
patch={Routes.container_show_path(Endpoint, :edit_tags, @container)}
|
||||
class="text-primary-600 link"
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-tags"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
@ -101,10 +101,12 @@ defmodule CanneryWeb.HomeLive do
|
||||
</b>
|
||||
<p>
|
||||
<%= if @admins |> Enum.empty?() do %>
|
||||
<%= link(dgettext("prompts", "Register to setup %{name}", name: "Cannery"),
|
||||
class: "hover:underline",
|
||||
to: Routes.user_registration_path(CanneryWeb.Endpoint, :new)
|
||||
) %>
|
||||
<.link
|
||||
href={Routes.user_registration_path(CanneryWeb.Endpoint, :new)}
|
||||
class="hover:underline"
|
||||
>
|
||||
<%= dgettext("prompts", "Register to setup %{name}", name: "Cannery") %>
|
||||
</.link>
|
||||
<% else %>
|
||||
<div class="flex flex-wrap justify-center space-x-2">
|
||||
<%= for admin <- @admins do %>
|
||||
@ -130,13 +132,15 @@ defmodule CanneryWeb.HomeLive do
|
||||
|
||||
<li class="flex flex-row justify-center items-center space-x-2">
|
||||
<b>Version:</b>
|
||||
<%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline",
|
||||
to: "https://gitea.bubbletea.dev/shibao/cannery/src/branch/stable/CHANGELOG.md",
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer" do %>
|
||||
<.link
|
||||
href="https://gitea.bubbletea.dev/shibao/cannery/src/branch/stable/CHANGELOG.md"
|
||||
class="flex flex-row justify-center items-center space-x-2 hover:underline"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<p>0.5.5</p>
|
||||
<i class="fas fa-md fa-info-circle"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -148,31 +152,37 @@ defmodule CanneryWeb.HomeLive do
|
||||
</h2>
|
||||
|
||||
<li class="flex flex-col justify-center space-x-2">
|
||||
<%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline",
|
||||
to: "https://gitea.bubbletea.dev/shibao/cannery",
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer" do %>
|
||||
<.link
|
||||
class="flex flex-row justify-center items-center space-x-2 hover:underline"
|
||||
href="https://gitea.bubbletea.dev/shibao/cannery"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<p><%= gettext("View the source code") %></p>
|
||||
<i class="fas fa-md fa-code"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</li>
|
||||
<li class="flex flex-col justify-center space-x-2">
|
||||
<%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline",
|
||||
to: "https://weblate.bubbletea.dev/engage/cannery",
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer" do %>
|
||||
<.link
|
||||
class="flex flex-row justify-center items-center space-x-2 hover:underline"
|
||||
href="https://weblate.bubbletea.dev/engage/cannery"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<p><%= gettext("Help translate") %></p>
|
||||
<i class="fas fa-md fa-language"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</li>
|
||||
<li class="flex flex-col justify-center space-x-2">
|
||||
<%= link class: "flex flex-row justify-center items-center space-x-2 hover:underline",
|
||||
to: "https://gitea.bubbletea.dev/shibao/cannery/issues/new",
|
||||
target: "_blank",
|
||||
rel: "noopener noreferrer" do %>
|
||||
<.link
|
||||
class="flex flex-row justify-center items-center space-x-2 hover:underline"
|
||||
href="https://gitea.bubbletea.dev/shibao/cannery/issues/new"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<p><%= gettext("Report bugs or request features") %></p>
|
||||
<i class="fas fa-md fa-spider"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -2,7 +2,7 @@ defmodule CanneryWeb.InitAssigns do
|
||||
@moduledoc """
|
||||
Ensures common `assigns` are applied to all LiveViews attaching this hook.
|
||||
"""
|
||||
import Phoenix.LiveView
|
||||
import Phoenix.Component
|
||||
alias Cannery.Accounts
|
||||
|
||||
def on_mount(:default, _params, %{"locale" => locale, "user_token" => user_token}, socket) do
|
||||
|
@ -60,7 +60,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
|
||||
case invite |> Invites.update_invite(invite_params, current_user) do
|
||||
{:ok, %{name: invite_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} updated successfully", name: invite_name)
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(:changeset, changeset)
|
||||
@ -78,7 +78,7 @@ defmodule CanneryWeb.InviteLive.FormComponent do
|
||||
case current_user |> Invites.create_invite(invite_params) do
|
||||
{:ok, %{name: invite_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} created successfully", name: invite_name)
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(changeset: changeset)
|
||||
|
@ -3,7 +3,7 @@
|
||||
<%= @title %>
|
||||
</h2>
|
||||
<.form
|
||||
let={f}
|
||||
:let={f}
|
||||
for={@changeset}
|
||||
id="invite-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"
|
||||
|
@ -17,7 +17,7 @@ defmodule CanneryWeb.InviteLive.Index do
|
||||
else
|
||||
prompt = dgettext("errors", "You are not authorized to view this page")
|
||||
return_to = Routes.live_path(Endpoint, HomeLive)
|
||||
socket |> put_flash(:error, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:error, prompt) |> push_navigate(to: return_to)
|
||||
end
|
||||
|
||||
{:ok, socket}
|
||||
|
@ -9,15 +9,13 @@
|
||||
<%= display_emoji("😔") %>
|
||||
</h1>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Invite someone new!"),
|
||||
to: Routes.invite_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Invite someone new!") %>
|
||||
</.link>
|
||||
<% else %>
|
||||
<%= live_patch(dgettext("actions", "Create Invite"),
|
||||
to: Routes.invite_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.invite_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Create Invite") %>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
||||
<div class="w-full flex flex-row flex-wrap justify-center items-center">
|
||||
@ -34,25 +32,28 @@
|
||||
</button>
|
||||
</form>
|
||||
</:code_actions>
|
||||
<%= live_patch to: Routes.invite_index_path(Endpoint, :edit, invite),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{invite.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.invite_index_path(Endpoint, :edit, invite)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{invite.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_invite",
|
||||
phx_value_id: invite.id,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext("prompts", "Are you sure you want to delete the invite for %{name}?",
|
||||
name: invite.name
|
||||
),
|
||||
qa: "delete-#{invite.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_invite"
|
||||
phx-value-id={invite.id}
|
||||
data-confirm={
|
||||
dgettext("prompts", "Are you sure you want to delete the invite for %{name}?",
|
||||
name: invite.name
|
||||
)
|
||||
}
|
||||
data-qa={"delete-#{invite.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= if invite.disabled_at |> is_nil() do %>
|
||||
<a href="#" class="btn btn-primary" phx-click="disable_invite" phx-value-id={invite.id}>
|
||||
@ -93,20 +94,21 @@
|
||||
<div class="w-full flex flex-row flex-wrap justify-center items-center">
|
||||
<%= for admin <- @admins do %>
|
||||
<.user_card user={admin}>
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_user",
|
||||
phx_value_id: admin.id,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: admin.email
|
||||
)
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_user"
|
||||
phx-value-id={admin.id}
|
||||
data-confirm={
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: admin.email
|
||||
)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</.user_card>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -122,20 +124,21 @@
|
||||
<div class="w-full flex flex-row flex-wrap justify-center items-center">
|
||||
<%= for user <- @users do %>
|
||||
<.user_card user={user}>
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete_user",
|
||||
phx_value_id: user.id,
|
||||
data: [
|
||||
confirm:
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: user.email
|
||||
)
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete_user"
|
||||
phx-value-id={user.id}
|
||||
data-confirm={
|
||||
dgettext(
|
||||
"prompts",
|
||||
"Are you sure you want to delete %{email}? This action is permanent!",
|
||||
email: user.email
|
||||
)
|
||||
}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</.user_card>
|
||||
<% end %>
|
||||
</div>
|
||||
|
@ -3,7 +3,7 @@ defmodule CanneryWeb.LiveHelpers do
|
||||
Contains common helper functions for liveviews
|
||||
"""
|
||||
|
||||
import Phoenix.LiveView.Helpers
|
||||
import Phoenix.Component
|
||||
alias Phoenix.LiveView.JS
|
||||
|
||||
@doc """
|
||||
@ -27,17 +27,17 @@ defmodule CanneryWeb.LiveHelpers do
|
||||
"""
|
||||
def modal(assigns) do
|
||||
~H"""
|
||||
<%= live_patch to: @return_to,
|
||||
id: "modal-bg",
|
||||
class:
|
||||
"fade-in fixed z-10 left-0 top-0
|
||||
<.link
|
||||
patch={@return_to}
|
||||
id="modal-bg"
|
||||
class="fade-in fixed z-10 left-0 top-0
|
||||
w-full h-full overflow-hidden
|
||||
p-8 flex flex-col justify-center items-center cursor-auto",
|
||||
style: "background-color: rgba(0,0,0,0.4);",
|
||||
phx_remove: hide_modal()
|
||||
do %>
|
||||
p-8 flex flex-col justify-center items-center cursor-auto"
|
||||
style="background-color: rgba(0,0,0,0.4);"
|
||||
phx_remove={hide_modal()}
|
||||
>
|
||||
<span class="hidden"></span>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<div
|
||||
id="modal"
|
||||
@ -53,15 +53,16 @@ defmodule CanneryWeb.LiveHelpers do
|
||||
flex flex-col justify-start items-center
|
||||
bg-white border-2 rounded-lg"
|
||||
>
|
||||
<%= live_patch to: @return_to,
|
||||
id: "close",
|
||||
class:
|
||||
"absolute top-8 right-10
|
||||
<.link
|
||||
patch={@return_to}
|
||||
id="close"
|
||||
class="absolute top-8 right-10
|
||||
text-gray-500 hover:text-gray-800
|
||||
transition-all duration-500 ease-in-out",
|
||||
phx_remove: hide_modal() do %>
|
||||
transition-all duration-500 ease-in-out"
|
||||
phx_remove={hide_modal()}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-times"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<div class="overflow-x-hidden overflow-y-auto w-full p-8 flex flex-col space-y-4 justify-start items-center">
|
||||
<%= render_slot(@inner_block) %>
|
||||
|
@ -53,7 +53,7 @@ defmodule CanneryWeb.RangeLive.FormComponent do
|
||||
case ActivityLog.update_shot_group(shot_group, shot_group_params, current_user) do
|
||||
{:ok, _shot_group} ->
|
||||
prompt = dgettext("prompts", "Shot records updated 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)
|
||||
|
@ -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"
|
||||
|
@ -103,10 +103,11 @@ defmodule CanneryWeb.RangeLive.Index do
|
||||
case key do
|
||||
:name ->
|
||||
{shot_group.ammo_group.ammo_type.name,
|
||||
live_patch(shot_group.ammo_group.ammo_type.name,
|
||||
to: Routes.ammo_group_show_path(Endpoint, :show, shot_group.ammo_group),
|
||||
class: "link"
|
||||
)}
|
||||
~H"""
|
||||
<.link patch={Routes.ammo_group_show_path(Endpoint, :show, @shot_group.ammo_group)} class="link">
|
||||
<%= @shot_group.ammo_group.ammo_type.name %>
|
||||
</.link>
|
||||
"""}
|
||||
|
||||
:date ->
|
||||
date |> display_date()
|
||||
@ -114,22 +115,24 @@ defmodule CanneryWeb.RangeLive.Index do
|
||||
:actions ->
|
||||
~H"""
|
||||
<div class="px-4 py-2 space-x-4 flex justify-center items-center">
|
||||
<%= live_patch to: Routes.range_index_path(Endpoint, :edit, shot_group),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{shot_group.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.range_index_path(Endpoint, :edit, @shot_group)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{@shot_group.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: shot_group.id,
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete this shot record?"),
|
||||
qa: "delete-#{shot_group.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete"
|
||||
phx-value-id={@shot_group.id}
|
||||
data-confirm={dgettext("prompts", "Are you sure you want to delete this shot record?")}
|
||||
data-qa={"delete-#{@shot_group.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</div>
|
||||
"""
|
||||
|
||||
|
@ -9,15 +9,13 @@
|
||||
<%= display_emoji("😔") %>
|
||||
</h1>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Why not get some ready to shoot?"),
|
||||
to: Routes.ammo_group_index_path(Endpoint, :index),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.ammo_group_index_path(Endpoint, :index)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Why not get some ready to shoot?") %>
|
||||
</.link>
|
||||
<% else %>
|
||||
<%= live_patch(dgettext("actions", "Stage ammo"),
|
||||
to: Routes.ammo_group_index_path(Endpoint, :index),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.ammo_group_index_path(Endpoint, :index)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Stage ammo") %>
|
||||
</.link>
|
||||
|
||||
<%= for ammo_group <- @ammo_groups do %>
|
||||
<.ammo_group_card ammo_group={ammo_group}>
|
||||
@ -33,10 +31,12 @@
|
||||
else: gettext("Stage for range") %>
|
||||
</button>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Record shots"),
|
||||
to: Routes.range_index_path(Endpoint, :add_shot_group, ammo_group),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link
|
||||
patch={Routes.range_index_path(Endpoint, :add_shot_group, ammo_group)}
|
||||
class="btn btn-primary"
|
||||
>
|
||||
<%= dgettext("actions", "Record shots") %>
|
||||
</.link>
|
||||
</.ammo_group_card>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -58,7 +58,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
|
||||
<%= @title %>
|
||||
</h2>
|
||||
<.form
|
||||
let={f}
|
||||
:let={f}
|
||||
for={@changeset}
|
||||
id="tag-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"
|
||||
@ -106,7 +106,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
|
||||
case Tags.update_tag(tag, tag_params, current_user) do
|
||||
{:ok, %{name: tag_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} updated successfully", name: tag_name)
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(:changeset, changeset)
|
||||
@ -124,7 +124,7 @@ defmodule CanneryWeb.TagLive.FormComponent do
|
||||
case Tags.create_tag(tag_params, current_user) do
|
||||
{:ok, %{name: tag_name}} ->
|
||||
prompt = dgettext("prompts", "%{name} created successfully", name: tag_name)
|
||||
socket |> put_flash(:info, prompt) |> push_redirect(to: return_to)
|
||||
socket |> put_flash(:info, prompt) |> push_navigate(to: return_to)
|
||||
|
||||
{:error, %Changeset{} = changeset} ->
|
||||
socket |> assign(changeset: changeset)
|
||||
|
@ -11,35 +11,37 @@
|
||||
<%= display_emoji("😔") %>
|
||||
</h2>
|
||||
|
||||
<%= live_patch(dgettext("actions", "Make your first tag!"),
|
||||
to: Routes.tag_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.tag_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "Make your first tag!") %>
|
||||
</.link>
|
||||
<% else %>
|
||||
<%= live_patch(dgettext("actions", "New Tag"),
|
||||
to: Routes.tag_index_path(Endpoint, :new),
|
||||
class: "btn btn-primary"
|
||||
) %>
|
||||
<.link patch={Routes.tag_index_path(Endpoint, :new)} class="btn btn-primary">
|
||||
<%= dgettext("actions", "New Tag") %>
|
||||
</.link>
|
||||
<% end %>
|
||||
<div class="flex flex-row flex-wrap justify-center items-center">
|
||||
<%= for tag <- @tags do %>
|
||||
<.tag_card tag={tag}>
|
||||
<%= live_patch to: Routes.tag_index_path(Endpoint, :edit, tag),
|
||||
class: "text-primary-600 link",
|
||||
data: [qa: "edit-#{tag.id}"] do %>
|
||||
<.link
|
||||
patch={Routes.tag_index_path(Endpoint, :edit, tag)}
|
||||
class="text-primary-600 link"
|
||||
data-qa={"edit-#{tag.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-edit"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
|
||||
<%= link to: "#",
|
||||
class: "text-primary-600 link",
|
||||
phx_click: "delete",
|
||||
phx_value_id: tag.id,
|
||||
data: [
|
||||
confirm: dgettext("prompts", "Are you sure you want to delete %{name}?", name: tag.name),
|
||||
qa: "delete-#{tag.id}"
|
||||
] do %>
|
||||
<.link
|
||||
href="#"
|
||||
class="text-primary-600 link"
|
||||
phx-click="delete"
|
||||
phx-value-id={tag.id}
|
||||
data-confirm={
|
||||
dgettext("prompts", "Are you sure you want to delete %{name}?", name: tag.name)
|
||||
}
|
||||
data-qa={"delete-#{tag.id}"}
|
||||
>
|
||||
<i class="fa-fw fa-lg fas fa-trash"></i>
|
||||
<% end %>
|
||||
</.link>
|
||||
</.tag_card>
|
||||
<% end %>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user