feat(users): add drag-and-drop reordering for PICs

Introduce pic_sort_order to persist custom user ordering
Replace data table with a custom draggable grid layout
Add API endpoint to handle bulk order updates
This commit is contained in:
2026-05-04 14:07:43 +08:00
parent 30753fdc61
commit 4e40bfd804
6 changed files with 355 additions and 91 deletions

View File

@@ -0,0 +1,24 @@
import { requireRole } from '../../../utils/auth'
import { assertBadRequest } from '../../../utils/http'
import { listUsers, reorderUsers } from '../../../utils/user-repository'
import { parseUserOrderInput } from '../../../utils/users'
export default defineEventHandler(async (event) => {
await requireRole(event, 'super_admin')
const body = await readBody<{
userIds?: unknown
}>(event)
const { userIds } = parseUserOrderInput(body)
const users = await listUsers()
const existingIds = new Set(users.map((user) => user.id))
assertBadRequest(userIds.length === users.length, 'User order must include every user')
assertBadRequest(userIds.every((userId) => existingIds.has(userId)), 'User order contains an unknown user')
await reorderUsers(userIds)
return {
users: await listUsers()
}
})