Ga naar hoofdinhoud

CnMassDeleteDialog

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

It is CnMassActionDialog with the delete texts, the error variant and a trash icon as defaults. Every prop of that dialog works here too.

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
variantString'error'Variant of the primary button
confirmIconString or componenttrash canIcon on the primary button: a CnIcon name or an icon component
sentenceString'Are you sure you want to permanently delete {count}?'Board look: the question above the list, {count} is the bold item count
irreversibleBooleantrueBoard look: end the sentence with "This action cannot be undone."

Events​

EventPayloadDescription
confirmids[]Deletion confirmed
close—Dialog 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.

OpenRegister reliance​

none: this component does not touch OpenRegister, directly or through anything it imports. 0 direct references, 0 files reached through imports.

See the reliance overview for the filterable list.

Props​

NameTypeRequiredDefaultDescription
confirmValuestring''Value the user must type before the destructive button enables. Empty: no field.
confirmFieldLabelstring() =&gt; t('nextcloud-vue', 'Type to confirm')Label of the type-to-confirm field.
itemsarray✓—Items the action applies to. 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')Label for the cancel button (visible before the action runs).
closeLabelstring() =&gt; t('nextcloud-vue', 'Close')Label for the close button (visible after the action completes).
confirmLabelstring() =&gt; t('nextcloud-vue', 'Delete')Label for the primary confirm button that triggers the delete.
removeLabelstring() =&gt; t('nextcloud-vue', 'Remove from list')Aria label for the per-row "remove from list" icon button.
variantstring'error'Visual variant of the primary button.
confirmIconunion() =&gt; markRaw(TrashCanOutline)Icon on the primary button: a CnIcon name or an icon component. Defaults to a trash can.
sentencestring() =&gt; t('nextcloud-vue', 'Are you sure you want to permanently delete \{count\}?')Board look: the question above the list, with {count} where the bold item count goes.
irreversiblebooleantrueBoard look: end the sentence with "This action cannot be undone."

Events​

NamePayloadDescription
close—Emitted when the dialog should close: cancel, close button, or 2 seconds after a success.
confirm—Emitted when the user confirms the action. Payload: the ids of the items still on the list.

Methods​

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

Board look​

The irreversible prop (default true) ends the board sentence with "This action cannot be undone."; set it to false for a delete that can be undone. confirmValue and confirmFieldLabel add type-to-confirm.