diff --git a/src/components/tasks/mixins/attachmentUpload.js b/src/components/tasks/mixins/attachmentUpload.js index 1e08e0fc4..4ba368822 100644 --- a/src/components/tasks/mixins/attachmentUpload.js +++ b/src/components/tasks/mixins/attachmentUpload.js @@ -1,5 +1,6 @@ import AttachmentModel from '../../../models/attachment' import AttachmentService from '../../../services/attachment' +import {generateAttachmentUrl} from '@/helpers/generateAttachmentUrl' export default { methods: { @@ -21,7 +22,7 @@ export default { taskId: this.taskId, attachment: a, }) - onSuccess(`${window.API_URL}/tasks/${this.taskId}/attachments/${a.id}`) + onSuccess(generateAttachmentUrl(this.taskId, a.id)) }) } if (r.errors !== null) { diff --git a/src/components/tasks/partials/attachments.vue b/src/components/tasks/partials/attachments.vue index 2f76ae3c7..52f49fa6f 100644 --- a/src/components/tasks/partials/attachments.vue +++ b/src/components/tasks/partials/attachments.vue @@ -55,14 +55,20 @@

{{ $t('task.attachment.download') }} + + {{ $t('task.attachment.copyUrl') }} + {{ $t('misc.delete') }} @@ -106,7 +112,7 @@ > {{ $t('task.attachment.delete') }}

- {{ $t('task.attachment.deleteText1', {filename: attachmentUpload.file.name}) }}
+ {{ $t('task.attachment.deleteText1', {filename: attachmentToDelete.file.name}) }}
{{ $t('task.attachment.deleteText2') }}

@@ -133,7 +139,9 @@ import AttachmentService from '../../../services/attachment' import AttachmentModel from '../../../models/attachment' import User from '../../misc/user' import attachmentUpload from '@/components/tasks/mixins/attachmentUpload' +import {generateAttachmentUrl} from '@/helpers/generateAttachmentUrl' import {mapState} from 'vuex' +import copy from 'copy-to-clipboard' export default { name: 'attachments', @@ -247,6 +255,9 @@ export default { this.downloadAttachment(attachment) } }, + copyUrl(attachment) { + copy(generateAttachmentUrl(this.taskId, attachment.id)) + }, }, } diff --git a/src/helpers/generateAttachmentUrl.js b/src/helpers/generateAttachmentUrl.js new file mode 100644 index 000000000..40c1e1efc --- /dev/null +++ b/src/helpers/generateAttachmentUrl.js @@ -0,0 +1,3 @@ +export const generateAttachmentUrl = (taskId, attachmentId) => { + return `${window.API_URL}/tasks/${taskId}/attachments/${attachmentId}` +} \ No newline at end of file diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index fdebc1893..fe007a663 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -529,11 +529,15 @@ "title": "Attachments", "createdBy": "created {0} by {1}", "download": "Download", + "downloadTooltip": "Download this attachment", "upload": "Upload attachment", "drop": "Drop files here to upload", "delete": "Delete attachment", + "deleteTooltip": "Delete this attachment", "deleteText1": "Are you sure you want to delete the attachment {filename}?", - "deleteText2": "This cannot be undone!" + "deleteText2": "This cannot be undone!", + "copyUrl": "Copy URL", + "copyUrlTooltip": "Copy the url of this attachment for usage in text" }, "comment": { "title": "Comments",