Disable the submit button while uploading attachment

This commit is contained in:
dtluna 2016-11-25 01:07:21 +03:00
parent 93be453037
commit 96b4997492
2 changed files with 17 additions and 4 deletions

View file

@ -22,12 +22,14 @@ const PostStatusForm = {
props: [ props: [
'replyTo', 'replyTo',
'repliedUser', 'repliedUser',
'attentions' 'attentions',
'submitDisabled'
], ],
components: { components: {
MediaUpload MediaUpload
}, },
data () { data () {
this.submitDisabled = false
let statusText = '' let statusText = ''
if (this.replyTo) { if (this.replyTo) {
@ -58,6 +60,13 @@ const PostStatusForm = {
}, },
addMediaFile (fileInfo) { addMediaFile (fileInfo) {
this.newStatus.files.push(fileInfo) this.newStatus.files.push(fileInfo)
this.enableSubmit()
},
disableSubmit () {
this.submitDisabled = true
},
enableSubmit () {
this.submitDisabled = false
} }
} }
} }

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="post-status-form"> <div class="post-status-form">
<form v-on:submit.prevent="postStatus(newStatus)"> <form @submit.prevent="postStatus(newStatus)">
<div class="form-group" > <div class="form-group" >
<textarea v-model="newStatus.status" placeholder="Just landed in L.A." rows="3" class="form-control"></textarea> <textarea v-model="newStatus.status" placeholder="Just landed in L.A." rows="3" class="form-control"></textarea>
</div> </div>
@ -10,8 +10,8 @@
</div> </div>
</div> </div>
<div class='form-bottom'> <div class='form-bottom'>
<media-upload v-on:uploaded="addMediaFile"></media-upload> <media-upload @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="enableSubmit"></media-upload>
<button type="submit" class="btn btn-default" >Submit</button> <button :disabled="submitDisabled" type="submit" class="btn btn-default">Submit</button>
</div> </div>
</form> </form>
</div> </div>
@ -49,6 +49,10 @@
.btn { .btn {
cursor: pointer; cursor: pointer;
} }
.btn[disabled] {
cursor: not-allowed;
}
} }
</style> </style>