Add category.move to reparent a category.

Validates both source and target via resolveCategoryAccess so the new
parent must be a category of the same authorized company, and guards
against moving into a descendant (cycle). Assigns next sibling sort.
This commit is contained in:
seb
2026-08-03 03:01:02 +02:00
parent b070607357
commit d8d66ce105
5 changed files with 114 additions and 0 deletions

View File

@@ -163,6 +163,7 @@ const MENU = {
items: [
{ value: 'category.createUnderParent', label: 'createUnderParent', hint: 'googleAuthId, parentId, name → row' },
{ value: 'category.rename', label: 'rename', hint: 'googleAuthId, id, name → row' },
{ value: 'category.move', label: 'move', hint: 'googleAuthId, id, parentId → row' },
{ value: 'category.order', label: 'order', hint: 'googleAuthId, parentId, JSON categoryIds' },
{ value: 'category.delete', label: 'delete', hint: 'googleAuthId, id' },
{ value: 'category.getTreeForCompany', label: 'getTreeForCompany', hint: 'googleAuthId, companyId → rows' },
@@ -671,6 +672,22 @@ async function runMethod(client, action) {
}),
];
}
case 'category.move': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;
const id = await askInt('Category id');
if (id == null) return;
const parentId = await askInt('new parent id');
if (parentId == null) return;
return [
'row',
await client.category.move({
googleAuthId: Number(googleAuthId),
id: Number(id),
parentId: Number(parentId),
}),
];
}
case 'category.order': {
const googleAuthId = await askInt('google_auth id');
if (googleAuthId == null) return;