1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-02-14 19:57:31 +00:00

feat: open edit page on table row click

This commit is contained in:
Elias Schneider
2025-10-29 10:46:03 +01:00
parent 04d8500910
commit f184120890
5 changed files with 17 additions and 1 deletions

View File

@@ -166,6 +166,12 @@
return filters;
}
function getPrimaryAction(item: T) {
if (!actions) return null;
const availableActions = actions(item).filter((a) => a.primary);
return availableActions.length > 0 ? () => availableActions[0].onClick(item) : null;
}
export async function refresh() {
items = await fetchCallback(requestOptions);
changePageState(items.pagination.currentPage);
@@ -248,7 +254,13 @@
</Table.Header>
<Table.Body>
{#each items.data as item}
<Table.Row class={selectedIds?.includes(item.id) ? 'bg-muted/20' : ''}>
<Table.Row
class={{
'bg-muted/20': selectedIds?.includes(item.id),
'cursor-pointer': getPrimaryAction(item)
}}
onclick={getPrimaryAction(item)}
>
{#if selectedIds}
<Table.Cell class="w-12">
<Checkbox