Fixed error where creating a new author would fail when the book initially had no authors

This commit is contained in:
kolaente 2017-12-05 14:19:44 +01:00
parent 28b5231199
commit 19932ca7e4
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 11 additions and 2 deletions

View File

@ -104,6 +104,7 @@
bookID: this.$route.params.id,
edit: false,
book: {
authors: [],
title: '',
description: '',
isbn: '',
@ -114,8 +115,7 @@
publisher: {
id: 0,
name: ''
},
Authors: []
}
},
publishers: [],
authors: [],
@ -159,6 +159,12 @@
name: as[i].forename + ' ' + as[i].lastname
}
}
// Workaround when the book don't has any authors
if (this.book.authors === null) {
this.book.authors = []
}
console.log(this.book.authors)
})
.catch(e => {
this.errorNotification(e)
@ -242,12 +248,15 @@
// Add all newly created authors to it
let as = this.newAuthors
console.log(this.book, this.newAuthors)
for (const i in as) {
this.book.authors.push({
id: 0,
name: as[i]
})
}
console.log(this.book.authors, this.newAuthors)
// Beautify all Authors aka split the names in forename and lastname
for (const i in this.book.authors) {