feat: migration to phoenix 1.8 - merge old live views into new live views
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
fd6770e82b
commit
646c5e2bcb
16 changed files with 234 additions and 932 deletions
|
|
@ -7,18 +7,18 @@ defmodule MvWeb.PropertyLive.Form do
|
|||
<Layouts.app flash={@flash}>
|
||||
<.header>
|
||||
{@page_title}
|
||||
<:subtitle>Use this form to manage property records in your database.</:subtitle>
|
||||
<:subtitle>{gettext("Use this form to manage property records in your database.")}</:subtitle>
|
||||
</.header>
|
||||
|
||||
<.form for={@form} id="property-form" phx-change="validate" phx-submit="save">
|
||||
<.input field={@form[:value]} type="text" label="Value" /><.input
|
||||
field={@form[:member_id]}
|
||||
type="text"
|
||||
label="Member"
|
||||
/><.input field={@form[:property_type_id]} type="text" label="Property type" />
|
||||
<.input field={@form[:value]} type="text" label={gettext("Value")} />
|
||||
<.input field={@form[:member_id]} type="text" label={gettext("Member")} />
|
||||
<.input field={@form[:property_type_id]} type="text" label={gettext("Property type")} />
|
||||
|
||||
<.button phx-disable-with="Saving..." variant="primary">Save Property</.button>
|
||||
<.button navigate={return_path(@return_to, @property)}>Cancel</.button>
|
||||
<.button phx-disable-with={gettext("Saving...")} variant="primary">
|
||||
{gettext("Save Property")}
|
||||
</.button>
|
||||
<.button navigate={return_path(@return_to, @property)}>{gettext("Cancel")}</.button>
|
||||
</.form>
|
||||
</Layouts.app>
|
||||
"""
|
||||
|
|
@ -57,9 +57,16 @@ defmodule MvWeb.PropertyLive.Form do
|
|||
{:ok, property} ->
|
||||
notify_parent({:saved, property})
|
||||
|
||||
action =
|
||||
case socket.assigns.form.source.type do
|
||||
:create -> gettext("create")
|
||||
:update -> gettext("update")
|
||||
other -> to_string(other)
|
||||
end
|
||||
|
||||
socket =
|
||||
socket
|
||||
|> put_flash(:info, "Property #{socket.assigns.form.source.type}d successfully")
|
||||
|> put_flash(:info, gettext("Property %{action} successfully", action: action))
|
||||
|> push_navigate(to: return_path(socket.assigns.return_to, property))
|
||||
|
||||
{:noreply, socket}
|
||||
|
|
|
|||
|
|
@ -27,10 +27,18 @@ defmodule MvWeb.PropertyLive.Show do
|
|||
end
|
||||
|
||||
@impl true
|
||||
def mount(%{"id" => id}, _session, socket) do
|
||||
{:ok,
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, socket}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:page_title, "Show Property")
|
||||
|> 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