diff --git a/src/components/attachment/attachment.js b/src/components/attachment/attachment.js index 47ca03de..9f751863 100644 --- a/src/components/attachment/attachment.js +++ b/src/components/attachment/attachment.js @@ -1,4 +1,5 @@ import nsfwImage from '../../assets/nsfw.jpg' +import fileTypeService from '../../services/file_type/file_type.service.js' const Attachment = { props: [ @@ -9,25 +10,7 @@ const Attachment = { data: () => ({ nsfwImage }), computed: { type () { - let type = 'unknown' - - if (this.attachment.mimetype.match(/text\/html/)) { - type = 'html' - } - - if (this.attachment.mimetype.match(/image/)) { - type = 'image' - } - - if (this.attachment.mimetype.match(/video\/(webm|mp4)/)) { - type = 'video' - }; - - if (this.attachment.mimetype.match(/ogg|audio/)) { - type = 'audio' - } - - return type + return fileTypeService.fileType(this.attachment.mimetype) } }, methods: { @@ -37,4 +20,4 @@ const Attachment = { } } -export default Attachment +export default Attachment \ No newline at end of file diff --git a/src/components/attachment/attachment.vue b/src/components/attachment/attachment.vue index d5578c04..1e49cbeb 100644 --- a/src/components/attachment/attachment.vue +++ b/src/components/attachment/attachment.vue @@ -4,7 +4,10 @@ - + + + diff --git a/src/components/media_upload/media_upload.vue b/src/components/media_upload/media_upload.vue index f2f0b83f..3302db37 100644 --- a/src/components/media_upload/media_upload.vue +++ b/src/components/media_upload/media_upload.vue @@ -15,4 +15,8 @@ font-size: 26px; flex: 1; } + + .icon-upload { + cursor: pointer; + } diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index f764a01b..b17fdaa1 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -1,5 +1,6 @@ import statusPoster from '../../services/status_poster/status_poster.service.js' import MediaUpload from '../media_upload/media_upload.vue' +import fileTypeService from '../../services/file_type/file_type.service.js' import { reject, map, uniqBy } from 'lodash' @@ -36,6 +37,7 @@ const PostStatusForm = { } return { + submitDisabled: false, newStatus: { status: statusText, files: [] @@ -58,6 +60,20 @@ const PostStatusForm = { }, addMediaFile (fileInfo) { this.newStatus.files.push(fileInfo) + this.enableSubmit() + }, + removeMediaFile (fileInfo) { + let index = this.newStatus.files.indexOf(fileInfo) + this.newStatus.files.splice(index, 1) + }, + disableSubmit () { + this.submitDisabled = true + }, + enableSubmit () { + this.submitDisabled = false + }, + type (fileInfo) { + return fileTypeService.fileType(fileInfo.mimetype) } } } diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 476ee51e..b18e5d80 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -1,17 +1,21 @@