tasks can be marked as finished

This commit is contained in:
Florian Hoss 2022-04-07 16:05:43 +02:00
parent 5e63fc1e38
commit 3bf957ee30
3 changed files with 44 additions and 7 deletions

View file

@ -50,7 +50,7 @@
}
function deleteTask(id) {
axios.delete("/tasks/" + id, axiosConfig)
axios.delete("/tasks", {params: {id: id}, headers: {username: username}})
.then(() => {
getAllTasks();
})
@ -59,6 +59,13 @@
});
}
function updateTask(id, done) {
axios.put("/tasks", null, {params: {id: id, done: done}, headers: {username: username}})
.catch((err) => {
showErrorToast(err.response.data.message);
});
}
function addTaskToTasks(task, number) {
tasks.push(task);
const newTask = document.createElement('div');
@ -68,7 +75,7 @@
<div class="col-1 text-center">${number}</div>
<div class="col-8">${task.Description}</div>
<div class="col-2 form-check form-switch d-flex justify-content-center">
<input class="text-center form-check-input" type="checkbox" ${task.Done && "checked"} role="switch" id="flexSwitchCheckDefault">
<input onchange="updateTask(${task.ID},this.checked)" class="text-center form-check-input" type="checkbox" ${task.Done && "checked"} role="switch" id="flexSwitchCheckDefault">
</div>
<button onclick="deleteTask(${task.ID})" class="col-1 btn btn-danger"><i class="bi bi-trash"></i></button>
`;