|
|
@ -1,30 +1,53 @@ |
|
|
<script> |
|
|
<script> |
|
|
|
|
|
import { Modal, ModalContent, Icon } from '@budibase/bbui' |
|
|
|
|
|
import { createEventDispatcher } from "svelte"; |
|
|
|
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher() |
|
|
import { FILE_TYPES } from "./fileTypes" |
|
|
import { FILE_TYPES } from "./fileTypes" |
|
|
|
|
|
|
|
|
export let files = [] |
|
|
export let files = [] |
|
|
export let height = "70" |
|
|
export let height = "70" |
|
|
export let width = "70" |
|
|
export let width = "70" |
|
|
|
|
|
|
|
|
|
|
|
let modal; |
|
|
|
|
|
let currentFile; |
|
|
|
|
|
|
|
|
|
|
|
const openModal = (file) => { |
|
|
|
|
|
currentFile = file |
|
|
|
|
|
modal.show() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleConfirm = () => { |
|
|
|
|
|
dispatch('delete', currentFile) |
|
|
|
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<div class="file-list"> |
|
|
<div class="file-list"> |
|
|
{#each files as file} |
|
|
{#each files as file} |
|
|
<a href={file.url} target="_blank"> |
|
|
<div class="file-container"> |
|
|
<div class="file"> |
|
|
<a href={file.url} target="_blank" class="file"> |
|
|
{#if FILE_TYPES.IMAGE.includes(file.extension.toLowerCase())} |
|
|
{#if FILE_TYPES.IMAGE.includes(file.extension.toLowerCase())} |
|
|
<img {width} {height} src={file.url} alt="preview of {file.name}" /> |
|
|
<img {width} {height} src={file.url} alt="preview of {file.name}" /> |
|
|
{:else}<i class="far fa-file" />{/if} |
|
|
{:else}<i class="far fa-file" />{/if} |
|
|
</div> |
|
|
</a> |
|
|
<span>{file.name}</span> |
|
|
<span>{file.name}</span> |
|
|
</a> |
|
|
<div class="button-placement"><button primary on:click={() => openModal(file)}>×</button></div> |
|
|
|
|
|
</div> |
|
|
{/each} |
|
|
{/each} |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<Modal bind:this={modal}> |
|
|
|
|
|
<ModalContent title="Confirm File Deletion" confirmText="Delete" onConfirm={handleConfirm} > |
|
|
|
|
|
<span>Are you sure you want to delete this attachment?</span> |
|
|
|
|
|
</ModalContent> |
|
|
|
|
|
</Modal> |
|
|
|
|
|
|
|
|
<style> |
|
|
<style> |
|
|
.file-list { |
|
|
.file-list { |
|
|
display: grid; |
|
|
display: grid; |
|
|
|
|
|
justify-content: start; |
|
|
grid-auto-flow: column; |
|
|
grid-auto-flow: column; |
|
|
grid-gap: var(--spacing-m); |
|
|
grid-gap: var(--spacing-m); |
|
|
grid-template-columns: repeat(10, 1fr); |
|
|
grid-template-columns: repeat(auto-fill, 1fr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
img { |
|
|
img { |
|
|
@ -40,6 +63,40 @@ |
|
|
text-decoration: none; |
|
|
text-decoration: none; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.file-container { |
|
|
|
|
|
position: relative; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
button { |
|
|
|
|
|
display: block; |
|
|
|
|
|
box-sizing: border-box; |
|
|
|
|
|
position: absolute; |
|
|
|
|
|
font-size: var(--font-size-l); |
|
|
|
|
|
z-index: 1000; |
|
|
|
|
|
top: 4px; |
|
|
|
|
|
left: 46px; |
|
|
|
|
|
margin: 0; |
|
|
|
|
|
padding: 0; |
|
|
|
|
|
width: 1.5rem; |
|
|
|
|
|
height: 1.5rem; |
|
|
|
|
|
border: 0; |
|
|
|
|
|
color: white; |
|
|
|
|
|
border-radius: var(--border-radius-xl); |
|
|
|
|
|
background: black; |
|
|
|
|
|
transition: transform 0.2s cubic-bezier(0.25, 0.1, 0.25, 1), |
|
|
|
|
|
background 0.2s cubic-bezier(0.25, 0.1, 0.25, 1); |
|
|
|
|
|
-webkit-appearance: none; |
|
|
|
|
|
outline: none; |
|
|
|
|
|
} |
|
|
|
|
|
button:hover { |
|
|
|
|
|
background-color: var(--grey-8); |
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
} |
|
|
|
|
|
button:active { |
|
|
|
|
|
background-color: var(--grey-9); |
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.file { |
|
|
.file { |
|
|
position: relative; |
|
|
position: relative; |
|
|
height: 75px; |
|
|
height: 75px; |
|
|
|