function moveNodeToParent()

in project/paperbench/paperbench/gui/static/script.js [352:380]


function moveNodeToParent(taskId) {
    const newParentId = prompt("Enter the ID of the new parent node:");
    if (!newParentId) return; // User cancelled

    fetch('/move_node_to_parent', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ 
            'node_id': taskId, 
            'new_parent_id': newParentId 
        }),
    })
    .then(response => response.json())
    .then(data => {
        if (data.status === 'success') {
            console.log('Node moved to new parent:', taskId);
            location.reload();
        } else {
            console.error('Error moving node:', data.message);
            alert('Failed to move node: ' + data.message);
        }
    })
    .catch(error => {
        console.error('Error moving node:', error);
        alert('Failed to move node. Please try again.');
    });
}