style: combines member and custom fields in settings
This commit is contained in:
parent
5fa0b48acc
commit
c88f805b6e
2 changed files with 171 additions and 155 deletions
|
|
@ -17,8 +17,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
||||||
assigns = assign(assigns, :field_type_label, &MvWeb.Translations.FieldTypes.label/1)
|
assigns = assign(assigns, :field_type_label, &MvWeb.Translations.FieldTypes.label/1)
|
||||||
|
|
||||||
~H"""
|
~H"""
|
||||||
<div id={@id}>
|
<div id={@id} class="mt-8">
|
||||||
<.form_section title={gettext("Custom Fields")}>
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<p class="text-sm text-base-content/70">
|
<p class="text-sm text-base-content/70">
|
||||||
{gettext("These will appear in addition to other data when adding new members.")}
|
{gettext("These will appear in addition to other data when adding new members.")}
|
||||||
|
|
@ -103,9 +102,7 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
||||||
</:action>
|
</:action>
|
||||||
|
|
||||||
<:action :let={{_id, custom_field}}>
|
<:action :let={{_id, custom_field}}>
|
||||||
<.link phx-click={
|
<.link phx-click={JS.push("prepare_delete", value: %{id: custom_field.id}, target: @myself)}>
|
||||||
JS.push("prepare_delete", value: %{id: custom_field.id}, target: @myself)
|
|
||||||
}>
|
|
||||||
{gettext("Delete")}
|
{gettext("Delete")}
|
||||||
</.link>
|
</.link>
|
||||||
</:action>
|
</:action>
|
||||||
|
|
@ -175,7 +172,6 @@ defmodule MvWeb.CustomFieldLive.IndexComponent do
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</dialog>
|
</dialog>
|
||||||
</.form_section>
|
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
</.form>
|
</.form>
|
||||||
</.form_section>
|
</.form_section>
|
||||||
<%!-- Memberdata Section --%>
|
<%!-- Memberdata Section --%>
|
||||||
|
<.form_section title={gettext("Memberdata")}>
|
||||||
<.live_component
|
<.live_component
|
||||||
module={MvWeb.MemberFieldLive.IndexComponent}
|
module={MvWeb.MemberFieldLive.IndexComponent}
|
||||||
id="member-fields-component"
|
id="member-fields-component"
|
||||||
|
|
@ -73,6 +74,7 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
module={MvWeb.CustomFieldLive.IndexComponent}
|
module={MvWeb.CustomFieldLive.IndexComponent}
|
||||||
id="custom-fields-component"
|
id="custom-fields-component"
|
||||||
/>
|
/>
|
||||||
|
</.form_section>
|
||||||
</Layouts.app>
|
</Layouts.app>
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
@ -158,6 +160,24 @@ defmodule MvWeb.GlobalSettingsLive do
|
||||||
{:noreply, put_flash(socket, :error, error_message)}
|
{:noreply, put_flash(socket, :error, error_message)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def handle_info({:member_field_saved, _member_field, action}, socket) do
|
||||||
|
# Reload settings to get updated member_field_visibility
|
||||||
|
{:ok, updated_settings} = Membership.get_settings()
|
||||||
|
|
||||||
|
# Send update to member fields component to close form
|
||||||
|
send_update(MvWeb.MemberFieldLive.IndexComponent,
|
||||||
|
id: "member-fields-component",
|
||||||
|
show_form: false,
|
||||||
|
settings: updated_settings
|
||||||
|
)
|
||||||
|
|
||||||
|
{:noreply,
|
||||||
|
socket
|
||||||
|
|> assign(:settings, updated_settings)
|
||||||
|
|> put_flash(:info, gettext("Member field %{action} successfully", action: action))}
|
||||||
|
end
|
||||||
|
|
||||||
defp assign_form(%{assigns: %{settings: settings}} = socket) do
|
defp assign_form(%{assigns: %{settings: settings}} = socket) do
|
||||||
form =
|
form =
|
||||||
AshPhoenix.Form.for_update(
|
AshPhoenix.Form.for_update(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue