1
0

Added method to mark a task as done

This commit is contained in:
kolaente
2018-09-10 07:37:10 +02:00
parent 97a3079a34
commit f29da62643
2 changed files with 27 additions and 5 deletions

View File

@ -30,7 +30,7 @@
<div class="box tasks">
<label class="task" v-for="l in list.tasks" v-bind:key="l.id" v-bind:for="l.id">
<input type="checkbox" v-bind:id="l.id">
<input @change="markAsDone" type="checkbox" v-bind:id="l.id">
{{l.text}}
</label>
</div>
@ -98,6 +98,21 @@
this.newTask = ''
},
markAsDone(e) {
this.loading = true
HTTP.post(`tasks/` + e.target.id, {done: !e.target.checked}, {headers: {'Authorization': 'Bearer ' + localStorage.getItem('token')}})
.then(response => {
// eslint-disable-next-line
console.log(response)
//this.list.tasks.push(response.data)
this.handleSuccess({message: 'The task was successfully marked as done.'})
})
.catch(e => {
this.handleError(e)
})
},
handleError(e) {
this.loading = false
message.error(e, this)