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

View File

@ -122,8 +122,8 @@ export default {
},
computed: {
filteredData: function () {
var filterKey = this.searchQuery && this.searchQuery.toLowerCase()
var data = this.books
let filterKey = this.searchQuery && this.searchQuery.toLowerCase()
let data = this.books
if (filterKey) {
data = data.filter(function (row) {
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
for (const b in bs) {
this.books[i] = {
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
ISBN: {content: bs[b].Isbn}, // We can also just use the content column
Year: bs[b].Year,
Price: bs[b].Price + '€',
Author: '',
Publisher: bs[b].Publisher.Name,
Quantity: bs[b].Quantity,
Status: bs[b].Status
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
isbn: {content: bs[b].isbn}, // We can also just use the content column
year: bs[b].year,
price: bs[b].price + '€',
author: '',
publisher: bs[b].publisher.name,
quantity: bs[b].quantity,
status: bs[b].status
}
// 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) {
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) {
this.books[i].Author += ', '
this.books[i].author += ', '
}
}
// 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
i++
@ -235,7 +235,7 @@ export default {
this.$on('delete-submit', function () {
// Prevent deleting already deleted books
if (obj) {
HTTP.delete('books/' + obj.ID.content)
HTTP.delete('books/' + obj.id.content)
.then(response => {
if (response.status === 200 && response.data.Message === 'success') {
// Fire a notification
@ -257,7 +257,7 @@ export default {
})
},
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">
<div class="field">
<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 class="field">
<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 class="three fields">
<div class="field">
<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 class="field">
<label v-lang.books.gridColumns.price></label>
<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>
</div>
</div>
<div class="field">
<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 class="field">
<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>
@ -35,9 +35,9 @@
<label v-lang.books.gridColumns.publisher></label>
<a class="ui green icon button add-publisher-btn" @click="toggleAddPublisher()"><i class="plus icon"></i></a>
<multiselect
v-model="book.Publisher"
track-by="ID"
label="Name"
v-model="book.publisher"
track-by="id"
label="name"
:placeholder="langGeneral.selectOne"
:options="publishers"
:searchable="true"
@ -48,15 +48,15 @@
<div class="field" v-if="addPublisherForm">
<label v-lang.publishers.newPublisher></label>
<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 class="field">
<label v-lang.books.gridColumns.authors></label>
<multiselect
v-model="book.Authors"
track-by="ID"
label="Name"
v-model="book.authors"
track-by="id"
label="name"
:placeholder="langGeneral.selectOneOrMore"
:options="authors"
:searchable="true"
@ -81,8 +81,8 @@
<label v-lang.books.gridColumns.status></label>
<div class="field" v-for="status in allStatus">
<div class="ui radio checkbox">
<input name="status" :id="status.ID" :value="status.ID" class="hidden" type="radio" v-model="book.Status"/>
<label :for="status.ID">{{ status.Name }}</label>
<input name="status" :id="status.id" :value="status.id" class="hidden" type="radio" v-model="book.status"/>
<label :for="status.id">{{ status.Name }}</label>
</div>
</div>
</div>
@ -104,16 +104,16 @@
bookID: this.$route.params.id,
edit: false,
book: {
Title: '',
Description: '',
Isbn: '',
Year: (new Date()).getFullYear(),
Price: 0,
Status: 0,
Quantity: 0,
Publisher: {
ID: 0,
Name: ''
title: '',
description: '',
isbn: '',
year: (new Date()).getFullYear(),
price: 0,
status: 0,
quantity: 0,
publisher: {
id: 0,
name: ''
},
Authors: []
},
@ -151,12 +151,12 @@
this.edit = true
// Loop through all authors and reverse them
let as = this.book.Authors
let as = this.book.authors
for (const i in as) {
this.book.Authors[i] = {
ID: as[i].ID,
Name: as[i].Forename + ' ' + as[i].Lastname
this.book.authors[i] = {
id: as[i].id,
name: as[i].forename + ' ' + as[i].lastname
}
}
})
@ -197,8 +197,8 @@
for (const i in as) {
this.authors[i] = {
ID: as[i].ID,
Name: as[i].Forename + ' ' + as[i].Lastname
id: as[i].id,
name: as[i].forename + ' ' + as[i].lastname
}
}
})
@ -217,7 +217,7 @@
},
toggleAddPublisher: function () {
this.addPublisherForm = !this.addPublisherForm
this.book.Publisher = {ID: 0, Name: ''}
this.book.publisher = {id: 0, name: ''}
},
addAddAuthor: function () {
this.addAuthorForm.push({
@ -230,7 +230,7 @@
this.addAuthorForm.splice(i, 1)
},
insertNewBook: function () {
if (this.book.Title === '') {
if (this.book.title === '') {
// Fire a notification
this.$notify({
type: 'warn',
@ -243,15 +243,15 @@
let as = this.newAuthors
for (const i in as) {
this.book.Authors.push({
ID: 0,
Name: as[i]
this.book.authors.push({
id: 0,
name: as[i]
})
}
// Beautify all Authors aka split the names in forename and lastname
for (const i in this.book.Authors) {
let author = this.book.Authors[i].Name
for (const i in this.book.authors) {
let author = this.book.authors[i].name
let firstname = ''
let lastname = ''
@ -266,17 +266,17 @@
}
// Put it all together
this.book.Authors[i] = {
ID: this.book.Authors[i].ID,
Forename: firstname,
Lastname: lastname
this.book.authors[i] = {
id: this.book.authors[i].id,
forename: firstname,
lastname: lastname
}
}
// Finally Send it
// If we want to newly insert it, make a different request
if (this.edit) {
HTTP.post('books/' + this.book.ID, {book: this.book})
HTTP.post('books/' + this.book.id, {book: this.book})
.then(response => {
this.loading = false

View File

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