Get status dynamically
the build was successful Details

This commit is contained in:
konrad 2017-11-15 16:26:51 +01:00 committed by kolaente
parent e12bcc0706
commit 249bef444e
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 23 additions and 17 deletions

View File

@ -10,7 +10,14 @@
</template>
</div>
<form class="ui form" v-bind:class="{ loading: loading }">
<div class="ui positive message" v-if="success">
<div class="header">
Success
</div>
{{ success }}
</div>
<form class="ui form" v-bind:class="{ loading: loading }" v-if="!success">
<div class="field">
<label>Title</label>
<input name="title" placeholder="Title" type="text" v-model="book.Title">
@ -83,8 +90,8 @@
<label>Status</label>
<div class="field" v-for="status in allStatus">
<div class="ui radio checkbox">
<input name="status" :id="status.value" :value="status.value" class="hidden" type="radio" v-model="book.Status"/>
<label :for="status.value">{{ 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>
@ -102,6 +109,7 @@
data () {
return {
error: '',
success: '',
loading: false,
book: {
Title: '',
@ -121,25 +129,13 @@
addAuthorForm: [],
newAuthors: {},
newestAuthor: 0,
allStatus: [
{
name: 'New',
value: 1
},
{
name: 'Second Hand',
value: 2
},
{
name: 'Other',
value: 3
}
]
allStatus: []
}
},
created () {
this.loadPublishers()
this.loadAuthors()
this.loadStatus()
},
methods: {
loadPublishers: function () {
@ -167,6 +163,15 @@
this.error = e
})
},
loadStatus: function () {
HTTP.get('status')
.then(response => {
this.allStatus = response.data
})
.catch(e => {
this.error = e
})
},
toggleAddPublisher: function () {
this.addPublisherForm = !this.addPublisherForm
this.book.PublisherFull = {ID: 0, Name: ''}
@ -223,6 +228,7 @@
.then(response => {
this.loading = false
console.log(response)
this.success = 'The book was successfully inserted!'
})
.catch(e => {
this.loading = false