When a task is marked as done, the checkbox gets updated
This commit is contained in:
parent
f29da62643
commit
4193317283
1 changed files with 8 additions and 5 deletions
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
<div class="box tasks">
|
<div class="box tasks">
|
||||||
<label class="task" v-for="l in list.tasks" v-bind:key="l.id" v-bind:for="l.id">
|
<label class="task" v-for="l in list.tasks" v-bind:key="l.id" v-bind:for="l.id">
|
||||||
<input @change="markAsDone" type="checkbox" v-bind:id="l.id">
|
<input @change="markAsDone" type="checkbox" v-bind:id="l.id" v-bind:checked="l.done">
|
||||||
{{l.text}}
|
{{l.text}}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
@ -102,11 +102,14 @@
|
||||||
|
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|
||||||
HTTP.post(`tasks/` + e.target.id, {done: !e.target.checked}, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
HTTP.post(`tasks/` + e.target.id, {done: e.target.checked}, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
// eslint-disable-next-line
|
for (const t in this.list.tasks) {
|
||||||
console.log(response)
|
if (this.list.tasks[t].id === response.data.id) {
|
||||||
//this.list.tasks.push(response.data)
|
this.$set(this.list.tasks, t, response.data)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
this.handleSuccess({message: 'The task was successfully marked as done.'})
|
this.handleSuccess({message: 'The task was successfully marked as done.'})
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
|
|
Loading…
Reference in a new issue