Components
AttachmentPopoverConnected
Container che wrappa AttachmentPopover e fa fetch/download/delete automatico via useAttachments + adapter.
Panoramica
AttachmentPopoverConnected è il container di AttachmentPopover: identifica l'entità owner tramite referenceTable + referenceColumn + referenceValue e fa il fetch via useAttachments. Gestisce internamente download e delete con toast di feedback.
Quando usarlo
- Tipico indicatore di righe nelle tabelle/liste: ogni riga monta un
AttachmentPopoverConnectedcon la propria reference. - Pagine in cui vuoi una preview rapida degli allegati senza aprire un dialog full-screen.
Override degli attachments: la prop
attachments (opzionale) salta il fetch automatico se valorizzata, utile quando hai già la lista in cache (es. la query principale ritorna anche gli allegati). Quando null (default), il componente fetcha al mounted.Props
| Prop | Tipo | Default | Descrizione |
|---|---|---|---|
adapter | AttachmentAdapter | (inject) | Data source. Se omesso, usa quello fornito dal plugin |
attachments | Attachment[] | null | null | Override statico — quando passato salta il fetch |
referenceTable | string | — | Richiesto. Tabella entità owner |
referenceColumn | string | — | Richiesto. Colonna FK |
referenceValue | string | number | — | Richiesto. Valore FK |
storagePath | string | 'attachments/attachments' | Path su MinIO/S3 |
canDelete | boolean | true | Mostra pulsante elimina |
Eventi
Nessun evento riemesso: download e delete sono gestiti internamente con toast.
Esempio: indicatore in tabella
<template>
<DataTable :value="tickets">
<Column field="codice" header="Codice" />
<Column header="Allegati">
<template #body="{ data }">
<AttachmentPopoverConnected
reference-table="tickets"
reference-column="idticket"
:reference-value="data.id"
:group-id="data.id"
/>
</template>
</Column>
</DataTable>
</template>
Esempio: con cache pre-popolata
Quando la query principale già restituisce gli allegati, evita il fetch duplicato:
<script setup lang="ts">
import type { Attachment } from '@pzeta/vue-attachment'
const ticket = ref<{ id: number; allegati: Attachment[] }>(...)
</script>
<template>
<AttachmentPopoverConnected
reference-table="tickets"
reference-column="idticket"
:reference-value="ticket.id"
:attachments="ticket.allegati"
/>
</template>
Anteprima live
Il preview live richiede un adapter funzionante. Per provare la UI in isolamento vedi
AttachmentPopover.