aboutsummaryrefslogtreecommitdiff
path: root/src/components/media_upload/media_upload.js
diff options
context:
space:
mode:
authorshpuld <shpuld@gmail.com>2017-02-21 15:13:19 +0200
committershpuld <shpuld@gmail.com>2017-02-21 15:13:19 +0200
commitca71722c1eaa5c2aa4597bef38ca812c15294359 (patch)
treed9ebca87d8c59923f3c1572f3d2028154ded04da /src/components/media_upload/media_upload.js
parent842e15a314bd3737629b827c9e7ebd6c47d3d6ba (diff)
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.
Diffstat (limited to 'src/components/media_upload/media_upload.js')
-rw-r--r--src/components/media_upload/media_upload.js26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js
index 3f2e3964..3f6fec5b 100644
--- a/src/components/media_upload/media_upload.js
+++ b/src/components/media_upload/media_upload.js
@@ -3,12 +3,22 @@ import statusPosterService from '../../services/status_poster/status_poster.serv
const mediaUpload = {
mounted () {
- const store = this.$store
const input = this.$el.querySelector('input')
- const self = this
input.addEventListener('change', ({target}) => {
const file = target.files[0]
+ this.uploadFile(file)
+ })
+ },
+ data () {
+ return {
+ uploading: false
+ }
+ },
+ methods: {
+ uploadFile(file) {
+ const self = this
+ const store = this.$store
const formData = new FormData()
formData.append('media', file)
@@ -23,11 +33,15 @@ const mediaUpload = {
self.$emit('upload-failed')
self.uploading = false
})
- })
+ }
},
- data () {
- return {
- uploading: false
+ props: [
+ 'dropFiles'
+ ],
+ watch: {
+ 'dropFiles': function (fileInfos) {
+ if (!this.uploading)
+ this.uploadFile(fileInfos[0])
}
}
}