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
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 27 additions and 5 deletions

15
package-lock.json generated
View file

@ -5274,7 +5274,8 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
@ -5284,7 +5285,8 @@
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -5401,7 +5403,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -5413,6 +5416,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -5538,7 +5542,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -5550,6 +5555,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -5671,6 +5677,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",

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)