aboutsummaryrefslogtreecommitdiff
path: root/src/components/post_status_form
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/post_status_form
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/post_status_form')
-rw-r--r--src/components/post_status_form/post_status_form.js7
-rw-r--r--src/components/post_status_form/post_status_form.vue4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
index 3365c569..e798b196 100644
--- a/src/components/post_status_form/post_status_form.js
+++ b/src/components/post_status_form/post_status_form.js
@@ -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
+ }
}
}
}
diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue
index 1bad41c7..57572f65 100644
--- a/src/components/post_status_form/post_status_form.vue
+++ b/src/components/post_status_form/post_status_form.vue
@@ -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>