Components
AttachmentsList
Lista verticale di allegati con AttachmentRow per ogni elemento.
Panoramica
AttachmentsList è una delle due viste di disposizione (l'altra è AttachmentsGrid). Renderizza ogni allegato come AttachmentRow con icona, nome, dimensione, data e pulsanti azione.
Anteprima live
Props
| Prop | Tipo | Default | Descrizione |
|---|---|---|---|
attachments | Attachment[] | — | Lista da visualizzare |
isSelected | (id: string) => boolean | — | Callback che ritorna lo stato di selezione |
isLoading | boolean | — | Mostra slot loading se vero |
downloadUrl | (attachment: Attachment) => Promise<void> | — | Callback chiamato al click download |
multipleSelect | boolean | false | Mostra checkbox di selezione |
Eventi
| Evento | Payload | Descrizione |
|---|---|---|
select | id: string | Toggle selezione su un elemento |
delete | id: string | Click elimina |
Slot
| Slot | Descrizione |
|---|---|
loading | Contenuto mostrato quando isLoading=true |
empty | Contenuto mostrato quando attachments.length === 0 |
Pattern di uso con useAttachments
<script setup>
import { useAttachments } from '@pzeta/vue-attachment'
const { attachments, isLoading, deleteAttachment, download } = useAttachments({
baseURL: '/api/attachments',
referenceTable: 'tickets',
referenceColumn: 'idticket',
referenceValue: 42
})
const selected = ref(new Set())
const isSelected = (id) => selected.value.has(id)
async function downloadUrl(attachment) {
const blob = await download(attachment.id, 'attachment')
// crea blob URL e triggerare il download
}
</script>
<template>
<AttachmentsList
:attachments="attachments"
:is-selected="isSelected"
:is-loading="isLoading"
:download-url="downloadUrl"
@delete="deleteAttachment"
@select="(id) => selected.has(id) ? selected.delete(id) : selected.add(id)"
/>
</template>