From dab0f365f532a81055ffa1fc8e75e2e8a0286c3e Mon Sep 17 00:00:00 2001 From: Andrey Sobolev Date: Mon, 7 Feb 2022 16:07:35 +0700 Subject: [PATCH] Fix PDF viewer close with Cross mark (#942) Signed-off-by: Andrey Sobolev --- .../src/components/PDFViewer.svelte | 19 +++++++++---------- packages/ui/src/components/icons/Close.svelte | 2 +- .../src/components/AttachmentPresenter.svelte | 15 +++++++++------ 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/presentation/src/components/PDFViewer.svelte b/packages/presentation/src/components/PDFViewer.svelte index edc2331167..4023fd5d36 100644 --- a/packages/presentation/src/components/PDFViewer.svelte +++ b/packages/presentation/src/components/PDFViewer.svelte @@ -14,14 +14,13 @@ --> diff --git a/plugins/attachment-resources/src/components/AttachmentPresenter.svelte b/plugins/attachment-resources/src/components/AttachmentPresenter.svelte index edc722d0d1..c2e89e27fc 100644 --- a/plugins/attachment-resources/src/components/AttachmentPresenter.svelte +++ b/plugins/attachment-resources/src/components/AttachmentPresenter.svelte @@ -24,29 +24,32 @@ const maxLenght: number = 16 const trimFilename = (fname: string): string => (fname.length > maxLenght) - ? fname.substr(0, (maxLenght - 1) / 2) + '...' + fname.substr(-(maxLenght - 1) / 2) - : fname + ? fname.substr(0, (maxLenght - 1) / 2) + '...' + fname.substr(-(maxLenght - 1) / 2) + : fname - function iconLabel(name: string): string { + function iconLabel (name: string): string { const parts = name.split('.') const ext = parts[parts.length - 1] return ext.substring(0, 4).toUpperCase() } - function openEmbedded(contentType: string) { + function openEmbedded (contentType: string) { return contentType.includes('application/pdf') || contentType.startsWith('image/') }
{#if openEmbedded(value.type)} -
{ closeTooltip(); showPopup(PDFViewer, { file: value.file, name: value.name }, 'right') }}>{iconLabel(value.name)}
+
{ + closeTooltip() + showPopup(PDFViewer, { file: value.file, name: value.name }, 'right') + }}>{iconLabel(value.name)}
{:else}
{iconLabel(value.name)}
{/if}
{#if openEmbedded(value.type)} -
{ closeTooltip(); showPopup(PDFViewer, { file: value.file, name: value.name }, 'right') }}>{trimFilename(value.name)}
+
{ closeTooltip(); showPopup(PDFViewer, { file: value.file, name: value.name }, 'right') }}>{trimFilename(value.name)}
{:else} {/if}