mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-10 20:44:19 +00:00
feat: open edit page on table row click
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -22,5 +22,6 @@ export type AdvancedTableAction<T> = {
|
||||
variant?: 'primary' | 'secondary' | 'danger' | 'outline' | 'ghost';
|
||||
onClick: (item: T) => void;
|
||||
hidden?: boolean;
|
||||
primary?: boolean;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
const actions: CreateAdvancedTableActions<OidcClientWithAllowedUserGroupsCount> = (_) => [
|
||||
{
|
||||
label: m.edit(),
|
||||
primary: true,
|
||||
icon: LucidePencil,
|
||||
onClick: (client) => goto(`/settings/admin/oidc-clients/${client.id}`)
|
||||
},
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
const actions: CreateAdvancedTableActions<UserGroupWithUserCount> = (group) => [
|
||||
{
|
||||
label: m.edit(),
|
||||
primary: true,
|
||||
icon: LucidePencil,
|
||||
variant: 'ghost',
|
||||
onClick: (group) => goto(`/settings/admin/user-groups/${group.id}`)
|
||||
|
||||
@@ -143,6 +143,7 @@
|
||||
},
|
||||
{
|
||||
label: m.edit(),
|
||||
primary: true,
|
||||
icon: LucidePencil,
|
||||
onClick: (u) => goto(`/settings/admin/users/${u.id}`)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user