mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-02-16 18:10:18 +00:00
feat: open edit page on table row click
This commit is contained in:
@@ -166,6 +166,12 @@
|
|||||||
return filters;
|
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() {
|
export async function refresh() {
|
||||||
items = await fetchCallback(requestOptions);
|
items = await fetchCallback(requestOptions);
|
||||||
changePageState(items.pagination.currentPage);
|
changePageState(items.pagination.currentPage);
|
||||||
@@ -248,7 +254,13 @@
|
|||||||
</Table.Header>
|
</Table.Header>
|
||||||
<Table.Body>
|
<Table.Body>
|
||||||
{#each items.data as item}
|
{#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}
|
{#if selectedIds}
|
||||||
<Table.Cell class="w-12">
|
<Table.Cell class="w-12">
|
||||||
<Checkbox
|
<Checkbox
|
||||||
|
|||||||
@@ -22,5 +22,6 @@ export type AdvancedTableAction<T> = {
|
|||||||
variant?: 'primary' | 'secondary' | 'danger' | 'outline' | 'ghost';
|
variant?: 'primary' | 'secondary' | 'danger' | 'outline' | 'ghost';
|
||||||
onClick: (item: T) => void;
|
onClick: (item: T) => void;
|
||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
|
primary?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -70,6 +70,7 @@
|
|||||||
const actions: CreateAdvancedTableActions<OidcClientWithAllowedUserGroupsCount> = (_) => [
|
const actions: CreateAdvancedTableActions<OidcClientWithAllowedUserGroupsCount> = (_) => [
|
||||||
{
|
{
|
||||||
label: m.edit(),
|
label: m.edit(),
|
||||||
|
primary: true,
|
||||||
icon: LucidePencil,
|
icon: LucidePencil,
|
||||||
onClick: (client) => goto(`/settings/admin/oidc-clients/${client.id}`)
|
onClick: (client) => goto(`/settings/admin/oidc-clients/${client.id}`)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
const actions: CreateAdvancedTableActions<UserGroupWithUserCount> = (group) => [
|
const actions: CreateAdvancedTableActions<UserGroupWithUserCount> = (group) => [
|
||||||
{
|
{
|
||||||
label: m.edit(),
|
label: m.edit(),
|
||||||
|
primary: true,
|
||||||
icon: LucidePencil,
|
icon: LucidePencil,
|
||||||
variant: 'ghost',
|
variant: 'ghost',
|
||||||
onClick: (group) => goto(`/settings/admin/user-groups/${group.id}`)
|
onClick: (group) => goto(`/settings/admin/user-groups/${group.id}`)
|
||||||
|
|||||||
@@ -143,6 +143,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: m.edit(),
|
label: m.edit(),
|
||||||
|
primary: true,
|
||||||
icon: LucidePencil,
|
icon: LucidePencil,
|
||||||
onClick: (u) => goto(`/settings/admin/users/${u.id}`)
|
onClick: (u) => goto(`/settings/admin/users/${u.id}`)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user