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
templateUrlString''Address of an empty file with the right columns; shows a download button when set.
templateLabelString'Download template'Label of the template download button.
mappingTitleString'How the columns are read'Heading of the column mapping table.
columnLabelString'Column in the file'Header of the file column.
fieldLabelString'Field'Header of the field column.
notUsedLabelString'Not used'The choice that leaves a column out.
checkFirstBooleanfalseOffer a switch that checks the file first and imports nothing (dryRun in the confirm options).
checkFirstLabelString'Check first, import nothing yet'Label of the check-first switch.
checkFirstDescriptionString'Shows which rows would fail and why.'Helper line of the check-first switch.
checkedTextString'Checked. Nothing is imported yet.'Note shown after a check.
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
close—Dialog 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.

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
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')Heading rendered above the per-sheet results table.
supportedFormatsLabelstring() =&gt; t('nextcloud-vue', 'Supported file types:')Label for the "Supported file types" intro line.
selectFileLabelstring() =&gt; t('nextcloud-vue', 'Select file')Label for the file-picker trigger button.
cancelLabelstring() =&gt; t('nextcloud-vue', 'Cancel')Label for the cancel button (visible before the import runs).
closeLabelstring() =&gt; t('nextcloud-vue', 'Close')Label for the close button (visible after import completes).
confirmLabelstring() =&gt; t('nextcloud-vue', 'Import')Label for the primary confirm button that triggers the import.
sheetLabelstring() =&gt; t('nextcloud-vue', 'Sheet')Column header for the per-sheet results row label.
foundLabelstring() =&gt; t('nextcloud-vue', 'Found')Column header for the "rows found" summary count.
createdLabelstring() =&gt; t('nextcloud-vue', 'Created')Column header for the "rows created" summary count.
updatedLabelstring() =&gt; t('nextcloud-vue', 'Updated')Column header for the "rows updated" summary count.
unchangedLabelstring() =&gt; t('nextcloud-vue', 'Unchanged')Column header for the "rows unchanged" summary count.
errorsLabelstring() =&gt; t('nextcloud-vue', 'Errors')Column header / collapsible toggle for the per-sheet errors list.
templateUrlstring''Address of an empty file with the right columns; shows a download button when set.
templateLabelstring() =&gt; t('nextcloud-vue', 'Download template')Label of the template download button.
fieldsarray[]The fields a row can fill, [{ key, label }]. With fields, a CSV or JSON file shows a table that maps each of its columns to a field or leaves it out; the file is uploaded with its columns renamed to the chosen fields.
mappingTitlestring() =&gt; t('nextcloud-vue', 'How the columns are read')Heading of the column mapping table.
columnLabelstring() =&gt; t('nextcloud-vue', 'Column in the file')Header of the file column.
fieldLabelstring() =&gt; t('nextcloud-vue', 'Field')Header of the field column.
notUsedLabelstring() =&gt; t('nextcloud-vue', 'Not used')The choice that leaves a column out.
checkFirstbooleanfalseOffer a switch that checks the file first and imports nothing (dryRun in the confirm options).
checkFirstLabelstring() =&gt; t('nextcloud-vue', 'Check first, import nothing yet')Label of the check-first switch.
checkFirstDescriptionstring() =&gt; t('nextcloud-vue', 'Shows which rows would fail and why.')Helper line of the check-first switch.
checkedTextstring() =&gt; t('nextcloud-vue', 'Checked. Nothing is imported yet.')Note shown after a check.

Events​

NamePayloadDescription
close—
confirm—

Slots​

NameBindingsDescription
fieldsfile

Methods​

NameDescription
setResultSet the result of the import operation.