When a task is marked as done, the checkbox gets updated

This commit is contained in:
kolaente 2018-09-10 08:19:57 +02:00
parent f29da62643
commit 4193317283
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -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 => {