function updateTaskCategory()

in project/paperbench/paperbench/gui/static/script.js [198:221]


function updateTaskCategory(taskId, category) {
    fetch('/update_task_category', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({ 'node_id': taskId, 'category': category }),
    })
    .then(response => response.json())
    .then(data => {
        if (data.status === 'success') {
            console.log('Task category updated for node', taskId);
        } else {
            console.error('Error updating task category:', data.message);
            alert('Failed to update task category: ' + data.message);
            location.reload(); // Reset the dropdown to its previous state
        }
    })
    .catch(error => {
        console.error('Error updating task category:', error);
        alert('Failed to update task category. Please try again.');
        location.reload(); // Reset the dropdown to its previous state
    });
}