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

PropTipoDefaultDescrizione
attachmentsAttachment[]Lista da visualizzare
isSelected(id: string) => booleanCallback che ritorna lo stato di selezione
isLoadingbooleanMostra slot loading se vero
downloadUrl(attachment: Attachment) => Promise<void>Callback chiamato al click download
multipleSelectbooleanfalseMostra checkbox di selezione

Eventi

EventoPayloadDescrizione
selectid: stringToggle selezione su un elemento
deleteid: stringClick elimina

Slot

SlotDescrizione
loadingContenuto mostrato quando isLoading=true
emptyContenuto 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>