From a4e764c82cb4774c9ffb4a2f2b742bccd7a53e44 Mon Sep 17 00:00:00 2001 From: Mikhail Sazanov Date: Wed, 8 Jun 2022 18:44:57 +0300 Subject: [PATCH] Move attachments to details, notify if attachment exists Signed-off-by: Mikhail Sazanov --- .../Editor/Attachments/AttachmentsList.vue | 144 ++++++++++-------- src/views/EditSidebar.vue | 27 +--- 2 files changed, 81 insertions(+), 90 deletions(-) diff --git a/src/components/Editor/Attachments/AttachmentsList.vue b/src/components/Editor/Attachments/AttachmentsList.vue index e9fb80e46f..d7106a4f60 100644 --- a/src/components/Editor/Attachments/AttachmentsList.vue +++ b/src/components/Editor/Attachments/AttachmentsList.vue @@ -5,12 +5,42 @@ multiple style="display:none" @change="onLocalAttachmentSelected"> +
+
+ +
+ {{ n('mail', '{count} attachment', '{count} attachments', attachments.length, { count: attachments.length }) }} +
+
+ {{ t('mail', 'No attachments') }} +
+
+ + + + + + {{ t('calendar', 'Add from Files') }} + + + + {{ t('calendar', 'Upload from PC') }} + + +
-
    +
      + :title="getBaseName(attachment.fileName)" + @click="openFile(attachment.value)"> @@ -18,12 +48,6 @@ {{ attachment.formatType }} @@ -79,17 +65,15 @@ import ListItem from '@nextcloud/vue/dist/Components/ListItem' import Actions from '@nextcloud/vue/dist/Components/Actions' import ActionButton from '@nextcloud/vue/dist/Components/ActionButton' -import ActionLink from '@nextcloud/vue/dist/Components/ActionLink' -import Button from '@nextcloud/vue/dist/Components/Button' -import EmptyContent from '@nextcloud/vue/dist/Components/EmptyContent' -import Download from 'vue-material-design-icons/Download' +import Upload from 'vue-material-design-icons/Upload' import TrashCan from 'vue-material-design-icons/TrashCan' -import CloudDownloadOutline from 'vue-material-design-icons/CloudDownloadOutline' import Folder from 'vue-material-design-icons/Folder' +import Paperclip from 'vue-material-design-icons/Paperclip' +import Plus from 'vue-material-design-icons/Plus' import { generateUrl } from '@nextcloud/router' -import { getFilePickerBuilder } from '@nextcloud/dialogs' +import { getFilePickerBuilder, showError } from '@nextcloud/dialogs' import { getRequestToken } from '@nextcloud/auth' import { shareFile, uploadLocalAttachment } from './../../../services/attachmentService' @@ -99,13 +83,11 @@ export default { ListItem, Actions, ActionButton, - ActionLink, - Button, - EmptyContent, - Download, + Upload, TrashCan, Folder, - CloudDownloadOutline, + Paperclip, + Plus, }, props: { @@ -154,8 +136,21 @@ export default { const picker = getFilePickerBuilder(t('mail', 'Choose a file to add as attachment')).setMultiSelect(false).build() try { const path = await picker.pick(t('mail', 'Choose a file to share as a link')) - const sharedData = await shareFile(path, getRequestToken()) - this.addAttachmentBySharedData(this.calendarObjectInstance, sharedData) + let err = false + this.attachments.find(attachment => { + if (attachment.fileName === path) { + err = true + } + return err + + }) + if (!err) { + const sharedData = await shareFile(path, getRequestToken()) + this.addAttachmentBySharedData(this.calendarObjectInstance, sharedData) + } else { + showError(t('calendar', 'Attachment {name} already exist!', { name: this.getBaseName(path) })) + } + } catch (error) { } @@ -196,21 +191,36 @@ export default { getBaseName(name) { return name.split('/').pop() }, + openFile(url) { + window.open(url, '_blank') + }, }, }