mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-11 15:53:00 +03:00
46 lines
1.2 KiB
Svelte
46 lines
1.2 KiB
Svelte
<script lang="ts">
|
|
import AdvancedTable from '$lib/components/advanced-table.svelte';
|
|
import * as Table from '$lib/components/ui/table';
|
|
import UserGroupService from '$lib/services/user-group-service';
|
|
import type { Paginated, SearchPaginationSortRequest } from '$lib/types/pagination.type';
|
|
import type { UserGroup } from '$lib/types/user-group.type';
|
|
import { onMount } from 'svelte';
|
|
|
|
let {
|
|
selectionDisabled = false,
|
|
selectedGroupIds = $bindable()
|
|
}: {
|
|
selectionDisabled?: boolean;
|
|
selectedGroupIds: string[];
|
|
} = $props();
|
|
|
|
const userGroupService = new UserGroupService();
|
|
|
|
let groups: Paginated<UserGroup> | undefined = $state();
|
|
let requestOptions: SearchPaginationSortRequest = $state({
|
|
sort: {
|
|
column: 'friendlyName',
|
|
direction: 'asc'
|
|
}
|
|
});
|
|
|
|
onMount(async () => {
|
|
groups = await userGroupService.list(requestOptions);
|
|
});
|
|
</script>
|
|
|
|
{#if groups}
|
|
<AdvancedTable
|
|
items={groups}
|
|
{requestOptions}
|
|
onRefresh={async (o) => (groups = await userGroupService.list(o))}
|
|
columns={[{ label: 'Name', sortColumn: 'friendlyName' }]}
|
|
bind:selectedIds={selectedGroupIds}
|
|
{selectionDisabled}
|
|
>
|
|
{#snippet rows({ item })}
|
|
<Table.Cell>{item.name}</Table.Cell>
|
|
{/snippet}
|
|
</AdvancedTable>
|
|
{/if}
|