Publisher JSON is now all lowercase

This commit is contained in:
konrad 2017-11-29 16:23:19 +01:00 committed by kolaente
parent 6f22a1a671
commit 37a39cbae6
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
5 changed files with 16 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div v-if="user.authenticated"> <div v-if="user.authenticated">
<h1>{{ publisher.Name }}</h1> <h1>{{ publisher.name }}</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;
@ -51,7 +51,7 @@
this.publisherList = [ this.publisherList = [
{ {
header: this.translate('general').name, header: this.translate('general').name,
content: this.publisher.Name content: this.publisher.name
} }
] ]

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.publishers[i] = { this.publishers[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].Name, link: '/publishers/' + bs[b].ID} // Add a link to the element name: {content: bs[b].name, link: '/publishers/' + bs[b].id} // Add a link to the element
} }
// increment dat shit // increment dat shit
@ -179,7 +179,7 @@ export default {
this.$on('delete-submit', function () { this.$on('delete-submit', function () {
// Prevent again deleting already deleted publishers // Prevent again deleting already deleted publishers
if (obj) { if (obj) {
HTTP.delete('publishers/' + obj.ID.content) HTTP.delete('publishers/' + 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
@ -200,7 +200,7 @@ export default {
}) })
}, },
editPublisher (publisher) { editPublisher (publisher) {
router.push({ name: 'publisher-edit', params: { id: publisher.ID.content } }) router.push({ name: 'publisher-edit', params: { id: publisher.id.content } })
} }
} }
} }

View File

@ -8,7 +8,7 @@
<form class="ui form" v-bind:class="{ loading: loading }" v-if="!success" @submit.prevent="insertOrUpdatePublisher"> <form class="ui form" v-bind:class="{ loading: loading }" v-if="!success" @submit.prevent="insertOrUpdatePublisher">
<div class="field"> <div class="field">
<label v-lang.general.name></label> <label v-lang.general.name></label>
<input name="Name" :placeholder="langGeneral.name" type="text" v-model="publisher.Name" required v-focus> <input name="name" :placeholder="langGeneral.name" type="text" v-model="publisher.name" required v-focus>
</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>
</form> </form>
@ -28,7 +28,7 @@
publisherID: this.$route.params.id, publisherID: this.$route.params.id,
edit: false, edit: false,
publisher: { publisher: {
Name: '' name: ''
} }
} }
}, },
@ -82,7 +82,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('publishers/' + this.publisher.ID, {publisher: this.publisher}) HTTP.post('publishers/' + this.publisher.id, {publisher: this.publisher})
.then(response => { .then(response => {
this.loading = false this.loading = false

View File

@ -2,10 +2,10 @@ package models
// Publisher holds publisher informations // Publisher holds publisher informations
type Publisher struct { type Publisher struct {
ID int64 `xorm:"int(11) autoincr not null unique pk"` ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"`
Name string `xorm:"varchar(250) not null"` Name string `xorm:"varchar(250) not null" json:"name"`
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 publishers struct // TableName returns the table name for publishers struct

View File

@ -17,7 +17,9 @@ func DeletePublisherByID(id int64) error {
} }
// Set all publisher to 0 on all book with this publisher // Set all publisher to 0 on all book with this publisher
_, err = x.Table("books").Where("publisher = ?", id).Update(map[string]interface{}{"publisher": 0}) _, err = x.Table("books").
Where("publisher_id = ?", id).
Update(map[string]interface{}{"publisher_id": 0})
return err return err
} }