From b644c00f59d1fffdeb09da0c58784f7dd332e284 Mon Sep 17 00:00:00 2001 From: kolaente Date: Sat, 16 Jan 2021 22:15:48 +0100 Subject: [PATCH] Add view image modal for image attachments --- src/components/modal/modal.vue | 4 ++- src/components/tasks/partials/attachments.vue | 34 +++++++++++++++++-- src/styles/components/attachments.scss | 11 +++++- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/components/modal/modal.vue b/src/components/modal/modal.vue index 8664fa218..fa0866bba 100644 --- a/src/components/modal/modal.vue +++ b/src/components/modal/modal.vue @@ -1,8 +1,9 @@ @@ -107,6 +120,9 @@ export default { showDeleteModal: false, attachmentToDelete: AttachmentModel, + + showImageModal: false, + attachmentImageBlobUrl: null, } }, props: { @@ -199,6 +215,20 @@ export default { this.showDeleteModal = false }) }, + viewOrDownload(attachment) { + if (attachment.file.name.endsWith('.jpg') || + attachment.file.name.endsWith('.png') || + attachment.file.name.endsWith('.bmp') || + attachment.file.name.endsWith('.gif')) { + this.showImageModal = true + this.attachmentService.getBlobUrl(attachment) + .then(url => { + this.attachmentImageBlobUrl = url + }) + } else { + this.downloadAttachment(attachment) + } + }, }, } diff --git a/src/styles/components/attachments.scss b/src/styles/components/attachments.scss index a862d686a..23fecac3e 100644 --- a/src/styles/components/attachments.scss +++ b/src/styles/components/attachments.scss @@ -7,11 +7,20 @@ margin-bottom: 1rem; .attachment { - margin-bottom: .75rem; + margin-bottom: .5rem; + display: block; + transition: background-color $transition; + border-radius: $radius; + padding: .5rem; + + &:hover { + background-color: $grey-lightest; + } .filename { font-weight: bold; margin-bottom: .25rem; + color: $dark; } .info {