Book JSON is now all lowercase
the build failed Details

This commit is contained in:
konrad 2017-11-29 16:43:58 +01:00 committed by kolaente
parent 37a39cbae6
commit c3d6032bcf
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 86 additions and 86 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div v-if="user.authenticated"> <div v-if="user.authenticated">
<h1>{{ book.Title }}</h1> <h1>{{ book.title }}</h1>
<div class="ui info message" v-if="loading"> <div class="ui info message" v-if="loading">
<icon name="refresh" spin></icon>&nbsp;&nbsp; <icon name="refresh" spin></icon>&nbsp;&nbsp;
@ -67,56 +67,56 @@
this.book = response.data this.book = response.data
// Get all authors and build an array with them // Get all authors and build an array with them
let authors = this.book.Authors let authors = this.book.authors
for (const au in authors) { for (const au in authors) {
this.AuthorList.push({ this.AuthorList.push({
content: authors[au].Forename + ' ' + authors[au].Lastname, content: authors[au].forename + ' ' + authors[au].lastname,
link: { link: {
name: 'author-show', name: 'author-show',
params: { params: {
id: authors[au].ID id: authors[au].id
} }
} }
}) })
} }
// Make Status a name, not an id // Make Status a name, not an id
this.book.Status = this.getStatusByID(this.book.Status) this.book.status = this.getStatusByID(this.book.status)
this.loading = false this.loading = false
// Build the list object // Build the list object
this.bookList = [ this.bookList = [
{ {
header: this.translate('books').description, header: this.translate('books').description,
content: this.book.Description.replace(/\n/g, '<br>') content: this.book.description.replace(/\n/g, '<br>')
}, },
{ {
header: this.translate('books').gridColumns.isbn, header: this.translate('books').gridColumns.isbn,
content: this.book.Isbn content: this.book.isbn
}, },
{ {
header: this.translate('books').gridColumns.year, header: this.translate('books').gridColumns.year,
content: this.book.Year content: this.book.year
}, },
{ {
header: this.translate('books').gridColumns.price, header: this.translate('books').gridColumns.price,
content: this.book.Price content: this.book.price
}, },
{ {
header: this.translate('books').gridColumns.quantity, header: this.translate('books').gridColumns.quantity,
content: this.book.Quantity content: this.book.quantity
}, },
{ {
header: this.translate('books').gridColumns.status, header: this.translate('books').gridColumns.status,
content: this.book.Status content: this.book.status
}, },
{ {
header: this.translate('books').gridColumns.publisher, header: this.translate('books').gridColumns.publisher,
content: this.book.Publisher.Name, content: this.book.publisher.name,
link: { link: {
name: 'publisher-show', name: 'publisher-show',
params: { params: {
id: this.book.Publisher.ID id: this.book.publisher.id
} }
} }
}, },

View File

@ -122,8 +122,8 @@ export default {
}, },
computed: { computed: {
filteredData: function () { filteredData: function () {
var filterKey = this.searchQuery && this.searchQuery.toLowerCase() let filterKey = this.searchQuery && this.searchQuery.toLowerCase()
var data = this.books let data = this.books
if (filterKey) { if (filterKey) {
data = data.filter(function (row) { data = data.filter(function (row) {
return Object.keys(row).some(function (key) { return Object.keys(row).some(function (key) {
@ -170,28 +170,28 @@ export default {
// Loop throught the data we got from our API and prepare an array to display all books // Loop throught the data we got from our API and prepare an array to display all books
for (const b in bs) { for (const b in bs) {
this.books[i] = { this.books[i] = {
ID: {content: bs[b].ID, hide: true}, // Don't show the ID id: {content: bs[b].id, hide: true}, // Don't show the ID
Title: {content: bs[b].Title, link: '/books/' + bs[b].ID}, // Add a link to the element title: {content: bs[b].title, link: '/books/' + bs[b].id}, // Add a link to the element
ISBN: {content: bs[b].Isbn}, // We can also just use the content column isbn: {content: bs[b].isbn}, // We can also just use the content column
Year: bs[b].Year, year: bs[b].year,
Price: bs[b].Price + '€', price: bs[b].price + '€',
Author: '', author: '',
Publisher: bs[b].Publisher.Name, publisher: bs[b].publisher.name,
Quantity: bs[b].Quantity, quantity: bs[b].quantity,
Status: bs[b].Status status: bs[b].status
} }
// Get all authors and concat them into one singe string // Get all authors and concat them into one singe string
let authors = bs[b].Authors let authors = bs[b].authors
for (const au in authors) { for (const au in authors) {
this.books[i].Author += authors[au].Forename + ' ' + authors[au].Lastname this.books[i].author += authors[au].forename + ' ' + authors[au].lastname
if (authors.length > au + 1) { if (authors.length > au + 1) {
this.books[i].Author += ', ' this.books[i].author += ', '
} }
} }
// Make Status a name, not an id // Make Status a name, not an id
this.books[i].Status = this.getStatusByID(this.books[i].Status) this.books[i].status = this.getStatusByID(this.books[i].status)
// increment dat shit // increment dat shit
i++ i++
@ -235,7 +235,7 @@ export default {
this.$on('delete-submit', function () { this.$on('delete-submit', function () {
// Prevent deleting already deleted books // Prevent deleting already deleted books
if (obj) { if (obj) {
HTTP.delete('books/' + obj.ID.content) HTTP.delete('books/' + obj.id.content)
.then(response => { .then(response => {
if (response.status === 200 && response.data.Message === 'success') { if (response.status === 200 && response.data.Message === 'success') {
// Fire a notification // Fire a notification
@ -257,7 +257,7 @@ export default {
}) })
}, },
editBook (book) { editBook (book) {
router.push({ name: 'book-edit', params: { id: book.ID.content } }) router.push({ name: 'book-edit', params: { id: book.id.content } })
} }
} }
} }

View File

@ -3,31 +3,31 @@
<form class="ui form" :class="{ loading: loading }" @submit.prevent="insertNewBook"> <form class="ui form" :class="{ loading: loading }" @submit.prevent="insertNewBook">
<div class="field"> <div class="field">
<label v-lang.books.gridColumns.title></label> <label v-lang.books.gridColumns.title></label>
<input name="title" :placeholder="langBooks.gridColumns.title" type="text" v-model="book.Title" required v-focus> <input name="title" :placeholder="langBooks.gridColumns.title" type="text" v-model="book.title" required v-focus>
</div> </div>
<div class="field"> <div class="field">
<label v-lang.books.description></label> <label v-lang.books.description></label>
<textarea name="description" :placeholder="langBooks.description" rows="3" v-model="book.Description"></textarea> <textarea name="description" :placeholder="langBooks.description" rows="3" v-model="book.description"></textarea>
</div> </div>
<div class="three fields"> <div class="three fields">
<div class="field"> <div class="field">
<label v-lang.books.gridColumns.isbn></label> <label v-lang.books.gridColumns.isbn></label>
<input name="isbn" :placeholder="langBooks.gridColumns.isbn" type="text" v-model="book.Isbn"> <input name="isbn" :placeholder="langBooks.gridColumns.isbn" type="text" v-model="book.isbn">
</div> </div>
<div class="field"> <div class="field">
<label v-lang.books.gridColumns.price></label> <label v-lang.books.gridColumns.price></label>
<div class="ui right labeled input "> <div class="ui right labeled input ">
<input name="price" :placeholder="langBooks.gridColumns.price" type="number" step="0.01" min="0" v-model.number="book.Price"> <input name="price" :placeholder="langBooks.gridColumns.price" type="number" step="0.01" min="0" v-model.number="book.price">
<label class="ui label"></label> <label class="ui label"></label>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label v-lang.books.gridColumns.year></label> <label v-lang.books.gridColumns.year></label>
<input name="year" :placeholder="langBooks.gridColumns.year" type="number" step="1" min="1800" v-model.number="book.Year"> <input name="year" :placeholder="langBooks.gridColumns.year" type="number" step="1" min="1800" v-model.number="book.year">
</div> </div>
<div class="field"> <div class="field">
<label v-lang.books.gridColumns.quantity></label> <label v-lang.books.gridColumns.quantity></label>
<input :placeholder="langBooks.gridColumns.quantity" type="number" min="0" step="1" v-model.number="book.Quantity"> <input :placeholder="langBooks.gridColumns.quantity" type="number" min="0" step="1" v-model.number="book.quantity">
</div> </div>
</div> </div>
@ -35,9 +35,9 @@
<label v-lang.books.gridColumns.publisher></label> <label v-lang.books.gridColumns.publisher></label>
<a class="ui green icon button add-publisher-btn" @click="toggleAddPublisher()"><i class="plus icon"></i></a> <a class="ui green icon button add-publisher-btn" @click="toggleAddPublisher()"><i class="plus icon"></i></a>
<multiselect <multiselect
v-model="book.Publisher" v-model="book.publisher"
track-by="ID" track-by="id"
label="Name" label="name"
:placeholder="langGeneral.selectOne" :placeholder="langGeneral.selectOne"
:options="publishers" :options="publishers"
:searchable="true" :searchable="true"
@ -48,15 +48,15 @@
<div class="field" v-if="addPublisherForm"> <div class="field" v-if="addPublisherForm">
<label v-lang.publishers.newPublisher></label> <label v-lang.publishers.newPublisher></label>
<a class="ui green icon button add-publisher-btn" @click="toggleAddPublisher()"><i class="list icon"></i></a> <a class="ui green icon button add-publisher-btn" @click="toggleAddPublisher()"><i class="list icon"></i></a>
<input name="name" :placeholder="langPublishers.newPublisher" type="text" v-model="book.Publisher.Name" class="add-publisher"> <input name="name" :placeholder="langPublishers.newPublisher" type="text" v-model="book.Publisher.name" class="add-publisher">
</div> </div>
<div class="field"> <div class="field">
<label v-lang.books.gridColumns.authors></label> <label v-lang.books.gridColumns.authors></label>
<multiselect <multiselect
v-model="book.Authors" v-model="book.authors"
track-by="ID" track-by="id"
label="Name" label="name"
:placeholder="langGeneral.selectOneOrMore" :placeholder="langGeneral.selectOneOrMore"
:options="authors" :options="authors"
:searchable="true" :searchable="true"
@ -81,8 +81,8 @@
<label v-lang.books.gridColumns.status></label> <label v-lang.books.gridColumns.status></label>
<div class="field" v-for="status in allStatus"> <div class="field" v-for="status in allStatus">
<div class="ui radio checkbox"> <div class="ui radio checkbox">
<input name="status" :id="status.ID" :value="status.ID" class="hidden" type="radio" v-model="book.Status"/> <input name="status" :id="status.id" :value="status.id" class="hidden" type="radio" v-model="book.status"/>
<label :for="status.ID">{{ status.Name }}</label> <label :for="status.id">{{ status.Name }}</label>
</div> </div>
</div> </div>
</div> </div>
@ -104,16 +104,16 @@
bookID: this.$route.params.id, bookID: this.$route.params.id,
edit: false, edit: false,
book: { book: {
Title: '', title: '',
Description: '', description: '',
Isbn: '', isbn: '',
Year: (new Date()).getFullYear(), year: (new Date()).getFullYear(),
Price: 0, price: 0,
Status: 0, status: 0,
Quantity: 0, quantity: 0,
Publisher: { publisher: {
ID: 0, id: 0,
Name: '' name: ''
}, },
Authors: [] Authors: []
}, },
@ -151,12 +151,12 @@
this.edit = true this.edit = true
// Loop through all authors and reverse them // Loop through all authors and reverse them
let as = this.book.Authors let as = this.book.authors
for (const i in as) { for (const i in as) {
this.book.Authors[i] = { this.book.authors[i] = {
ID: as[i].ID, id: as[i].id,
Name: as[i].Forename + ' ' + as[i].Lastname name: as[i].forename + ' ' + as[i].lastname
} }
} }
}) })
@ -197,8 +197,8 @@
for (const i in as) { for (const i in as) {
this.authors[i] = { this.authors[i] = {
ID: as[i].ID, id: as[i].id,
Name: as[i].Forename + ' ' + as[i].Lastname name: as[i].forename + ' ' + as[i].lastname
} }
} }
}) })
@ -217,7 +217,7 @@
}, },
toggleAddPublisher: function () { toggleAddPublisher: function () {
this.addPublisherForm = !this.addPublisherForm this.addPublisherForm = !this.addPublisherForm
this.book.Publisher = {ID: 0, Name: ''} this.book.publisher = {id: 0, name: ''}
}, },
addAddAuthor: function () { addAddAuthor: function () {
this.addAuthorForm.push({ this.addAuthorForm.push({
@ -230,7 +230,7 @@
this.addAuthorForm.splice(i, 1) this.addAuthorForm.splice(i, 1)
}, },
insertNewBook: function () { insertNewBook: function () {
if (this.book.Title === '') { if (this.book.title === '') {
// Fire a notification // Fire a notification
this.$notify({ this.$notify({
type: 'warn', type: 'warn',
@ -243,15 +243,15 @@
let as = this.newAuthors let as = 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]
}) })
} }
// 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) {
let author = this.book.Authors[i].Name let author = this.book.authors[i].name
let firstname = '' let firstname = ''
let lastname = '' let lastname = ''
@ -266,17 +266,17 @@
} }
// Put it all together // Put it all together
this.book.Authors[i] = { this.book.authors[i] = {
ID: this.book.Authors[i].ID, id: this.book.authors[i].id,
Forename: firstname, forename: firstname,
Lastname: lastname lastname: lastname
} }
} }
// Finally Send it // Finally Send it
// If we want to newly insert it, make a different request // If we want to newly insert it, make a different request
if (this.edit) { if (this.edit) {
HTTP.post('books/' + this.book.ID, {book: this.book}) HTTP.post('books/' + this.book.id, {book: this.book})
.then(response => { .then(response => {
this.loading = false this.loading = false

View File

@ -6,20 +6,20 @@ import (
// Book holds a book // Book holds a book
type Book struct { type Book struct {
ID int64 `xorm:"int(11) autoincr not null unique pk"` ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
Title string `xorm:"varchar(250) not null"` Title string `xorm:"varchar(250) not null" json:"title"`
Description string `xorm:"varchar(750)"` Description string `xorm:"varchar(750)" json:"description"`
Isbn string `xorm:"varchar(30)"` Isbn string `xorm:"varchar(30)" json:"isbn"`
Year int64 `xorm:"int(11)"` Year int64 `xorm:"int(11)" json:"year"`
Price float64 `xorm:"double"` Price float64 `xorm:"double" json:"price"`
Status int64 `xorm:"int(11)"` Status int64 `xorm:"int(11)" json:"status"`
PublisherID int64 `xorm:"int(11)"` PublisherID int64 `xorm:"int(11)" json:"publisherID"`
Created int64 `xorm:"created"` Created int64 `xorm:"created" json:"created"`
Updated int64 `xorm:"updated"` Updated int64 `xorm:"updated" json:"updated"`
Quantity int64 `xorm:"-"` Quantity int64 `xorm:"-" json:"quantity"`
Publisher Publisher `xorm:"-"` Publisher Publisher `xorm:"-" json:"publisher"`
Authors []Author `xorm:"-"` Authors []Author `xorm:"-" json:"authors"`
} }
// TableName returns the name for the books table // TableName returns the name for the books table