mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 19:44:59 +03:00
Attachment click handler (#3077)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
aa1f440312
commit
3cd606ad21
@ -44,37 +44,39 @@
|
||||
contentType.startsWith('application/msword')
|
||||
)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex-row-center attachment-container">
|
||||
{#if openEmbedded(value.type)}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="flex-center icon"
|
||||
on:click={() => {
|
||||
function clickHandler (e: MouseEvent) {
|
||||
if (!openEmbedded(value.type)) return
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
if (e.metaKey || e.ctrlKey) {
|
||||
window.open((e.target as HTMLAnchorElement).href, '_blank')
|
||||
return
|
||||
}
|
||||
closeTooltip()
|
||||
showPopup(
|
||||
PDFViewer,
|
||||
{ file: value.file, name: value.name, contentType: value.type, value },
|
||||
isImage(value.type) ? 'centered' : 'float'
|
||||
)
|
||||
}}
|
||||
}
|
||||
|
||||
function middleClickHandler (e: MouseEvent) {
|
||||
if (e.button !== 1) return
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
window.open((e.target as HTMLAnchorElement).href, '_blank')
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex-row-center attachment-container">
|
||||
<a
|
||||
class="no-line"
|
||||
href={getFileUrl(value.file)}
|
||||
download={value.name}
|
||||
on:click={clickHandler}
|
||||
on:mousedown={middleClickHandler}
|
||||
>
|
||||
{iconLabel(value.name)}
|
||||
{#if removable}
|
||||
<div
|
||||
class="remove-btn"
|
||||
on:click|preventDefault={(ev) => {
|
||||
ev.stopPropagation()
|
||||
dispatch('remove')
|
||||
}}
|
||||
>
|
||||
<Icon icon={IconClose} size={'medium'} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<a class="no-line" href={getFileUrl(value.file)} download={value.name}>
|
||||
<div class="flex-center icon">
|
||||
{iconLabel(value.name)}
|
||||
{#if removable}
|
||||
@ -92,26 +94,12 @@
|
||||
{/if}
|
||||
</div>
|
||||
</a>
|
||||
{/if}
|
||||
<div class="flex-col info">
|
||||
{#if openEmbedded(value.type)}
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div
|
||||
class="name"
|
||||
on:click={() => {
|
||||
closeTooltip()
|
||||
showPopup(
|
||||
PDFViewer,
|
||||
{ file: value.file, name: value.name, contentType: value.type, value },
|
||||
isImage(value.type) ? 'centered' : 'float'
|
||||
)
|
||||
}}
|
||||
>
|
||||
<div class="name">
|
||||
<a href={getFileUrl(value.file)} download={value.name} on:click={clickHandler} on:mousedown={middleClickHandler}>
|
||||
{trimFilename(value.name)}
|
||||
</a>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="name"><a href={getFileUrl(value.file)} download={value.name}>{trimFilename(value.name)}</a></div>
|
||||
{/if}
|
||||
<div class="type">{filesize(value.size)}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user