fix tests and linting
This commit is contained in:
parent
4a6e7cf51a
commit
36776f8e28
11 changed files with 63 additions and 239 deletions
|
|
@ -18,8 +18,8 @@ defmodule MvWeb.MemberFieldLive.FormComponent do
|
|||
use MvWeb, :live_component
|
||||
|
||||
alias Mv.Membership
|
||||
alias MvWeb.Translations.MemberFields
|
||||
alias MvWeb.Translations.FieldTypes
|
||||
alias MvWeb.Translations.MemberFields
|
||||
|
||||
@required_fields [:first_name, :last_name, :email]
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ defmodule MvWeb.MemberFieldLive.IndexComponent do
|
|||
use MvWeb, :live_component
|
||||
|
||||
alias Mv.Membership
|
||||
alias MvWeb.Translations.MemberFields
|
||||
alias MvWeb.Translations.FieldTypes
|
||||
alias MvWeb.Translations.MemberFields
|
||||
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
|
|
@ -109,6 +109,9 @@ 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)
|
||||
|
||||
# If show_form is explicitly provided in assigns, reset editing state
|
||||
socket =
|
||||
if Map.has_key?(assigns, :show_form) and assigns.show_form == false do
|
||||
|
|
@ -119,6 +122,13 @@ 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)
|
||||
|
||||
if previous_show_form and not new_show_form do
|
||||
send(self(), {:editing_section_changed, nil})
|
||||
end
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(assigns)
|
||||
|
|
@ -136,6 +146,11 @@ defmodule MvWeb.MemberFieldLive.IndexComponent do
|
|||
if field_string in valid_fields do
|
||||
field_atom = String.to_existing_atom(field_string)
|
||||
|
||||
# Only send event if form was not already open
|
||||
if not socket.assigns[:show_form] do
|
||||
send(self(), {:editing_section_changed, :member_fields})
|
||||
end
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:show_form, true)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue