Ga naar hoofdinhoud

CnMassDeleteDialog

Two-phase mass delete confirmation dialog. Shows list of items to delete, requires confirmation, and displays results.

Try it

Loading CnMassDeleteDialog playground…

Wraps: NcDialog, NcButton, NcNoteCard

CnMassDeleteDialog showing confirmation with list of items to delete

Props

PropTypeDefaultDescription
itemsArray[]Items to delete ([\{ id, name \}])
nameFieldString'title'Field to display as item name
nameFormatterFunctionnullOptional function (item) => string to format item names. Overrides nameField when provided.
dialogTitleString'Delete items'
warningTextString''Warning text shown above the item list
emptyTextString'No items selected for deletion.'Message shown when all items have been removed from the list
successTextString'Items successfully deleted.'Message shown in the result phase on success
cancelLabelString'Cancel'
closeLabelString'Close'Label for the close button shown in the result phase
confirmLabelString'Delete'
removeLabelString'Remove from list'Tooltip/label for the per-item remove button

Events

EventPayloadDescription
confirmids[]Deletion confirmed
closeDialog closed

Public Methods

MethodDescription
setResult(\{ success?, error?, results? \})Set result per item

Live demo

<template>
<div>
<button @click="open = true" style="padding: 6px 16px; border-radius: 4px; background: var(--color-primary-element); color: white; border: none; cursor: pointer;">Delete selected (2)</button>
<CnMassDeleteDialog
v-if="open"
ref="dlg"
:items="[{ id: 1, title: 'Report A' }, { id: 2, title: 'Report B' }]"
@confirm="onConfirm"
@close="open = false" />
</div>
</template>
<script>
export default {
data() { return { open: false } },
methods: {
async onConfirm(ids) {
await new Promise(r => setTimeout(r, 800))
this.$refs.dlg.setResult({ success: true })
},
},
}
</script>

Usage

<CnMassDeleteDialog
ref="massDeleteDialog"
:items="selectedItems"
@confirm="onMassDelete"
@close="showMassDelete = false" />

Custom name formatting

Use nameFormatter when items don't have a simple name field:

<CnMassDeleteDialog
:items="selectedAuditTrails"
:name-formatter="(item) => t('myapp', 'Audit Trail #{id}', { id: item.id })"
@confirm="onMassDelete"
@close="showMassDelete = false" />

Reference (auto-generated)

The tables below are generated from the SFC source via vue-docgen-cli. They reflect what's actually in CnMassDeleteDialog.vue and update automatically whenever the component changes.

Props

NameTypeRequiredDefaultDescription
itemsarrayItems to delete. Each must have an id property.
nameFieldstring'title'Property name used for display (e.g., 'title', 'name')
nameFormatterfuncnullOptional function to format the item name. Receives the item, returns a string. Overrides nameField when provided.
dialogTitlestring() =&gt; t('nextcloud-vue', 'Delete items')Dialog title
warningTextstring() =&gt; t('nextcloud-vue', 'The following items will be permanently deleted. Remove any items you want to keep.')Warning text shown above the item list
emptyTextstring() =&gt; t('nextcloud-vue', 'No items selected for deletion.')Text when all items removed from list
successTextstring() =&gt; t('nextcloud-vue', 'Items successfully deleted.')Success message
cancelLabelstring() =&gt; t('nextcloud-vue', 'Cancel')
closeLabelstring() =&gt; t('nextcloud-vue', 'Close')
confirmLabelstring() =&gt; t('nextcloud-vue', 'Delete')
removeLabelstring() =&gt; t('nextcloud-vue', 'Remove from list')

Events

NamePayloadDescription
close
confirmEmitted when the user confirms deletion. Payload: array of item IDs to delete.

Methods

NameDescription
setResultSet the result of the delete operation. Call this from the parent after the API call completes.