Author JSON is now all lowercase

This commit is contained in:
konrad 2017-11-29 16:15:29 +01:00 committed by kolaente
parent 3d1a710ae0
commit 6f22a1a671
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
4 changed files with 21 additions and 21 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div v-if="user.authenticated"> <div v-if="user.authenticated">
<h1>{{ author.Forename }} {{ author.Lastname }}</h1> <h1>{{ author.forename }} {{ author.lastname }}</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;
@ -52,11 +52,11 @@
this.authorList = [ this.authorList = [
{ {
header: this.translate('authors').forename, header: this.translate('authors').forename,
content: this.author.Forename content: this.author.forename
}, },
{ {
header: this.translate('authors').lastname, header: this.translate('authors').lastname,
content: this.author.Lastname content: this.author.lastname
} }
] ]

View File

@ -154,8 +154,8 @@ export default {
// Loop throught the data we got from our API and prepare an array to display all authors // Loop throught the data we got from our API and prepare an array to display all authors
for (const b in bs) { for (const b in bs) {
this.authors[i] = { this.authors[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
Name: {content: bs[b].Forename + ' ' + bs[b].Lastname, link: '/authors/' + bs[b].ID} // Add a link to the element name: {content: bs[b].forename + ' ' + bs[b].lastname, link: '/authors/' + bs[b].id} // Add a link to the element
} }
// increment dat shit // increment dat shit
@ -180,7 +180,7 @@ export default {
this.$on('delete-submit', function () { this.$on('delete-submit', function () {
// Prevent deleting already deleted authors // Prevent deleting already deleted authors
if (obj) { if (obj) {
HTTP.delete('authors/' + obj.ID.content) HTTP.delete('authors/' + 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
@ -202,7 +202,7 @@ export default {
}) })
}, },
editauthor (author) { editauthor (author) {
router.push({ name: 'author-edit', params: { id: author.ID.content } }) router.push({ name: 'author-edit', params: { id: author.id.content } })
} }
} }
} }

View File

@ -8,12 +8,12 @@
<form class="ui form" v-bind:class="{ loading: loading }" v-if="!success" @submit.prevent="insertOrUpdateAuthor"> <form class="ui form" v-bind:class="{ loading: loading }" v-if="!success" @submit.prevent="insertOrUpdateAuthor">
<div class="field"> <div class="field">
<label v-lang.authors.forename></label> <label v-lang.authors.forename></label>
<input name="forename" :placeholder="langAuthors.forename" type="text" v-model="author.Forename" v-focus> <input name="forename" :placeholder="langAuthors.forename" type="text" v-model="author.forename" v-focus>
</div> </div>
<div class="field"> <div class="field">
<label v-lang.authors.lastname></label> <label v-lang.authors.lastname></label>
<input name="lastname" :placeholder="langAuthors.lastname" type="text" v-model="author.Lastname" required> <input name="lastname" :placeholder="langAuthors.lastname" type="text" v-model="author.lastname" required>
</div> </div>
<button class="ui blue button" type="submit" v-lang.general.submit></button> <button class="ui blue button" type="submit" v-lang.general.submit></button>
@ -31,11 +31,11 @@
return { return {
success: '', success: '',
loading: false, loading: false,
authorID: this.$route.params.id, authorid: this.$route.params.id,
edit: false, edit: false,
author: { author: {
Forename: '', forename: '',
Lastname: '' lastname: ''
} }
} }
}, },
@ -43,8 +43,8 @@
this.loading = true this.loading = true
// Look if we're in edit mode and get the author infos if nessesary // Look if we're in edit mode and get the author infos if nessesary
if (this.authorID) { if (this.authorid) {
HTTP.get('authors/' + this.authorID) HTTP.get('authors/' + this.authorid)
.then(response => { .then(response => {
this.author = response.data this.author = response.data
this.edit = true this.edit = true
@ -76,7 +76,7 @@
}) })
}, },
insertOrUpdateAuthor: function () { insertOrUpdateAuthor: function () {
if (this.author.Lastname === '') { if (this.author.lastname === '') {
// Fire a notification // Fire a notification
this.$notify({ this.$notify({
type: 'warn', type: 'warn',
@ -88,7 +88,7 @@
// 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('authors/' + this.author.ID, {author: this.author}) HTTP.post('authors/' + this.author.id, {author: this.author})
.then(response => { .then(response => {
this.loading = false this.loading = false

View File

@ -2,11 +2,11 @@ package models
// Author holds infos about an author // Author holds infos about an author
type Author struct { type Author struct {
ID int64 `xorm:"int(11) autoincr not null unique pk"` ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
Forename string `xorm:"varchar(250)"` Forename string `xorm:"varchar(250)" json:"forename"`
Lastname string `xorm:"varchar(250) not null"` Lastname string `xorm:"varchar(250) not null" json:"lastname"`
Created int64 `xorm:"created"` Created int64 `xorm:"created" json:"created"`
Updated int64 `xorm:"updated"` Updated int64 `xorm:"updated" json:"updated"`
} }
// TableName returns the table name for struct author // TableName returns the table name for struct author