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. <:actions> <.link patch={~p"/properties/#{@property}/show/edit"} phx-click={JS.push_focus()}> <.button>Edit property <.list> <:item title="Id">{@property.id} <.back navigate={~p"/properties"}>Back to properties <.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}"} /> """ 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