feat: add col_click attribute to table component for checkbox column
- Add col_click slot attribute to table component that overrides row_click - Clicking anywhere in the checkbox column now toggles the checkbox - Clicking other columns still navigates to member details Closes #223
This commit is contained in:
parent
09c75212b2
commit
8e4f1ba674
6 changed files with 71 additions and 60 deletions
|
|
@ -892,6 +892,16 @@ defmodule MvWeb.MemberLive.Index do
|
|||
|> Enum.map(&format_member_email/1)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Returns a JS command to toggle member selection when clicking the checkbox column.
|
||||
|
||||
Used as `col_click` handler to ensure clicking anywhere in the checkbox column
|
||||
toggles the checkbox instead of navigating to the member details.
|
||||
"""
|
||||
def checkbox_column_click(member) do
|
||||
JS.push("select_member", value: %{id: member.id})
|
||||
end
|
||||
|
||||
# Formats a member's email in the format "First Last <email>"
|
||||
# Used for copy_emails feature and mailto links to create email-client-friendly format.
|
||||
def format_member_email(member) do
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
<!-- <:col :let={member} label="Id">{member.id}</:col> -->
|
||||
<:col
|
||||
:let={member}
|
||||
col_click={&MvWeb.MemberLive.Index.checkbox_column_click/1}
|
||||
label={
|
||||
~H"""
|
||||
<.input
|
||||
|
|
@ -74,11 +75,7 @@
|
|||
<.input
|
||||
type="checkbox"
|
||||
name={member.id}
|
||||
phx-click="select_member"
|
||||
phx-value-id={member.id}
|
||||
checked={MapSet.member?(@selected_members, member.id)}
|
||||
phx-capture-click
|
||||
phx-stop-propagation
|
||||
aria-label={gettext("Select member")}
|
||||
role="checkbox"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue