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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user