fix: datafield edit view was shown alongside othe relements
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
carla 2026-02-26 12:37:52 +01:00
parent faf80bfb4b
commit 9751525a0c
8 changed files with 85 additions and 41 deletions

View file

@ -25,7 +25,7 @@ defmodule MvWeb.MemberFieldLive.IndexComponent do
~H"""
<div id={@id}>
<p class="text-sm text-base-content/70 mb-4">
<p :if={!@show_form} class="text-sm text-base-content/70 mb-4">
{gettext(
"These fields are neccessary for MILA to handle member identification and payment calculations in the future. Thus you cannot delete these fields but hide them in the member overview."
)}
@ -100,8 +100,8 @@ defmodule MvWeb.MemberFieldLive.IndexComponent do
@impl true
def update(assigns, socket) do
# Track previous show_form state to detect when form is closed
previous_show_form = Map.get(socket.assigns, :show_form, false)
# Use socket state so send_update(show_form: false) is the only trigger for "form closed"
previous_show_form = socket.assigns[:show_form] || false
# If show_form is explicitly provided in assigns, reset editing state
socket =
@ -113,20 +113,22 @@ defmodule MvWeb.MemberFieldLive.IndexComponent do
socket
end
# Detect when form is closed (show_form changes from true to false)
new_show_form = Map.get(assigns, :show_form, false)
socket =
socket
|> assign(assigns)
|> assign_new(:settings, fn -> get_settings() end)
|> assign_new(:show_form, fn -> false end)
|> assign_new(:form_id, fn -> "member-field-form-new" end)
|> assign_new(:editing_member_field, fn -> nil end)
if previous_show_form and not new_show_form do
# Detect form closed only from final socket state (not from assigns alone)
current_show_form = socket.assigns[:show_form] || false
if previous_show_form and not current_show_form do
send(self(), {:editing_section_changed, nil})
end
{:ok,
socket
|> assign(assigns)
|> assign_new(:settings, fn -> get_settings() end)
|> assign_new(:show_form, fn -> false end)
|> assign_new(:form_id, fn -> "member-field-form-new" end)
|> assign_new(:editing_member_field, fn -> nil end)}
{:ok, socket}
end
@impl true