Fixed error where creating a new author would fail when the book initially had no authors
This commit is contained in:
parent
28b5231199
commit
19932ca7e4
|
@ -104,6 +104,7 @@
|
||||||
bookID: this.$route.params.id,
|
bookID: this.$route.params.id,
|
||||||
edit: false,
|
edit: false,
|
||||||
book: {
|
book: {
|
||||||
|
authors: [],
|
||||||
title: '',
|
title: '',
|
||||||
description: '',
|
description: '',
|
||||||
isbn: '',
|
isbn: '',
|
||||||
|
@ -114,8 +115,7 @@
|
||||||
publisher: {
|
publisher: {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: ''
|
name: ''
|
||||||
},
|
}
|
||||||
Authors: []
|
|
||||||
},
|
},
|
||||||
publishers: [],
|
publishers: [],
|
||||||
authors: [],
|
authors: [],
|
||||||
|
@ -159,6 +159,12 @@
|
||||||
name: as[i].forename + ' ' + as[i].lastname
|
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 => {
|
.catch(e => {
|
||||||
this.errorNotification(e)
|
this.errorNotification(e)
|
||||||
|
@ -242,12 +248,15 @@
|
||||||
// Add all newly created authors to it
|
// Add all newly created authors to it
|
||||||
let as = this.newAuthors
|
let as = this.newAuthors
|
||||||
|
|
||||||
|
console.log(this.book, this.newAuthors)
|
||||||
|
|
||||||
for (const i in as) {
|
for (const i in as) {
|
||||||
this.book.authors.push({
|
this.book.authors.push({
|
||||||
id: 0,
|
id: 0,
|
||||||
name: as[i]
|
name: as[i]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
console.log(this.book.authors, this.newAuthors)
|
||||||
|
|
||||||
// Beautify all Authors aka split the names in forename and lastname
|
// Beautify all Authors aka split the names in forename and lastname
|
||||||
for (const i in this.book.authors) {
|
for (const i in this.book.authors) {
|
||||||
|
|
Loading…
Reference in New Issue