Added show a single publisher
the build was successful Details

This commit is contained in:
konrad 2017-11-21 13:38:20 +01:00 committed by kolaente
parent 8a8bd44a21
commit 8767737ee4
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 84 additions and 1 deletions

View File

@ -0,0 +1,77 @@
<template>
<div v-if="user.authenticated">
<h1>{{ publisher.Name }}</h1>
<div class="ui info message" v-if="loading">
<icon name="refresh" spin></icon>&nbsp;&nbsp;
Loading...
</div>
<div class="ui negative message" v-if="error">
<div class="header">
An error occured.
</div>
{{ error.message }}
<p v-if="error.response.data">
{{ error.response.data.Message }}
</p>
</div>
<div v-if="!loading && !error">
<router-link :to="{ name: 'publisher-edit', params: { id: publisherID} }" class="ui teal labeled icon button" style="float: right;">
<i class="edit icon"></i>
Edit
</router-link>
<div class="ui list">
<div class="item">
<div class="header">
Name
</div>
{{ publisher.Name }}
</div>
</div>
</div>
</div>
</template>
<script>
import auth from '../auth'
import {HTTP} from '../http-common'
export default {
name: 'Publisher',
data () {
return {
user: auth.user,
publisher: {},
error: '',
success: '',
publisherID: this.$route.params.id
}
},
created () {
this.loadPublisher()
},
watch: {
// call again the method if the route changes
'$route': 'loadPublisher'
},
methods: {
loadPublisher () {
this.loading = true
this.publisher = {}
HTTP.get(`publishers/` + this.publisherID)
.then(response => {
this.publisher = response.data
this.loading = false
})
.catch(e => {
this.loading = false
this.error = e
})
}
}
}
</script>

View File

@ -156,7 +156,7 @@ export default {
for (const b in bs) {
this.publishers[i] = {
ID: {content: bs[b].ID, hide: true}, // Don't show the ID
Name: {content: bs[b].Name, link: '/publisher/' + 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

View File

@ -10,6 +10,7 @@ import AuthorsAddEdit from '@/components/AuthorsAddEdit'
import AuthorOverview from '@/components/AuthorOverview'
import Publishers from '@/components/Publishers'
import PublishersAddEdit from '@/components/PublishersAddEdit'
import PublisherOverview from '@/components/PublisherOverview'
Vue.use(Router)
@ -75,6 +76,11 @@ export default new Router({
name: 'publishers-add',
component: PublishersAddEdit
},
{
path: '/publishers/:id',
name: 'publisher-show',
component: PublisherOverview
},
{
path: '/publishers/:id/edit',
name: 'publisher-edit',