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