Merge remote-tracking branch 'origin/main' into feature/220_ui_issues_2
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
commit
b1f6d29ca1
7 changed files with 45 additions and 44 deletions
|
|
@ -499,6 +499,7 @@ defmodule MvWeb.CoreComponents do
|
|||
slot :col, required: true do
|
||||
attr :label, :string
|
||||
attr :class, :string
|
||||
attr :col_click, :any, doc: "optional column-specific click handler that overrides row_click"
|
||||
end
|
||||
|
||||
slot :action, doc: "the slot for showing user actions in the last table column"
|
||||
|
|
@ -534,9 +535,13 @@ defmodule MvWeb.CoreComponents do
|
|||
<tr :for={row <- @rows} id={@row_id && @row_id.(row)}>
|
||||
<td
|
||||
:for={col <- @col}
|
||||
phx-click={@row_click && @row_click.(row)}
|
||||
phx-click={
|
||||
(col[:col_click] && col[:col_click].(@row_item.(row))) ||
|
||||
(@row_click && @row_click.(row))
|
||||
}
|
||||
class={
|
||||
col_class = Map.get(col, :class)
|
||||
has_click = col[:col_click] || @row_click
|
||||
classes = ["max-w-xs"]
|
||||
|
||||
classes =
|
||||
|
|
@ -547,7 +552,7 @@ defmodule MvWeb.CoreComponents do
|
|||
end
|
||||
|
||||
classes =
|
||||
if @row_click do
|
||||
if has_click do
|
||||
["hover:cursor-pointer" | classes]
|
||||
else
|
||||
classes
|
||||
|
|
|
|||
|
|
@ -1082,6 +1082,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
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
<!-- <:col :let={member} label="Id">{member.id}</:col> -->
|
||||
<:col
|
||||
:let={member}
|
||||
col_click={&MvWeb.MemberLive.Index.checkbox_column_click/1}
|
||||
label={
|
||||
~H"""
|
||||
<.input
|
||||
|
|
@ -81,11 +82,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