WIP feat: account live view - basic functionality
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
de4643349a
commit
edb3978b64
8 changed files with 868 additions and 290 deletions
|
|
@ -6,10 +6,10 @@ defmodule MvWeb.UserLive.Index do
|
|||
~H"""
|
||||
<Layouts.app flash={@flash}>
|
||||
<.header>
|
||||
Listing Users
|
||||
{gettext("Listing Users")}
|
||||
<:actions>
|
||||
<.button variant="primary" navigate={~p"/users/new"}>
|
||||
<.icon name="hero-plus" /> New User
|
||||
<.icon name="hero-plus" /> {gettext("New User")}
|
||||
</.button>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
|
@ -19,24 +19,23 @@ defmodule MvWeb.UserLive.Index do
|
|||
rows={@streams.users}
|
||||
row_click={fn {_id, user} -> JS.navigate(~p"/users/#{user}") end}
|
||||
>
|
||||
<:col :let={{_id, user}} label="Id">{user.id}</:col>
|
||||
|
||||
<:col :let={{_id, user}} label="Email">{user.email}</:col>
|
||||
<:col :let={{_id, user}} label={gettext("Email")}>{user.email}</:col>
|
||||
<:col :let={{_id, user}} label={gettext("OIDC ID")}>{user.oidc_id}</:col>
|
||||
|
||||
<:action :let={{_id, user}}>
|
||||
<div class="sr-only">
|
||||
<.link navigate={~p"/users/#{user}"}>Show</.link>
|
||||
<.link navigate={~p"/users/#{user}"}>{gettext("Show")}</.link>
|
||||
</div>
|
||||
|
||||
<.link navigate={~p"/users/#{user}/edit"}>Edit</.link>
|
||||
<.link navigate={~p"/users/#{user}/edit"}>{gettext("Edit")}</.link>
|
||||
</:action>
|
||||
|
||||
<:action :let={{id, user}}>
|
||||
<.link
|
||||
phx-click={JS.push("delete", value: %{id: user.id}) |> hide("##{id}")}
|
||||
data-confirm="Are you sure?"
|
||||
data-confirm={gettext("Are you sure?")}
|
||||
>
|
||||
Delete
|
||||
{gettext("Delete")}
|
||||
</.link>
|
||||
</:action>
|
||||
</.table>
|
||||
|
|
@ -48,14 +47,14 @@ defmodule MvWeb.UserLive.Index do
|
|||
def mount(_params, _session, socket) do
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, "Listing Users")
|
||||
|> stream(:users, Ash.read!(Mv.Accounts.User))}
|
||||
|> assign(:page_title, gettext("Listing Users"))
|
||||
|> stream(:users, Ash.read!(Mv.Accounts.User, domain: Mv.Accounts))}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_event("delete", %{"id" => id}, socket) do
|
||||
user = Ash.get!(Mv.Accounts.User, id)
|
||||
Ash.destroy!(user)
|
||||
user = Ash.get!(Mv.Accounts.User, id, domain: Mv.Accounts)
|
||||
Ash.destroy!(user, domain: Mv.Accounts)
|
||||
|
||||
{:noreply, stream_delete(socket, :users, user)}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue