From 9aaa8a86f52bc97838c768a8859919a3ad6fd54f Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Thu, 13 Apr 2023 01:11:20 +0300 Subject: initial implementation of attachmentsetting --- .../settings_modal/helpers/attachment_setting.js | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/components/settings_modal/helpers/attachment_setting.js (limited to 'src/components/settings_modal/helpers/attachment_setting.js') diff --git a/src/components/settings_modal/helpers/attachment_setting.js b/src/components/settings_modal/helpers/attachment_setting.js new file mode 100644 index 00000000..a0a12ead --- /dev/null +++ b/src/components/settings_modal/helpers/attachment_setting.js @@ -0,0 +1,42 @@ +import Setting from './setting.js' +import { fileTypeExt } from 'src/services/file_type/file_type.service.js' +import MediaUpload from 'src/components/media_upload/media_upload.vue' +import Attachment from 'src/components/attachment/attachment.vue' + +export default { + ...Setting, + props: { + ...Setting.props, + type: { + type: Array, + required: false, + default: [] + } + }, + components: { + ...Setting.components, + MediaUpload, + Attachment + }, + computed: { + ...Setting.computed, + attachment () { + const path = this.realDraftMode ? this.draft : this.state + const url = path.includes('://') ? path : this.$store.state.instance.server + path + return { + mimetype: fileTypeExt(url), + url + } + } + }, + methods: { + ...Setting.methods, + setMediaFile (fileInfo) { + if (this.realDraftMode) { + this.draft = fileInfo.url + } else { + this.configSink(this.path, fileInfo.url) + } + } + } +} -- cgit v1.2.3-70-g09d2 From e0fbeee88edb29f04a3260560d10d1a812f84029 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 24 Apr 2023 21:57:31 +0300 Subject: finish up attachment setting (right now only for admin section only) --- src/components/media_upload/media_upload.js | 18 ++++++-- src/components/media_upload/media_upload.vue | 22 ++++++--- .../settings_modal/helpers/attachment_setting.js | 7 +-- .../settings_modal/helpers/attachment_setting.vue | 53 +++++++++++++++------- src/i18n/en.json | 2 + 5 files changed, 73 insertions(+), 29 deletions(-) (limited to 'src/components/settings_modal/helpers/attachment_setting.js') diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index cfd42d4c..8c9e5f71 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -23,6 +23,11 @@ const mediaUpload = { } }, methods: { + onClick () { + if (this.uploadReady) { + this.$refs.input.click() + } + }, uploadFile (file) { const self = this const store = this.$store @@ -69,10 +74,15 @@ const mediaUpload = { this.multiUpload(target.files) } }, - props: [ - 'dropFiles', - 'disabled' - ], + props: { + dropFiles: Object, + disabled: Boolean, + normalButton: Boolean, + acceptTypes: { + type: String, + default: '*/*' + } + }, watch: { dropFiles: function (fileInfos) { if (!this.uploading) { diff --git a/src/components/media_upload/media_upload.vue b/src/components/media_upload/media_upload.vue index 2799495b..c761b94f 100644 --- a/src/components/media_upload/media_upload.vue +++ b/src/components/media_upload/media_upload.vue @@ -1,8 +1,10 @@ @@ -32,10 +40,12 @@ @import "../../variables"; .media-upload { - cursor: pointer; // We use