Files dropped into post_status_form text box get sent to media_upload for attachment upload, media_upload reorganized a bit to allow reuse of existing code.

This commit is contained in:
shpuld 2017-02-21 15:13:19 +02:00
parent 842e15a314
commit ca71722c1e
3 changed files with 29 additions and 8 deletions

View file

@ -84,6 +84,7 @@ const PostStatusForm = {
}
return {
dropFiles: [],
submitDisabled: false,
newStatus: {
status: statusText,
@ -141,6 +142,12 @@ const PostStatusForm = {
},
type (fileInfo) {
return fileTypeService.fileType(fileInfo.mimetype)
},
fileDrop (e) {
if(e.dataTransfer.files.length > 0) {
e.preventDefault() // allow dropping text like before
this.dropFiles = e.dataTransfer.files
}
}
}
}

View file

@ -2,7 +2,7 @@
<div class="post-status-form">
<form @submit.prevent="postStatus(newStatus)">
<div class="form-group" >
<textarea v-model="newStatus.status" placeholder="Just landed in L.A." rows="3" class="form-control" @keyup.ctrl.enter="postStatus(newStatus)"></textarea>
<textarea v-model="newStatus.status" placeholder="Just landed in L.A." rows="3" class="form-control" @keyup.ctrl.enter="postStatus(newStatus)" @drop="fileDrop"></textarea>
</div>
<div class="attachments">
<div class="attachment" v-for="file in newStatus.files">
@ -14,7 +14,7 @@
</div>
</div>
<div class='form-bottom'>
<media-upload @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="enableSubmit"></media-upload>
<media-upload @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="enableSubmit" :drop-files="dropFiles"></media-upload>
<button :disabled="submitDisabled" type="submit" class="btn btn-default">Submit</button>
</div>
</form>