Merge pull request #355 from hcengineering/images2

Open images in internal viewer
This commit is contained in:
Andrey Sobolev 2021-11-24 14:07:06 +07:00 committed by GitHub
commit 2c738eb62a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,16 +32,20 @@
const ext = parts[parts.length - 1] const ext = parts[parts.length - 1]
return ext.substring(0, 4).toUpperCase() return ext.substring(0, 4).toUpperCase()
} }
function openEmbedded(contentType: string) {
return contentType.includes('application/pdf') || contentType.startsWith('image/')
}
</script> </script>
<div class="flex-row-center"> <div class="flex-row-center">
{#if value.type.includes('application/pdf')} {#if openEmbedded(value.type)}
<div class="flex-center icon" on:click={()=> { closeTooltip(); showPopup(PDFViewer, { file: value.file }, 'right') }}>{iconLabel(value.name)}</div> <div class="flex-center icon" on:click={()=> { closeTooltip(); showPopup(PDFViewer, { file: value.file }, 'right') }}>{iconLabel(value.name)}</div>
{:else} {:else}
<a class="no-line" href={getFileUrl(value.file)} download={value.name}><div class="flex-center icon">{iconLabel(value.name)}</div></a> <a class="no-line" href={getFileUrl(value.file)} download={value.name}><div class="flex-center icon">{iconLabel(value.name)}</div></a>
{/if} {/if}
<div class="flex-col info"> <div class="flex-col info">
{#if value.type.includes('application/pdf') || value.type.startsWith('image/')} {#if openEmbedded(value.type)}
<div class="name" on:click={()=> { closeTooltip(); showPopup(PDFViewer, { file: value.file }, 'right') }}>{trimFilename(value.name)}</div> <div class="name" on:click={()=> { closeTooltip(); showPopup(PDFViewer, { file: value.file }, 'right') }}>{trimFilename(value.name)}</div>
{:else} {:else}
<div class="name"><a href={getFileUrl(value.file)} download={value.name}>{trimFilename(value.name)}</a></div> <div class="name"><a href={getFileUrl(value.file)} download={value.name}>{trimFilename(value.name)}</a></div>