WIP: add liveview
This commit is contained in:
parent
45fc52d6fb
commit
b91df051dc
10 changed files with 776 additions and 0 deletions
57
lib/mv_web/property_live/show.ex
Normal file
57
lib/mv_web/property_live/show.ex
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
defmodule MvWeb.PropertyLive.Show do
|
||||
use MvWeb, :live_view
|
||||
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<.header>
|
||||
Property {@property.id}
|
||||
<:subtitle>This is a property record from your database.</:subtitle>
|
||||
|
||||
<:actions>
|
||||
<.link patch={~p"/properties/#{@property}/show/edit"} phx-click={JS.push_focus()}>
|
||||
<.button>Edit property</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
</.header>
|
||||
|
||||
<.list>
|
||||
<:item title="Id">{@property.id}</:item>
|
||||
</.list>
|
||||
|
||||
<.back navigate={~p"/properties"}>Back to properties</.back>
|
||||
|
||||
<.modal
|
||||
:if={@live_action == :edit}
|
||||
id="property-modal"
|
||||
show
|
||||
on_cancel={JS.patch(~p"/properties/#{@property}")}
|
||||
>
|
||||
<.live_component
|
||||
module={MvWeb.PropertyLive.FormComponent}
|
||||
id={@property.id}
|
||||
title={@page_title}
|
||||
action={@live_action}
|
||||
property={@property}
|
||||
patch={~p"/properties/#{@property}"}
|
||||
/>
|
||||
</.modal>
|
||||
"""
|
||||
end
|
||||
|
||||
@impl true
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action))
|
||||
|> assign(:property, Ash.get!(Mv.Membership.Property, id))}
|
||||
end
|
||||
|
||||
defp page_title(:show), do: "Show Property"
|
||||
defp page_title(:edit), do: "Edit Property"
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue