This commit is contained in:
parent
720a43a38c
commit
35895ac7fd
3 changed files with 28 additions and 157 deletions
|
|
@ -148,9 +148,9 @@ defmodule MvWeb.MemberLive.Show do
|
|||
</div>
|
||||
|
||||
<%!-- Custom Fields Section --%>
|
||||
<%= if Enum.any?(@custom_fields) do %>
|
||||
<%= if is_list(@custom_fields) && Enum.any?(@custom_fields) do %>
|
||||
<div>
|
||||
<.section_box title={gettext("Custom Fields")}>
|
||||
<.section_box title={gettext("Additional Data Fields")}>
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<%= for custom_field <- @custom_fields do %>
|
||||
<% cfv = find_custom_field_value(@member.custom_field_values, custom_field.id) %>
|
||||
|
|
@ -233,13 +233,15 @@ defmodule MvWeb.MemberLive.Show do
|
|||
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
# Load custom fields once using assign_new to avoid repeated queries
|
||||
socket =
|
||||
assign_new(socket, :custom_fields, fn ->
|
||||
Mv.Membership.CustomField
|
||||
|> Ash.Query.sort(name: :asc)
|
||||
|> Ash.read!()
|
||||
end)
|
||||
# Load custom fields for display
|
||||
# Note: Each page load starts a new LiveView process, so caching with
|
||||
# assign_new is not necessary here (mount creates a fresh socket each time)
|
||||
custom_fields =
|
||||
Mv.Membership.CustomField
|
||||
|> Ash.Query.sort(name: :asc)
|
||||
|> Ash.read!()
|
||||
|
||||
socket = assign(socket, :custom_fields, custom_fields)
|
||||
|
||||
query =
|
||||
Mv.Membership.Member
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue