feat(member): show join_description as a tooltip on custom-field labels
This commit is contained in:
parent
ee5ccbf7e9
commit
df271055a8
5 changed files with 85 additions and 9 deletions
|
|
@ -235,6 +235,19 @@ defmodule MvWeb.MemberLive.Show do
|
||||||
<%= for custom_field <- @custom_fields do %>
|
<%= for custom_field <- @custom_fields do %>
|
||||||
<% cfv = find_custom_field_value(@member.custom_field_values, custom_field.id) %>
|
<% cfv = find_custom_field_value(@member.custom_field_values, custom_field.id) %>
|
||||||
<.data_field label={custom_field.name}>
|
<.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)}
|
{format_custom_field_value(cfv, custom_field.value_type)}
|
||||||
</.data_field>
|
</.data_field>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
@ -605,11 +618,14 @@ defmodule MvWeb.MemberLive.Show do
|
||||||
attr :value, :string, default: nil
|
attr :value, :string, default: nil
|
||||||
attr :class, :string, default: ""
|
attr :class, :string, default: ""
|
||||||
slot :inner_block
|
slot :inner_block
|
||||||
|
slot :label_suffix
|
||||||
|
|
||||||
defp data_field(assigns) do
|
defp data_field(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<dl class={@class}>
|
<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">
|
<dd class="mt-1 text-base-content">
|
||||||
<%= if @inner_block != [] do %>
|
<%= if @inner_block != [] do %>
|
||||||
{render_slot(@inner_block)}
|
{render_slot(@inner_block)}
|
||||||
|
|
|
||||||
|
|
@ -3968,7 +3968,7 @@ msgstr "Zeitraum"
|
||||||
msgid "To"
|
msgid "To"
|
||||||
msgstr "Bis"
|
msgstr "Bis"
|
||||||
|
|
||||||
#~ #: lib/mv_web/live/group_live/show.ex
|
#: lib/mv_web/live/member_live/show.ex
|
||||||
#~ #, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
#~ msgid "No members selected."
|
msgid "Join form:"
|
||||||
#~ msgstr "Keine Mitglieder ausgewählt."
|
msgstr "Beitrittsformular:"
|
||||||
|
|
|
||||||
|
|
@ -3967,3 +3967,8 @@ msgstr ""
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "To"
|
msgid "To"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: lib/mv_web/live/member_live/show.ex
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
msgid "Join form:"
|
||||||
|
msgstr ""
|
||||||
|
|
|
||||||
|
|
@ -3968,7 +3968,7 @@ msgstr ""
|
||||||
msgid "To"
|
msgid "To"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#~ #: lib/mv_web/live/group_live/show.ex
|
#: lib/mv_web/live/member_live/show.ex
|
||||||
#~ #, elixir-autogen, elixir-format, fuzzy
|
#, elixir-autogen, elixir-format, fuzzy
|
||||||
#~ msgid "No members selected."
|
msgid "Join form:"
|
||||||
#~ msgstr ""
|
msgstr ""
|
||||||
|
|
|
||||||
|
|
@ -220,4 +220,59 @@ defmodule MvWeb.MemberLive.ShowTest do
|
||||||
assert html =~ "private@example.com"
|
assert html =~ "private@example.com"
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue