fix: make drag-and-drop on category tree persist correctly

Two issues prevented the shelf tree reordering from working:

- The JS used ``onDragStop`` (only fires for drags outside the
  tree) instead of the ``tree.move`` event to send the AJAX
  request. Moved the POST into the ``tree.move`` handler.
- The ``inside`` case used ``appendNode`` (last child), but
  jqTree sends ``inside`` when dropping before the first child.
  Switched to ``prependNode`` so the node lands first.
- Added missing ``before`` case with ``insertBeforeNode``.
This commit is contained in:
Valentin Lab
2026-02-13 05:42:54 +01:00
parent 7a246a189a
commit cd5d72e272
2 changed files with 17 additions and 46 deletions

View File

@@ -67,17 +67,15 @@ class Categories
$category_target = self::getNode($target_id);
switch ($type) {
case 'before':
return $category->insertBeforeNode($category_target);
case 'after':
$category->afterNode($category_target);
break;
return $category->insertAfterNode($category_target);
case 'inside':
$category_target->appendNode($category);
break;
return $category_target->prependNode($category);
default:
$category->afterNode($category_target);
return $category->insertAfterNode($category_target);
}
return $category->save();
}
public static function create($data)