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