From 19932ca7e4052292099e3756fdbdc3311f11df07 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 5 Dec 2017 14:19:44 +0100 Subject: [PATCH] Fixed error where creating a new author would fail when the book initially had no authors --- frontend/src/components/BooksAddEdit.vue | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/BooksAddEdit.vue b/frontend/src/components/BooksAddEdit.vue index 130be2f..05a69b6 100644 --- a/frontend/src/components/BooksAddEdit.vue +++ b/frontend/src/components/BooksAddEdit.vue @@ -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) {