mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-03-30 19:26:37 +00:00
fix: make sorting consistent around tables
This commit is contained in:
@@ -6,18 +6,13 @@ import type { PageServerLoad } from './$types';
|
||||
export const load: PageServerLoad = async ({ cookies }) => {
|
||||
const userService = new UserService(cookies.get(ACCESS_TOKEN_COOKIE_NAME));
|
||||
|
||||
// Create request options with default sorting
|
||||
const requestOptions: SearchPaginationSortRequest = {
|
||||
const usersRequestOptions: SearchPaginationSortRequest = {
|
||||
sort: {
|
||||
column: 'firstName',
|
||||
direction: 'asc'
|
||||
},
|
||||
pagination: {
|
||||
page: 1,
|
||||
limit: 10
|
||||
}
|
||||
};
|
||||
|
||||
const users = await userService.list(requestOptions);
|
||||
return users;
|
||||
const users = await userService.list(usersRequestOptions);
|
||||
return {users, usersRequestOptions};
|
||||
};
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import UserService from '$lib/services/user-service';
|
||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import type { Paginated } from '$lib/types/pagination.type';
|
||||
import type { User, UserCreate } from '$lib/types/user.type';
|
||||
import type { UserCreate } from '$lib/types/user.type';
|
||||
import { axiosErrorToast } from '$lib/utils/error-util';
|
||||
import { LucideMinus } from 'lucide-svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
@@ -13,7 +12,9 @@
|
||||
import UserList from './user-list.svelte';
|
||||
|
||||
let { data } = $props();
|
||||
let users: Paginated<User> = $state(data);
|
||||
let users = $state(data.users);
|
||||
let usersRequestOptions = $state(data.usersRequestOptions);
|
||||
|
||||
let expandAddUser = $state(false);
|
||||
|
||||
const userService = new UserService();
|
||||
@@ -28,7 +29,7 @@
|
||||
success = false;
|
||||
});
|
||||
|
||||
users = await userService.list();
|
||||
users = await userService.list(usersRequestOptions);
|
||||
return success;
|
||||
}
|
||||
</script>
|
||||
@@ -67,6 +68,6 @@
|
||||
<Card.Title>Manage Users</Card.Title>
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
<UserList {users} />
|
||||
<UserList {users} requestOptions={usersRequestOptions} />
|
||||
</Card.Content>
|
||||
</Card.Root>
|
||||
|
||||
@@ -5,15 +5,14 @@
|
||||
import Badge from '$lib/components/ui/badge/badge.svelte';
|
||||
import { Button } from '$lib/components/ui/button';
|
||||
import * as Card from '$lib/components/ui/card';
|
||||
import UserGroupSelection from '$lib/components/user-group-selection.svelte';
|
||||
import CustomClaimService from '$lib/services/custom-claim-service';
|
||||
import UserGroupService from '$lib/services/user-group-service';
|
||||
import UserService from '$lib/services/user-service';
|
||||
import appConfigStore from '$lib/stores/application-configuration-store';
|
||||
import type { UserCreate } from '$lib/types/user.type';
|
||||
import { axiosErrorToast } from '$lib/utils/error-util';
|
||||
import { LucideChevronLeft } from 'lucide-svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import UserGroupSelection from '$lib/components/user-group-selection.svelte';
|
||||
import UserForm from '../user-form.svelte';
|
||||
|
||||
let { data } = $props();
|
||||
@@ -24,7 +23,6 @@
|
||||
|
||||
const userService = new UserService();
|
||||
const customClaimService = new CustomClaimService();
|
||||
const userGroupService = new UserGroupService();
|
||||
|
||||
async function updateUserGroups(userIds: string[]) {
|
||||
await userService
|
||||
@@ -101,14 +99,10 @@
|
||||
title="User Groups"
|
||||
description="Manage which groups this user belongs to."
|
||||
>
|
||||
{#await userGroupService.list() then groups}
|
||||
<UserGroupSelection
|
||||
{groups}
|
||||
bind:selectedGroupIds={user.userGroupIds}
|
||||
selectionDisabled={!!user.ldapId && $appConfigStore.ldapEnabled}
|
||||
/>
|
||||
{/await}
|
||||
|
||||
<UserGroupSelection
|
||||
bind:selectedGroupIds={user.userGroupIds}
|
||||
selectionDisabled={!!user.ldapId && $appConfigStore.ldapEnabled}
|
||||
/>
|
||||
<div class="mt-5 flex justify-end">
|
||||
<Button
|
||||
on:click={() => updateUserGroups(user.userGroupIds)}
|
||||
|
||||
@@ -16,18 +16,13 @@
|
||||
import { toast } from 'svelte-sonner';
|
||||
import OneTimeLinkModal from './one-time-link-modal.svelte';
|
||||
|
||||
let { users = $bindable() }: { users: Paginated<User> } = $props();
|
||||
let {
|
||||
users = $bindable(),
|
||||
requestOptions
|
||||
}: { users: Paginated<User>; requestOptions: SearchPaginationSortRequest } = $props();
|
||||
|
||||
let userIdToCreateOneTimeLink: string | null = $state(null);
|
||||
|
||||
let requestOptions: SearchPaginationSortRequest | undefined = $state({
|
||||
sort: { column: 'firstName', direction: 'asc' },
|
||||
pagination: {
|
||||
page: users.pagination.currentPage,
|
||||
limit: users.pagination.itemsPerPage
|
||||
}
|
||||
});
|
||||
|
||||
const userService = new UserService();
|
||||
|
||||
async function deleteUser(user: User) {
|
||||
@@ -54,7 +49,6 @@
|
||||
<AdvancedTable
|
||||
items={users}
|
||||
{requestOptions}
|
||||
defaultSort={{ column: 'firstName', direction: 'asc' }}
|
||||
onRefresh={async (options) => (users = await userService.list(options))}
|
||||
columns={[
|
||||
{ label: 'First name', sortColumn: 'firstName' },
|
||||
|
||||
Reference in New Issue
Block a user