57 lines
1.4 KiB
Elixir
57 lines
1.4 KiB
Elixir
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
|