function addSubTask()

in project/paperbench/paperbench/gui/static/script.js [123:147]


function addSubTask(taskId) {
    var newRequirements = prompt("Enter the requirements for the new sub-task:");
    if (newRequirements === null || newRequirements.trim() === "") {
        return; // User cancelled or entered empty string
    }

    fetch('/add_sub_task', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ 'parent_id': taskId, 'requirements': newRequirements }),
    })
    .then(response => response.json())
    .then(data => {
        if (data.status === 'success') {
            console.log('Sub-task added to node', taskId);
            location.reload();
        } else {
            console.error('Error adding sub-task:', data.message);
            alert('Failed to add sub-task: ' + data.message);
        }
    })
    .catch(error => console.error('Error adding sub-task:', error));
}