feat(member): show join_description as a tooltip on custom-field labels

This commit is contained in:
Simon 2026-06-03 12:22:58 +02:00
parent ee5ccbf7e9
commit df271055a8
5 changed files with 85 additions and 9 deletions

View file

@ -235,6 +235,19 @@ defmodule MvWeb.MemberLive.Show do
<%= for custom_field <- @custom_fields do %>
<% cfv = find_custom_field_value(@member.custom_field_values, custom_field.id) %>
<.data_field label={custom_field.name}>
<:label_suffix :if={custom_field.join_description}>
<.tooltip
content={"#{gettext("Join form:")} #{custom_field.join_description}"}
wrap_class="ml-1 inline-flex items-center"
>
<span data-testid="join-description-tooltip">
<.icon
name="hero-information-circle"
class="size-3.5 text-base-content/50"
/>
</span>
</.tooltip>
</:label_suffix>
{format_custom_field_value(cfv, custom_field.value_type)}
</.data_field>
<% end %>
@ -605,11 +618,14 @@ defmodule MvWeb.MemberLive.Show do
attr :value, :string, default: nil
attr :class, :string, default: ""
slot :inner_block
slot :label_suffix
defp data_field(assigns) do
~H"""
<dl class={@class}>
<dt class="text-sm font-medium text-base-content/70">{@label}</dt>
<dt class="text-sm font-medium text-base-content/70 flex items-center">
{@label}{render_slot(@label_suffix)}
</dt>
<dd class="mt-1 text-base-content">
<%= if @inner_block != [] do %>
{render_slot(@inner_block)}

View file

@ -3968,7 +3968,7 @@ msgstr "Zeitraum"
msgid "To"
msgstr "Bis"
#~ #: lib/mv_web/live/group_live/show.ex
#~ #, elixir-autogen, elixir-format
#~ msgid "No members selected."
#~ msgstr "Keine Mitglieder ausgewählt."
#: lib/mv_web/live/member_live/show.ex
#, elixir-autogen, elixir-format
msgid "Join form:"
msgstr "Beitrittsformular:"

View file

@ -3967,3 +3967,8 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "To"
msgstr ""
#: lib/mv_web/live/member_live/show.ex
#, elixir-autogen, elixir-format
msgid "Join form:"
msgstr ""

View file

@ -3968,7 +3968,7 @@ msgstr ""
msgid "To"
msgstr ""
#~ #: lib/mv_web/live/group_live/show.ex
#~ #, elixir-autogen, elixir-format, fuzzy
#~ msgid "No members selected."
#~ msgstr ""
#: lib/mv_web/live/member_live/show.ex
#, elixir-autogen, elixir-format, fuzzy
msgid "Join form:"
msgstr ""

View file

@ -220,4 +220,59 @@ defmodule MvWeb.MemberLive.ShowTest do
assert html =~ "private@example.com"
end
end
describe "custom field join_description tooltip" do
test "shows a tooltip on the custom field label when join_description is set", %{
conn: conn,
member: member,
actor: actor
} do
{:ok, custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "DSGVO",
value_type: :boolean,
join_description: "Accept the privacy policy"
})
|> Ash.create(actor: actor)
conn = conn_with_oidc_user(conn)
{:ok, view, html} = live(conn, ~p"/members/#{member}")
assert has_element?(view, "[data-tip*='Accept the privacy policy']")
# Tooltip content conveys both the join-form context and the description text.
assert has_element?(view, "[data-tip*='Join form:']")
assert html =~ "Accept the privacy policy"
assert html =~ custom_field.name
# The info-icon wrapper must center the icon vertically with the label,
# matching the flex-items-center idiom used elsewhere (e.g. custom field edit),
# so the icon is flush with the label text and not offset downward.
assert has_element?(
view,
"[data-tip*='Accept the privacy policy'].inline-flex.items-center"
)
end
test "shows no tooltip on the custom field label when join_description is nil", %{
conn: conn,
member: member,
actor: actor
} do
{:ok, _custom_field} =
CustomField
|> Ash.Changeset.for_create(:create, %{
name: "Plain field",
value_type: :string
})
|> Ash.create(actor: actor)
conn = conn_with_oidc_user(conn)
{:ok, view, _html} = live(conn, ~p"/members/#{member}")
assert has_element?(view, "dt", "Plain field")
# The info-icon tooltip beside the label is only rendered when join_description is set.
refute has_element?(view, "[data-testid='join-description-tooltip']")
end
end
end