fix: color contrast dark mode and keyboard moadals
This commit is contained in:
parent
5516c7fe62
commit
c71c7d6ed6
14 changed files with 1067 additions and 740 deletions
|
|
@ -111,6 +111,7 @@ defmodule MvWeb.CustomFieldLive.FormComponent do
|
|||
)}
|
||||
</p>
|
||||
<.button
|
||||
id="delete-custom-field-trigger"
|
||||
type="button"
|
||||
variant="danger"
|
||||
phx-click="request_delete"
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
class="modal modal-open"
|
||||
role="dialog"
|
||||
aria-labelledby="delete-custom-field-modal-title"
|
||||
phx-keydown="dialog_keydown"
|
||||
>
|
||||
<div class="modal-box">
|
||||
<h3 id="delete-custom-field-modal-title" class="text-lg font-bold">
|
||||
|
|
@ -226,6 +227,8 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
socket
|
||||
|
||||
id ->
|
||||
send(self(), {:custom_field_delete_modal_open, true})
|
||||
|
||||
custom_field =
|
||||
Ash.get!(Mv.Membership.CustomField, id,
|
||||
load: [:assigned_members_count],
|
||||
|
|
@ -290,6 +293,8 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
actor: actor
|
||||
)
|
||||
|
||||
send(self(), {:custom_field_delete_modal_open, true})
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:custom_field_to_delete, custom_field)
|
||||
|
|
@ -310,6 +315,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
if socket.assigns.slug_confirmation == custom_field.slug do
|
||||
case Ash.destroy(custom_field, actor: actor) do
|
||||
:ok ->
|
||||
send(self(), {:custom_field_delete_modal_open, false})
|
||||
send(self(), {:custom_field_deleted, custom_field})
|
||||
|
||||
{:noreply,
|
||||
|
|
@ -320,6 +326,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
|> stream_delete(:custom_fields, custom_field)}
|
||||
|
||||
{:error, error} ->
|
||||
send(self(), {:custom_field_delete_modal_open, false})
|
||||
send(self(), {:custom_field_delete_error, error})
|
||||
|
||||
{:noreply,
|
||||
|
|
@ -329,6 +336,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
|> assign(:slug_confirmation, "")}
|
||||
end
|
||||
else
|
||||
send(self(), {:custom_field_delete_modal_open, false})
|
||||
send(self(), :custom_field_slug_mismatch)
|
||||
|
||||
{:noreply,
|
||||
|
|
@ -341,10 +349,22 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
|||
|
||||
@impl true
|
||||
def handle_event("cancel_delete", _params, socket) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:show_delete_modal, false)
|
||||
|> assign(:custom_field_to_delete, nil)
|
||||
|> assign(:slug_confirmation, "")}
|
||||
send(self(), {:custom_field_delete_modal_open, false})
|
||||
{:noreply, close_delete_modal_and_restore_focus(socket)}
|
||||
end
|
||||
|
||||
def handle_event("dialog_keydown", %{"key" => key}, socket) when key in ["Escape", "Esc"] do
|
||||
send(self(), {:custom_field_delete_modal_open, false})
|
||||
{:noreply, close_delete_modal_and_restore_focus(socket)}
|
||||
end
|
||||
|
||||
def handle_event("dialog_keydown", _params, socket), do: {:noreply, socket}
|
||||
|
||||
defp close_delete_modal_and_restore_focus(socket) do
|
||||
socket
|
||||
|> assign(:show_delete_modal, false)
|
||||
|> assign(:custom_field_to_delete, nil)
|
||||
|> assign(:slug_confirmation, "")
|
||||
|> push_event("focus_restore", %{id: "delete-custom-field-trigger"})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue