in script.js [841:864]
function wouldCreateCycle(draggedId, dropTargetId) {
// Check if drop target is a descendant of dragged item
let currentId = dropTargetId;
const visited = new Set();
while (currentId) {
if (visited.has(currentId)) {
// Cycle detected (shouldn't happen, but just in case)
return true;
}
visited.add(currentId);
if (currentId === draggedId) {
// The drop target is a descendant of the dragged item
return true;
}
// Move up to parent
const parent = currentData.management_groups.find(mg => mg.id === currentId);
currentId = parent ? parent.parent_id : null;
}
return false;
}