Ga naar hoofdinhoud

CnMassImportDialog

File upload dialog with options and results summary. Supports importing data from files into OpenRegister.

Try it

Loading CnMassImportDialog playground…

Wraps: NcDialog, NcButton

CnMassImportDialog showing file upload with supported formats list

Props

PropTypeDefaultDescription
dialogTitleString'Import data'
acceptedTypesString'.json,.xlsx,.xls,.csv'Accepted file types (input accept attribute)
optionsArray[]Additional import option definitions
fileTypeHelpArray[{ label, description }]Help entries shown in the "Supported file types" list; defaults to JSON, Excel, and CSV entries
canSubmitBooleantrueWhether the form is ready to submit. The parent can set this to false (via a slot) while required options are incomplete.
successTextString'Import completed successfully!'Message shown in the result phase when all rows imported without errors
partialSuccessTextString'Import completed with errors. Check the details below.'Message shown when the import finished but with some errors
loadingTextString'Importing data — this may take a moment for large files...'Text shown while the import is running
summaryTitleString'Import summary'Heading above the result summary table
supportedFormatsLabelString'Supported file types:'Label above the file type help list
selectFileLabelString'Select file'Label for the file-picker button
cancelLabelString'Cancel'
closeLabelString'Close'Label for the close button shown in the result phase
confirmLabelString'Import'
sheetLabelString'Sheet'Column header for the sheet name in the summary table
foundLabelString'Found'Column header for the found-rows count
createdLabelString'Created'Column header for the created-rows count
updatedLabelString'Updated'Column header for the updated-rows count
unchangedLabelString'Unchanged'Column header for the unchanged-rows count
errorsLabelString'Errors'Column header for the error count

Events

EventPayloadDescription
confirm\{ file, options \}Import confirmed
closeDialog closed

Slots

SlotScopeDescription
#import-fields\{ file \}Extra fields below file upload

Public Methods

MethodDescription
setResult(\{ success?, error?, imported?, skipped? \})Set import result

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;">Import</button>
<CnMassImportDialog
v-if="open"
ref="dlg"
@confirm="onConfirm"
@close="open = false" />
</div>
</template>
<script>
export default {
data() { return { open: false } },
methods: {
async onConfirm(payload) {
await new Promise(r => setTimeout(r, 800))
this.$refs.dlg.setResult({ success: true })
},
},
}
</script>

Usage

<CnMassImportDialog
accepted-types=".json,.csv,.xlsx"
@confirm="onImport"
@close="showImport = false">
<template #import-fields="{ file }">
<NcCheckboxRadioSwitch v-model="overwriteExisting">
Overwrite existing records
</NcCheckboxRadioSwitch>
</template>
</CnMassImportDialog>

Reference (auto-generated)

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

Props

NameTypeRequiredDefaultDescription
dialogTitlestring() =&gt; t('nextcloud-vue', 'Import data')Dialog title
acceptedTypesstring'.json,.xlsx,.xls,.csv'Accepted file types (input accept attribute)
optionsarray[]Import option definitions
fileTypeHelparray[ \{ label: 'JSON', description: 'Configuration and objects.' \}, \{ label: 'Excel (.xlsx, .xls)', description: 'Tabular objects data with multiple sheets.' \}, \{ label: 'CSV', description: 'Single table of objects data.' \}, ]File type help entries
canSubmitbooleantrueWhether the form is ready to submit (parent can control via slot logic)
successTextstring() =&gt; t('nextcloud-vue', 'Import completed successfully!')Success text when all rows imported without errors
partialSuccessTextstring() =&gt; t('nextcloud-vue', 'Import completed with errors. Check the details below.')Text when import partially succeeded
loadingTextstring() =&gt; t('nextcloud-vue', 'Importing data — this may take a moment for large files...')Text shown while importing
summaryTitlestring() =&gt; t('nextcloud-vue', 'Import summary')
supportedFormatsLabelstring() =&gt; t('nextcloud-vue', 'Supported file types:')
selectFileLabelstring() =&gt; t('nextcloud-vue', 'Select file')
cancelLabelstring() =&gt; t('nextcloud-vue', 'Cancel')
closeLabelstring() =&gt; t('nextcloud-vue', 'Close')
confirmLabelstring() =&gt; t('nextcloud-vue', 'Import')
sheetLabelstring() =&gt; t('nextcloud-vue', 'Sheet')
foundLabelstring() =&gt; t('nextcloud-vue', 'Found')
createdLabelstring() =&gt; t('nextcloud-vue', 'Created')
updatedLabelstring() =&gt; t('nextcloud-vue', 'Updated')
unchangedLabelstring() =&gt; t('nextcloud-vue', 'Unchanged')
errorsLabelstring() =&gt; t('nextcloud-vue', 'Errors')

Events

NamePayloadDescription
close
confirm

Slots

NameBindingsDescription
fieldsfile

Methods

NameDescription
setResultSet the result of the import operation.