Ga naar hoofdinhoud

CnMassActionDialog

Two-phase confirmation dialog for one action on many items: publish, lock, validate, restore or delete. The review phase lists the items, and the user can take any item off the list. The result phase shows success or an error.

The dialog does not perform the action. It emits confirm with the ids still on the list. Your code performs the call and reports back with setResult() on a ref. Until then, Cancel is disabled: the action is already running.

CnMassDeleteDialog is this dialog with the delete texts, the error variant and a trash icon as defaults.

Import​

import { CnMassActionDialog } from '@conduction/nextcloud-vue'

Usage​

<CnMassActionDialog
v-if="showPublish"
ref="publishDialog"
:items="selectedObjects"
:dialog-title="t('myapp', 'Publish objects')"
:warning-text="t('myapp', 'The following objects will be published.')"
:success-text="t('myapp', 'Objects published.')"
:confirm-label="t('myapp', 'Publish')"
confirm-icon="Publish"
@confirm="onPublishConfirm"
@close="showPublish = false" />
async onPublishConfirm(ids) {
try {
await store.massPublish(ids)
this.$refs.publishDialog.setResult({ success: true })
} catch (e) {
this.$refs.publishDialog.setResult({ error: e.message })
}
}

Props​

PropTypeDefaultDescription
itemsArrayrequiredItems the action applies to. Each needs an id.
nameFieldString'title'Field shown as the item name.
nameFormatterFunctionnull(item) => string for the item name. Overrides nameField.
dialogTitleString'Confirm action'Dialog title.
warningTextString'The action applies to the following items. Remove any items you want to leave out.'Text above the item list.
emptyTextString'No items selected.'Text when every item is off the list.
successTextString'Done.'Text in the result phase on success.
confirmLabelString'Confirm'Primary button label.
cancelLabelString'Cancel'Cancel button label in the review phase.
closeLabelString'Close'Close button label in the result phase.
removeLabelString'Remove from list'Accessible label of the per-item remove button.
variantString'primary'Primary button variant: primary, error, warning or success. Use error for delete or purge.
confirmIconString or component''Icon on the primary button: a CnIcon name or an icon component. Empty draws none.
sentenceString'Are you sure you want to continue with {count}?'Board look: the question above the list. {count} is the bold item count.
irreversibleBooleanfalseBoard look: end the sentence with "This action cannot be undone."
confirmValueString''Type-to-confirm: the value the user must type before the primary button works.
confirmFieldLabelString'Type to confirm'Label of the type-to-confirm field.
look / width / eyebrow / subtitleStringBoard look props, as on CnDialog.

Events​

EventPayloadDescription
confirmids[]The user confirmed. The payload holds the ids still on the list.
closeThe dialog should close: cancel, close button, or 2 seconds after a success.

Public methods​

MethodDescription
setResult({ success?, error? })Report the outcome. A success closes the dialog after 2 seconds; an error stays open.

Test ids​

The dialog carries data-testid-modal="cn-mass-action-dialog", and the primary button data-testid="cn-mass-action-dialog-confirm". CnMassDeleteDialog keeps its own cn-mass-delete-* test ids.