Skip to content

Commit

Permalink
Move attachments to details, notify if attachment exists
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Sazanov <m@sazanof.ru>
  • Loading branch information
Mikhail Sazanov committed Jun 8, 2022
1 parent a4e764c commit 1f9598e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/components/Editor/Attachments/AttachmentsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,27 @@ export default {
return err
})
if (!err) {
if (!this.isDuplicateAttachment(path)) {
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) {
}
},
isDuplicateAttachment(path){
return this.attachments.find(attachment => {
if(attachment.fileName === path){
showError(t('calendar', 'Attachment {name} already exist!', { name: this.getBaseName(path) }))
return true
}
})
},
clickOnUploadButton() {
this.$refs.localAttachments.click()
},
Expand Down
5 changes: 3 additions & 2 deletions src/services/attachmentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ const uploadLocalAttachment = async function(event, dav, componentAttachments) {
const promises = []

files.forEach(file => {
if (componentAttachments.map(attachment => attachment.fileName).indexOf(file.name) !== -1) {
// temp fix, until we decide where to save the attachments
if (componentAttachments.map(attachment => attachment.fileName.split('/').pop()).indexOf(file.name) !== -1) {
showError(t('calendar', 'Attachment {fileName} already exists!', {
fileName: file.name,
}))
Expand Down Expand Up @@ -91,5 +92,5 @@ const uploadLocalAttachment = async function(event, dav, componentAttachments) {
export {
shareFile,
shareFileWith,
uploadLocalAttachment,
uploadLocalAttachment
}

0 comments on commit 1f9598e

Please sign in to comment.