diff --git a/lib/mv_web/live/custom_field_live/form_component.ex b/lib/mv_web/live/custom_field_live/form_component.ex index c0b731c..46be022 100644 --- a/lib/mv_web/live/custom_field_live/form_component.ex +++ b/lib/mv_web/live/custom_field_live/form_component.ex @@ -21,9 +21,14 @@ defmodule MvWeb.CustomFieldLive.FormComponent do ~H"""
-

- {if @custom_field, do: gettext("Edit Custom Field"), else: gettext("New Custom Field")} -

+
+ <.button type="button" phx-click="cancel" phx-target={@myself}> + <.icon name="hero-arrow-left" class="w-4 h-4" /> + +

+ {if @custom_field, do: gettext("Edit Custom Field"), else: gettext("New Custom Field")} +

+
<.form for={@form} @@ -83,7 +88,14 @@ defmodule MvWeb.CustomFieldLive.FormComponent do def handle_event("save", %{"custom_field" => custom_field_params}, socket) do case AshPhoenix.Form.submit(socket.assigns.form, params: custom_field_params) do {:ok, custom_field} -> - socket.assigns.on_save.(custom_field) + action = + case socket.assigns.form.source.type do + :create -> gettext("create") + :update -> gettext("update") + other -> to_string(other) + end + + socket.assigns.on_save.(custom_field, action) {:noreply, socket} {:error, form} -> diff --git a/lib/mv_web/live/custom_field_live/index_component.ex b/lib/mv_web/live/custom_field_live/index_component.ex index a071b7a..9b8ff0d 100644 --- a/lib/mv_web/live/custom_field_live/index_component.ex +++ b/lib/mv_web/live/custom_field_live/index_component.ex @@ -19,7 +19,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do <.header> {gettext("Custom Fields")} <:subtitle> - {gettext("Manage custom field definitions for members.")} + {gettext("These will appear in addition to other data when adding new members.")} <:actions> <.button variant="primary" phx-click="new_custom_field" phx-target={@myself}> @@ -34,12 +34,14 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do module={MvWeb.CustomFieldLive.FormComponent} id={@form_id} custom_field={@editing_custom_field} - on_save={fn custom_field -> send(self(), {:custom_field_saved, custom_field}) end} - on_cancel={fn -> send(self(), :cancel_custom_field_form) end} + on_save={fn custom_field, action -> send(self(), {:custom_field_saved, custom_field, action}) end} + on_cancel={fn -> send_update(__MODULE__, id: @id, show_form: false) end} />
+ <%!-- Hide table when form is visible --%> <.table + :if={!@show_form} id="custom_fields" rows={@streams.custom_fields} row_click={ @@ -85,11 +87,11 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do <%!-- Delete Confirmation Modal --%>