tasks can be marked as finished
This commit is contained in:
parent
5e63fc1e38
commit
3bf957ee30
3 changed files with 44 additions and 7 deletions
|
@ -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>
|
||||
`;
|
||||
|
|
Reference in a new issue