@conduction/nextcloud-vue 0.1.0-beta.11 → 0.1.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/nextcloud-vue.cjs +67614 -0
  2. package/dist/nextcloud-vue.cjs.js +13518 -13617
  3. package/dist/nextcloud-vue.cjs.js.map +1 -1
  4. package/dist/nextcloud-vue.cjs.map +1 -0
  5. package/dist/nextcloud-vue.css +1796 -1800
  6. package/dist/nextcloud-vue.esm.js +13518 -13617
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/package.json +3 -2
  9. package/src/components/CnActionsBar/CnActionsBar.vue +254 -254
  10. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -570
  11. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -217
  12. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -121
  13. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -422
  14. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -247
  15. package/src/components/CnCard/CnCard.vue +415 -415
  16. package/src/components/CnCardGrid/CnCardGrid.vue +156 -156
  17. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  18. package/src/components/CnChartWidget/CnChartWidget.vue +346 -346
  19. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  20. package/src/components/CnContextMenu/CnContextMenu.vue +142 -142
  21. package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -266
  22. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -229
  23. package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -397
  24. package/src/components/CnDataTable/CnDataTable.vue +362 -362
  25. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -177
  26. package/src/components/CnDetailCard/CnDetailCard.vue +225 -225
  27. package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -256
  28. package/src/components/CnDetailPage/CnDetailPage.vue +432 -432
  29. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -234
  30. package/src/components/CnFilterBar/CnFilterBar.vue +153 -153
  31. package/src/components/CnFormDialog/CnFormDialog.vue +1047 -1047
  32. package/src/components/CnIcon/CnIcon.vue +89 -89
  33. package/src/components/CnIndexPage/CnIndexPage.vue +981 -980
  34. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -536
  35. package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -219
  36. package/src/components/CnItemCard/CnItemCard.vue +134 -134
  37. package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -312
  38. package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -93
  39. package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -161
  40. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -327
  41. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -245
  42. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -191
  43. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -494
  44. package/src/components/CnNoteCard/CnNoteCard.vue +149 -149
  45. package/src/components/CnNotesCard/CnNotesCard.vue +416 -416
  46. package/src/components/CnObjectCard/CnObjectCard.vue +294 -294
  47. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -854
  48. package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -289
  49. package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -369
  50. package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -287
  51. package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -250
  52. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -255
  53. package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -259
  54. package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -483
  55. package/src/components/CnPageHeader/CnPageHeader.vue +61 -61
  56. package/src/components/CnPagination/CnPagination.vue +253 -253
  57. package/src/components/CnProgressBar/CnProgressBar.vue +262 -262
  58. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -793
  59. package/src/components/CnRowActions/CnRowActions.vue +95 -95
  60. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -226
  61. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -788
  62. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -305
  63. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -1398
  64. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -236
  65. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  66. package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -267
  67. package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -437
  68. package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -321
  69. package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -90
  70. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -545
  71. package/src/components/CnTableWidget/CnTableWidget.vue +333 -333
  72. package/src/components/CnTasksCard/CnTasksCard.vue +374 -374
  73. package/src/components/CnTileWidget/CnTileWidget.vue +159 -159
  74. package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -294
  75. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -436
  76. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -313
  77. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -180
  78. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -248
@@ -1,494 +1,494 @@
1
- <template>
2
- <NcDialog
3
- :name="dialogTitle"
4
- size="large"
5
- :can-close="!loading"
6
- @closing="$emit('close')">
7
- <!-- Success/error messages -->
8
- <NcNoteCard v-if="result && result.success && !hasErrors" type="success">
9
- {{ successText }}
10
- </NcNoteCard>
11
- <NcNoteCard v-if="result && result.success && hasErrors" type="warning">
12
- {{ partialSuccessText }}
13
- </NcNoteCard>
14
- <NcNoteCard v-if="result && result.error" type="error">
15
- {{ result.error }}
16
- </NcNoteCard>
17
-
18
- <!-- Results summary table -->
19
- <div v-if="result && result.summary" class="cn-mass-import__results">
20
- <h3>{{ summaryTitle }}</h3>
21
- <table class="cn-mass-import__summary-table">
22
- <thead>
23
- <tr>
24
- <th>{{ sheetLabel }}</th>
25
- <th>{{ foundLabel }}</th>
26
- <th>{{ createdLabel }}</th>
27
- <th>{{ updatedLabel }}</th>
28
- <th>{{ unchangedLabel }}</th>
29
- <th>{{ errorsLabel }}</th>
30
- </tr>
31
- </thead>
32
- <tbody>
33
- <template v-for="(sheet, key) in result.summary">
34
- <tr :key="key">
35
- <td class="cn-mass-import__sheet-name">
36
- {{ key }}
37
- </td>
38
- <td class="cn-mass-import__stat cn-mass-import__stat--found">
39
- {{ sheet.found || 0 }}
40
- </td>
41
- <td class="cn-mass-import__stat cn-mass-import__stat--created">
42
- {{ getCount(sheet.created) }}
43
- </td>
44
- <td class="cn-mass-import__stat cn-mass-import__stat--updated">
45
- {{ getCount(sheet.updated) }}
46
- </td>
47
- <td class="cn-mass-import__stat cn-mass-import__stat--unchanged">
48
- {{ getCount(sheet.unchanged) }}
49
- </td>
50
- <td class="cn-mass-import__stat cn-mass-import__stat--errors">
51
- <span>{{ getCount(sheet.errors) }}</span>
52
- <button
53
- v-if="getCount(sheet.errors) > 0"
54
- class="cn-mass-import__expand"
55
- :class="{ 'cn-mass-import__expand--open': expandedErrors[key] }"
56
- @click="toggleErrors(key)">
57
- <ChevronDown :size="16" />
58
- </button>
59
- </td>
60
- </tr>
61
- <!-- Error details row -->
62
- <tr
63
- v-if="expandedErrors[key] && sheet.errors && sheet.errors.length"
64
- :key="`${key}-errors`"
65
- class="cn-mass-import__error-row">
66
- <td colspan="6">
67
- <table class="cn-mass-import__error-table">
68
- <thead>
69
- <tr>
70
- <th>Row</th>
71
- <th>Type</th>
72
- <th>Message</th>
73
- </tr>
74
- </thead>
75
- <tbody>
76
- <tr v-for="(err, idx) in sheet.errors" :key="idx">
77
- <td>{{ err.row || '—' }}</td>
78
- <td>{{ err.type || 'Unknown' }}</td>
79
- <td>{{ err.error || err.message || '—' }}</td>
80
- </tr>
81
- </tbody>
82
- </table>
83
- </td>
84
- </tr>
85
- </template>
86
- </tbody>
87
- </table>
88
- </div>
89
-
90
- <!-- Upload form -->
91
- <div v-if="!result" class="cn-mass-import__form">
92
- <input
93
- ref="fileInput"
94
- type="file"
95
- :accept="acceptedTypes"
96
- style="display: none"
97
- @change="handleFileSelect">
98
-
99
- <div class="cn-mass-import__file-row">
100
- <NcButton @click="$refs.fileInput.click()">
101
- <template #icon>
102
- <Upload :size="20" />
103
- </template>
104
- {{ selectFileLabel }}
105
- </NcButton>
106
- <div v-if="selectedFile" class="cn-mass-import__file-info">
107
- <span class="cn-mass-import__file-name">{{ selectedFile.name }}</span>
108
- <span class="cn-mass-import__file-size">({{ formatFileSize(selectedFile.size) }})</span>
109
- </div>
110
- </div>
111
-
112
- <!-- Additional fields slot (e.g., register/schema selectors) -->
113
- <slot name="fields" :file="selectedFile" />
114
-
115
- <!-- File type help text -->
116
- <div v-if="fileTypeHelp" class="cn-mass-import__help">
117
- <p><strong>{{ supportedFormatsLabel }}</strong></p>
118
- <ul>
119
- <li v-for="(help, idx) in fileTypeHelp" :key="idx">
120
- <strong>{{ help.label }}</strong> — {{ help.description }}
121
- </li>
122
- </ul>
123
- </div>
124
-
125
- <!-- Import options -->
126
- <div v-if="options.length > 0" class="cn-mass-import__options">
127
- <NcCheckboxRadioSwitch
128
- v-for="opt in options"
129
- :key="opt.key"
130
- :checked="optionValues[opt.key]"
131
- type="switch"
132
- @update:checked="setOption(opt.key, $event)">
133
- {{ opt.label }}
134
- <template v-if="opt.description" #helper>
135
- {{ opt.description }}
136
- </template>
137
- </NcCheckboxRadioSwitch>
138
- </div>
139
- </div>
140
-
141
- <!-- Loading indicator -->
142
- <NcNoteCard v-if="loading" type="info">
143
- {{ loadingText }}
144
- </NcNoteCard>
145
-
146
- <template #actions>
147
- <NcButton @click="$emit('close')">
148
- {{ result ? closeLabel : cancelLabel }}
149
- </NcButton>
150
- <NcButton
151
- v-if="!result"
152
- type="primary"
153
- :disabled="loading || !selectedFile || !canSubmit"
154
- @click="executeImport">
155
- <template #icon>
156
- <NcLoadingIcon v-if="loading" :size="20" />
157
- <ImportIcon v-else :size="20" />
158
- </template>
159
- {{ confirmLabel }}
160
- </NcButton>
161
- </template>
162
- </NcDialog>
163
- </template>
164
-
165
- <script>
166
- import { translate as t } from '@nextcloud/l10n'
167
- import { NcDialog, NcButton, NcNoteCard, NcLoadingIcon, NcCheckboxRadioSwitch } from '@nextcloud/vue'
168
- import Upload from 'vue-material-design-icons/Upload.vue'
169
- import ImportIcon from 'vue-material-design-icons/Import.vue'
170
- import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
171
-
172
- /**
173
- * CnMassImportDialog — File import dialog with options and results summary.
174
- *
175
- * Supports file upload (JSON, Excel, CSV), configurable import options via
176
- * toggle switches, and a results summary table showing created/updated/error
177
- * counts per sheet. Based on the OpenRegister ImportRegister pattern.
178
- *
179
- * The dialog does NOT perform the import itself — it emits a `confirm` event
180
- * with the file and options. The parent handles the API call and calls
181
- * `setResult()` via a ref.
182
- *
183
- * @example
184
- * <CnMassImportDialog
185
- * v-if="showImportDialog"
186
- * ref="importDialog"
187
- * :options="importOptions"
188
- * @confirm="onImportConfirm"
189
- * @close="showImportDialog = false">
190
- * <template #fields="{ file }">
191
- * <NcSelect v-if="file" :options="schemas" @input="selectedSchema = $event" />
192
- * </template>
193
- * </CnMassImportDialog>
194
- *
195
- * // In data:
196
- * importOptions: [
197
- * { key: 'validation', label: 'Enable validation', description: 'Validate against schema', default: true },
198
- * { key: 'publish', label: 'Auto-publish', description: 'Set published date', default: false },
199
- * ]
200
- *
201
- * // In methods:
202
- * async onImportConfirm({ file, options }) {
203
- * try {
204
- * const formData = new FormData()
205
- * formData.append('file', file)
206
- * const result = await axios.post('/api/import', formData, { params: options })
207
- * this.$refs.importDialog.setResult({ success: true, summary: result.data.summary })
208
- * } catch (e) {
209
- * this.$refs.importDialog.setResult({ error: e.message })
210
- * }
211
- * }
212
- */
213
- export default {
214
- name: 'CnMassImportDialog',
215
-
216
- components: {
217
- NcDialog,
218
- NcButton,
219
- NcNoteCard,
220
- NcLoadingIcon,
221
- NcCheckboxRadioSwitch,
222
- Upload,
223
- ImportIcon,
224
- ChevronDown,
225
- },
226
-
227
- props: {
228
- /** Dialog title */
229
- dialogTitle: {
230
- type: String,
231
- default: () => t('nextcloud-vue', 'Import data'),
232
- },
233
- /** Accepted file types (input accept attribute) */
234
- acceptedTypes: {
235
- type: String,
236
- default: '.json,.xlsx,.xls,.csv',
237
- },
238
- /** Import option definitions */
239
- options: {
240
- type: Array,
241
- default: () => [],
242
- },
243
- /** File type help entries */
244
- fileTypeHelp: {
245
- type: Array,
246
- default: () => [
247
- { label: 'JSON', description: 'Configuration and objects.' },
248
- { label: 'Excel (.xlsx, .xls)', description: 'Tabular objects data with multiple sheets.' },
249
- { label: 'CSV', description: 'Single table of objects data.' },
250
- ],
251
- },
252
- /** Whether the form is ready to submit (parent can control via slot logic) */
253
- canSubmit: {
254
- type: Boolean,
255
- default: true,
256
- },
257
- /** Success text when all rows imported without errors */
258
- successText: {
259
- type: String,
260
- default: () => t('nextcloud-vue', 'Import completed successfully!'),
261
- },
262
- /** Text when import partially succeeded */
263
- partialSuccessText: {
264
- type: String,
265
- default: () => t('nextcloud-vue', 'Import completed with errors. Check the details below.'),
266
- },
267
- /** Text shown while importing */
268
- loadingText: {
269
- type: String,
270
- default: () => t('nextcloud-vue', 'Importing data — this may take a moment for large files...'),
271
- },
272
- summaryTitle: { type: String, default: () => t('nextcloud-vue', 'Import summary') },
273
- supportedFormatsLabel: { type: String, default: () => t('nextcloud-vue', 'Supported file types:') },
274
- selectFileLabel: { type: String, default: () => t('nextcloud-vue', 'Select file') },
275
- cancelLabel: { type: String, default: () => t('nextcloud-vue', 'Cancel') },
276
- closeLabel: { type: String, default: () => t('nextcloud-vue', 'Close') },
277
- confirmLabel: { type: String, default: () => t('nextcloud-vue', 'Import') },
278
- sheetLabel: { type: String, default: () => t('nextcloud-vue', 'Sheet') },
279
- foundLabel: { type: String, default: () => t('nextcloud-vue', 'Found') },
280
- createdLabel: { type: String, default: () => t('nextcloud-vue', 'Created') },
281
- updatedLabel: { type: String, default: () => t('nextcloud-vue', 'Updated') },
282
- unchangedLabel: { type: String, default: () => t('nextcloud-vue', 'Unchanged') },
283
- errorsLabel: { type: String, default: () => t('nextcloud-vue', 'Errors') },
284
- },
285
-
286
- data() {
287
- const optionValues = {}
288
- this.options.forEach((opt) => {
289
- optionValues[opt.key] = opt.default !== undefined ? opt.default : false
290
- })
291
- return {
292
- selectedFile: null,
293
- loading: false,
294
- result: null,
295
- optionValues,
296
- expandedErrors: {},
297
- }
298
- },
299
-
300
- computed: {
301
- hasErrors() {
302
- if (!this.result || !this.result.summary) return false
303
- return Object.values(this.result.summary).some(
304
- (sheet) => sheet.errors && sheet.errors.length > 0,
305
- )
306
- },
307
- },
308
-
309
- methods: {
310
- handleFileSelect(event) {
311
- const file = event.target.files[0]
312
- this.selectedFile = file || null
313
- },
314
-
315
- setOption(key, value) {
316
- this.$set(this.optionValues, key, value)
317
- },
318
-
319
- formatFileSize(bytes) {
320
- if (bytes === 0) return '0 B'
321
- const k = 1024
322
- const sizes = ['B', 'KB', 'MB', 'GB']
323
- const i = Math.floor(Math.log(bytes) / Math.log(k))
324
- return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
325
- },
326
-
327
- getCount(val) {
328
- if (Array.isArray(val)) return val.length
329
- if (typeof val === 'number') return val
330
- return 0
331
- },
332
-
333
- toggleErrors(key) {
334
- this.$set(this.expandedErrors, key, !this.expandedErrors[key])
335
- },
336
-
337
- executeImport() {
338
- this.loading = true
339
- this.$emit('confirm', {
340
- file: this.selectedFile,
341
- options: { ...this.optionValues },
342
- })
343
- },
344
-
345
- /**
346
- * Set the result of the import operation.
347
- * @param {{ success?: boolean, error?: string, summary?: object }} resultData - Result data to pass to the dialog
348
- * @public
349
- */
350
- setResult(resultData) {
351
- this.loading = false
352
- this.result = resultData
353
- },
354
- },
355
- }
356
- </script>
357
-
358
- <style scoped>
359
- .cn-mass-import__form {
360
- display: flex;
361
- flex-direction: column;
362
- gap: 16px;
363
- }
364
-
365
- .cn-mass-import__file-row {
366
- display: flex;
367
- align-items: center;
368
- gap: 12px;
369
- }
370
-
371
- .cn-mass-import__file-info {
372
- display: flex;
373
- align-items: center;
374
- gap: 6px;
375
- }
376
-
377
- .cn-mass-import__file-name {
378
- font-weight: 500;
379
- }
380
-
381
- .cn-mass-import__file-size {
382
- color: var(--color-text-maxcontrast);
383
- font-size: 0.9em;
384
- }
385
-
386
- .cn-mass-import__help {
387
- padding: 12px;
388
- background: var(--color-background-hover);
389
- border-radius: var(--border-radius);
390
- }
391
-
392
- .cn-mass-import__help p {
393
- margin: 0 0 8px;
394
- }
395
-
396
- .cn-mass-import__help ul {
397
- margin: 0;
398
- padding-left: 20px;
399
- }
400
-
401
- .cn-mass-import__options {
402
- display: flex;
403
- flex-direction: column;
404
- gap: 12px;
405
- }
406
-
407
- /* Summary table */
408
- .cn-mass-import__results h3 {
409
- margin: 0 0 12px;
410
- font-size: 1.1rem;
411
- }
412
-
413
- .cn-mass-import__summary-table {
414
- width: 100%;
415
- border-collapse: collapse;
416
- border-radius: var(--border-radius);
417
- overflow: hidden;
418
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
419
- }
420
-
421
- .cn-mass-import__summary-table th,
422
- .cn-mass-import__summary-table td {
423
- padding: 8px 12px;
424
- text-align: left;
425
- border-bottom: 1px solid var(--color-border);
426
- }
427
-
428
- .cn-mass-import__summary-table th {
429
- background: var(--color-background-dark);
430
- font-weight: 600;
431
- font-size: 0.85rem;
432
- text-transform: uppercase;
433
- }
434
-
435
- .cn-mass-import__sheet-name {
436
- font-weight: 600;
437
- }
438
-
439
- .cn-mass-import__stat {
440
- text-align: center;
441
- font-weight: 600;
442
- }
443
-
444
- .cn-mass-import__stat--found { color: var(--color-primary-element); }
445
- .cn-mass-import__stat--created { color: var(--color-success); }
446
- .cn-mass-import__stat--updated { color: var(--color-warning); }
447
- .cn-mass-import__stat--unchanged { color: var(--color-text-maxcontrast); }
448
- .cn-mass-import__stat--errors { color: var(--color-error); }
449
-
450
- .cn-mass-import__expand {
451
- background: none;
452
- border: none;
453
- cursor: pointer;
454
- padding: 2px;
455
- border-radius: var(--border-radius-small, 4px);
456
- color: var(--color-error);
457
- transition: transform 0.2s ease;
458
- vertical-align: middle;
459
- margin-left: 4px;
460
- }
461
-
462
- .cn-mass-import__expand:hover {
463
- background: var(--color-background-hover);
464
- }
465
-
466
- .cn-mass-import__expand--open {
467
- transform: rotate(180deg);
468
- }
469
-
470
- /* Error details */
471
- .cn-mass-import__error-row td {
472
- padding: 8px 12px;
473
- background: var(--color-background-hover);
474
- }
475
-
476
- .cn-mass-import__error-table {
477
- width: 100%;
478
- border-collapse: collapse;
479
- font-size: 0.9em;
480
- }
481
-
482
- .cn-mass-import__error-table th,
483
- .cn-mass-import__error-table td {
484
- padding: 6px 10px;
485
- text-align: left;
486
- border-bottom: 1px solid var(--color-border);
487
- }
488
-
489
- .cn-mass-import__error-table th {
490
- background: var(--color-background-dark);
491
- font-weight: 600;
492
- font-size: 0.85rem;
493
- }
494
- </style>
1
+ <template>
2
+ <NcDialog
3
+ :name="dialogTitle"
4
+ size="large"
5
+ :can-close="!loading"
6
+ @closing="$emit('close')">
7
+ <!-- Success/error messages -->
8
+ <NcNoteCard v-if="result && result.success && !hasErrors" type="success">
9
+ {{ successText }}
10
+ </NcNoteCard>
11
+ <NcNoteCard v-if="result && result.success && hasErrors" type="warning">
12
+ {{ partialSuccessText }}
13
+ </NcNoteCard>
14
+ <NcNoteCard v-if="result && result.error" type="error">
15
+ {{ result.error }}
16
+ </NcNoteCard>
17
+
18
+ <!-- Results summary table -->
19
+ <div v-if="result && result.summary" class="cn-mass-import__results">
20
+ <h3>{{ summaryTitle }}</h3>
21
+ <table class="cn-mass-import__summary-table">
22
+ <thead>
23
+ <tr>
24
+ <th>{{ sheetLabel }}</th>
25
+ <th>{{ foundLabel }}</th>
26
+ <th>{{ createdLabel }}</th>
27
+ <th>{{ updatedLabel }}</th>
28
+ <th>{{ unchangedLabel }}</th>
29
+ <th>{{ errorsLabel }}</th>
30
+ </tr>
31
+ </thead>
32
+ <tbody>
33
+ <template v-for="(sheet, key) in result.summary">
34
+ <tr :key="key">
35
+ <td class="cn-mass-import__sheet-name">
36
+ {{ key }}
37
+ </td>
38
+ <td class="cn-mass-import__stat cn-mass-import__stat--found">
39
+ {{ sheet.found || 0 }}
40
+ </td>
41
+ <td class="cn-mass-import__stat cn-mass-import__stat--created">
42
+ {{ getCount(sheet.created) }}
43
+ </td>
44
+ <td class="cn-mass-import__stat cn-mass-import__stat--updated">
45
+ {{ getCount(sheet.updated) }}
46
+ </td>
47
+ <td class="cn-mass-import__stat cn-mass-import__stat--unchanged">
48
+ {{ getCount(sheet.unchanged) }}
49
+ </td>
50
+ <td class="cn-mass-import__stat cn-mass-import__stat--errors">
51
+ <span>{{ getCount(sheet.errors) }}</span>
52
+ <button
53
+ v-if="getCount(sheet.errors) > 0"
54
+ class="cn-mass-import__expand"
55
+ :class="{ 'cn-mass-import__expand--open': expandedErrors[key] }"
56
+ @click="toggleErrors(key)">
57
+ <ChevronDown :size="16" />
58
+ </button>
59
+ </td>
60
+ </tr>
61
+ <!-- Error details row -->
62
+ <tr
63
+ v-if="expandedErrors[key] && sheet.errors && sheet.errors.length"
64
+ :key="`${key}-errors`"
65
+ class="cn-mass-import__error-row">
66
+ <td colspan="6">
67
+ <table class="cn-mass-import__error-table">
68
+ <thead>
69
+ <tr>
70
+ <th>Row</th>
71
+ <th>Type</th>
72
+ <th>Message</th>
73
+ </tr>
74
+ </thead>
75
+ <tbody>
76
+ <tr v-for="(err, idx) in sheet.errors" :key="idx">
77
+ <td>{{ err.row || '—' }}</td>
78
+ <td>{{ err.type || 'Unknown' }}</td>
79
+ <td>{{ err.error || err.message || '—' }}</td>
80
+ </tr>
81
+ </tbody>
82
+ </table>
83
+ </td>
84
+ </tr>
85
+ </template>
86
+ </tbody>
87
+ </table>
88
+ </div>
89
+
90
+ <!-- Upload form -->
91
+ <div v-if="!result" class="cn-mass-import__form">
92
+ <input
93
+ ref="fileInput"
94
+ type="file"
95
+ :accept="acceptedTypes"
96
+ style="display: none"
97
+ @change="handleFileSelect">
98
+
99
+ <div class="cn-mass-import__file-row">
100
+ <NcButton @click="$refs.fileInput.click()">
101
+ <template #icon>
102
+ <Upload :size="20" />
103
+ </template>
104
+ {{ selectFileLabel }}
105
+ </NcButton>
106
+ <div v-if="selectedFile" class="cn-mass-import__file-info">
107
+ <span class="cn-mass-import__file-name">{{ selectedFile.name }}</span>
108
+ <span class="cn-mass-import__file-size">({{ formatFileSize(selectedFile.size) }})</span>
109
+ </div>
110
+ </div>
111
+
112
+ <!-- Additional fields slot (e.g., register/schema selectors) -->
113
+ <slot name="fields" :file="selectedFile" />
114
+
115
+ <!-- File type help text -->
116
+ <div v-if="fileTypeHelp" class="cn-mass-import__help">
117
+ <p><strong>{{ supportedFormatsLabel }}</strong></p>
118
+ <ul>
119
+ <li v-for="(help, idx) in fileTypeHelp" :key="idx">
120
+ <strong>{{ help.label }}</strong> — {{ help.description }}
121
+ </li>
122
+ </ul>
123
+ </div>
124
+
125
+ <!-- Import options -->
126
+ <div v-if="options.length > 0" class="cn-mass-import__options">
127
+ <NcCheckboxRadioSwitch
128
+ v-for="opt in options"
129
+ :key="opt.key"
130
+ :checked="optionValues[opt.key]"
131
+ type="switch"
132
+ @update:checked="setOption(opt.key, $event)">
133
+ {{ opt.label }}
134
+ <template v-if="opt.description" #helper>
135
+ {{ opt.description }}
136
+ </template>
137
+ </NcCheckboxRadioSwitch>
138
+ </div>
139
+ </div>
140
+
141
+ <!-- Loading indicator -->
142
+ <NcNoteCard v-if="loading" type="info">
143
+ {{ loadingText }}
144
+ </NcNoteCard>
145
+
146
+ <template #actions>
147
+ <NcButton @click="$emit('close')">
148
+ {{ result ? closeLabel : cancelLabel }}
149
+ </NcButton>
150
+ <NcButton
151
+ v-if="!result"
152
+ type="primary"
153
+ :disabled="loading || !selectedFile || !canSubmit"
154
+ @click="executeImport">
155
+ <template #icon>
156
+ <NcLoadingIcon v-if="loading" :size="20" />
157
+ <ImportIcon v-else :size="20" />
158
+ </template>
159
+ {{ confirmLabel }}
160
+ </NcButton>
161
+ </template>
162
+ </NcDialog>
163
+ </template>
164
+
165
+ <script>
166
+ import { translate as t } from '@nextcloud/l10n'
167
+ import { NcDialog, NcButton, NcNoteCard, NcLoadingIcon, NcCheckboxRadioSwitch } from '@nextcloud/vue'
168
+ import Upload from 'vue-material-design-icons/Upload.vue'
169
+ import ImportIcon from 'vue-material-design-icons/Import.vue'
170
+ import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
171
+
172
+ /**
173
+ * CnMassImportDialog — File import dialog with options and results summary.
174
+ *
175
+ * Supports file upload (JSON, Excel, CSV), configurable import options via
176
+ * toggle switches, and a results summary table showing created/updated/error
177
+ * counts per sheet. Based on the OpenRegister ImportRegister pattern.
178
+ *
179
+ * The dialog does NOT perform the import itself — it emits a `confirm` event
180
+ * with the file and options. The parent handles the API call and calls
181
+ * `setResult()` via a ref.
182
+ *
183
+ * @example
184
+ * <CnMassImportDialog
185
+ * v-if="showImportDialog"
186
+ * ref="importDialog"
187
+ * :options="importOptions"
188
+ * @confirm="onImportConfirm"
189
+ * @close="showImportDialog = false">
190
+ * <template #fields="{ file }">
191
+ * <NcSelect v-if="file" :options="schemas" @input="selectedSchema = $event" />
192
+ * </template>
193
+ * </CnMassImportDialog>
194
+ *
195
+ * // In data:
196
+ * importOptions: [
197
+ * { key: 'validation', label: 'Enable validation', description: 'Validate against schema', default: true },
198
+ * { key: 'publish', label: 'Auto-publish', description: 'Set published date', default: false },
199
+ * ]
200
+ *
201
+ * // In methods:
202
+ * async onImportConfirm({ file, options }) {
203
+ * try {
204
+ * const formData = new FormData()
205
+ * formData.append('file', file)
206
+ * const result = await axios.post('/api/import', formData, { params: options })
207
+ * this.$refs.importDialog.setResult({ success: true, summary: result.data.summary })
208
+ * } catch (e) {
209
+ * this.$refs.importDialog.setResult({ error: e.message })
210
+ * }
211
+ * }
212
+ */
213
+ export default {
214
+ name: 'CnMassImportDialog',
215
+
216
+ components: {
217
+ NcDialog,
218
+ NcButton,
219
+ NcNoteCard,
220
+ NcLoadingIcon,
221
+ NcCheckboxRadioSwitch,
222
+ Upload,
223
+ ImportIcon,
224
+ ChevronDown,
225
+ },
226
+
227
+ props: {
228
+ /** Dialog title */
229
+ dialogTitle: {
230
+ type: String,
231
+ default: () => t('nextcloud-vue', 'Import data'),
232
+ },
233
+ /** Accepted file types (input accept attribute) */
234
+ acceptedTypes: {
235
+ type: String,
236
+ default: '.json,.xlsx,.xls,.csv',
237
+ },
238
+ /** Import option definitions */
239
+ options: {
240
+ type: Array,
241
+ default: () => [],
242
+ },
243
+ /** File type help entries */
244
+ fileTypeHelp: {
245
+ type: Array,
246
+ default: () => [
247
+ { label: 'JSON', description: 'Configuration and objects.' },
248
+ { label: 'Excel (.xlsx, .xls)', description: 'Tabular objects data with multiple sheets.' },
249
+ { label: 'CSV', description: 'Single table of objects data.' },
250
+ ],
251
+ },
252
+ /** Whether the form is ready to submit (parent can control via slot logic) */
253
+ canSubmit: {
254
+ type: Boolean,
255
+ default: true,
256
+ },
257
+ /** Success text when all rows imported without errors */
258
+ successText: {
259
+ type: String,
260
+ default: () => t('nextcloud-vue', 'Import completed successfully!'),
261
+ },
262
+ /** Text when import partially succeeded */
263
+ partialSuccessText: {
264
+ type: String,
265
+ default: () => t('nextcloud-vue', 'Import completed with errors. Check the details below.'),
266
+ },
267
+ /** Text shown while importing */
268
+ loadingText: {
269
+ type: String,
270
+ default: () => t('nextcloud-vue', 'Importing data — this may take a moment for large files...'),
271
+ },
272
+ summaryTitle: { type: String, default: () => t('nextcloud-vue', 'Import summary') },
273
+ supportedFormatsLabel: { type: String, default: () => t('nextcloud-vue', 'Supported file types:') },
274
+ selectFileLabel: { type: String, default: () => t('nextcloud-vue', 'Select file') },
275
+ cancelLabel: { type: String, default: () => t('nextcloud-vue', 'Cancel') },
276
+ closeLabel: { type: String, default: () => t('nextcloud-vue', 'Close') },
277
+ confirmLabel: { type: String, default: () => t('nextcloud-vue', 'Import') },
278
+ sheetLabel: { type: String, default: () => t('nextcloud-vue', 'Sheet') },
279
+ foundLabel: { type: String, default: () => t('nextcloud-vue', 'Found') },
280
+ createdLabel: { type: String, default: () => t('nextcloud-vue', 'Created') },
281
+ updatedLabel: { type: String, default: () => t('nextcloud-vue', 'Updated') },
282
+ unchangedLabel: { type: String, default: () => t('nextcloud-vue', 'Unchanged') },
283
+ errorsLabel: { type: String, default: () => t('nextcloud-vue', 'Errors') },
284
+ },
285
+
286
+ data() {
287
+ const optionValues = {}
288
+ this.options.forEach((opt) => {
289
+ optionValues[opt.key] = opt.default !== undefined ? opt.default : false
290
+ })
291
+ return {
292
+ selectedFile: null,
293
+ loading: false,
294
+ result: null,
295
+ optionValues,
296
+ expandedErrors: {},
297
+ }
298
+ },
299
+
300
+ computed: {
301
+ hasErrors() {
302
+ if (!this.result || !this.result.summary) return false
303
+ return Object.values(this.result.summary).some(
304
+ (sheet) => sheet.errors && sheet.errors.length > 0,
305
+ )
306
+ },
307
+ },
308
+
309
+ methods: {
310
+ handleFileSelect(event) {
311
+ const file = event.target.files[0]
312
+ this.selectedFile = file || null
313
+ },
314
+
315
+ setOption(key, value) {
316
+ this.$set(this.optionValues, key, value)
317
+ },
318
+
319
+ formatFileSize(bytes) {
320
+ if (bytes === 0) return '0 B'
321
+ const k = 1024
322
+ const sizes = ['B', 'KB', 'MB', 'GB']
323
+ const i = Math.floor(Math.log(bytes) / Math.log(k))
324
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i]
325
+ },
326
+
327
+ getCount(val) {
328
+ if (Array.isArray(val)) return val.length
329
+ if (typeof val === 'number') return val
330
+ return 0
331
+ },
332
+
333
+ toggleErrors(key) {
334
+ this.$set(this.expandedErrors, key, !this.expandedErrors[key])
335
+ },
336
+
337
+ executeImport() {
338
+ this.loading = true
339
+ this.$emit('confirm', {
340
+ file: this.selectedFile,
341
+ options: { ...this.optionValues },
342
+ })
343
+ },
344
+
345
+ /**
346
+ * Set the result of the import operation.
347
+ * @param {{ success?: boolean, error?: string, summary?: object }} resultData - Result data to pass to the dialog
348
+ * @public
349
+ */
350
+ setResult(resultData) {
351
+ this.loading = false
352
+ this.result = resultData
353
+ },
354
+ },
355
+ }
356
+ </script>
357
+
358
+ <style scoped>
359
+ .cn-mass-import__form {
360
+ display: flex;
361
+ flex-direction: column;
362
+ gap: 16px;
363
+ }
364
+
365
+ .cn-mass-import__file-row {
366
+ display: flex;
367
+ align-items: center;
368
+ gap: 12px;
369
+ }
370
+
371
+ .cn-mass-import__file-info {
372
+ display: flex;
373
+ align-items: center;
374
+ gap: 6px;
375
+ }
376
+
377
+ .cn-mass-import__file-name {
378
+ font-weight: 500;
379
+ }
380
+
381
+ .cn-mass-import__file-size {
382
+ color: var(--color-text-maxcontrast);
383
+ font-size: 0.9em;
384
+ }
385
+
386
+ .cn-mass-import__help {
387
+ padding: 12px;
388
+ background: var(--color-background-hover);
389
+ border-radius: var(--border-radius);
390
+ }
391
+
392
+ .cn-mass-import__help p {
393
+ margin: 0 0 8px;
394
+ }
395
+
396
+ .cn-mass-import__help ul {
397
+ margin: 0;
398
+ padding-left: 20px;
399
+ }
400
+
401
+ .cn-mass-import__options {
402
+ display: flex;
403
+ flex-direction: column;
404
+ gap: 12px;
405
+ }
406
+
407
+ /* Summary table */
408
+ .cn-mass-import__results h3 {
409
+ margin: 0 0 12px;
410
+ font-size: 1.1rem;
411
+ }
412
+
413
+ .cn-mass-import__summary-table {
414
+ width: 100%;
415
+ border-collapse: collapse;
416
+ border-radius: var(--border-radius);
417
+ overflow: hidden;
418
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
419
+ }
420
+
421
+ .cn-mass-import__summary-table th,
422
+ .cn-mass-import__summary-table td {
423
+ padding: 8px 12px;
424
+ text-align: left;
425
+ border-bottom: 1px solid var(--color-border);
426
+ }
427
+
428
+ .cn-mass-import__summary-table th {
429
+ background: var(--color-background-dark);
430
+ font-weight: 600;
431
+ font-size: 0.85rem;
432
+ text-transform: uppercase;
433
+ }
434
+
435
+ .cn-mass-import__sheet-name {
436
+ font-weight: 600;
437
+ }
438
+
439
+ .cn-mass-import__stat {
440
+ text-align: center;
441
+ font-weight: 600;
442
+ }
443
+
444
+ .cn-mass-import__stat--found { color: var(--color-primary-element); }
445
+ .cn-mass-import__stat--created { color: var(--color-success); }
446
+ .cn-mass-import__stat--updated { color: var(--color-warning); }
447
+ .cn-mass-import__stat--unchanged { color: var(--color-text-maxcontrast); }
448
+ .cn-mass-import__stat--errors { color: var(--color-error); }
449
+
450
+ .cn-mass-import__expand {
451
+ background: none;
452
+ border: none;
453
+ cursor: pointer;
454
+ padding: 2px;
455
+ border-radius: var(--border-radius-small, 4px);
456
+ color: var(--color-error);
457
+ transition: transform 0.2s ease;
458
+ vertical-align: middle;
459
+ margin-left: 4px;
460
+ }
461
+
462
+ .cn-mass-import__expand:hover {
463
+ background: var(--color-background-hover);
464
+ }
465
+
466
+ .cn-mass-import__expand--open {
467
+ transform: rotate(180deg);
468
+ }
469
+
470
+ /* Error details */
471
+ .cn-mass-import__error-row td {
472
+ padding: 8px 12px;
473
+ background: var(--color-background-hover);
474
+ }
475
+
476
+ .cn-mass-import__error-table {
477
+ width: 100%;
478
+ border-collapse: collapse;
479
+ font-size: 0.9em;
480
+ }
481
+
482
+ .cn-mass-import__error-table th,
483
+ .cn-mass-import__error-table td {
484
+ padding: 6px 10px;
485
+ text-align: left;
486
+ border-bottom: 1px solid var(--color-border);
487
+ }
488
+
489
+ .cn-mass-import__error-table th {
490
+ background: var(--color-background-dark);
491
+ font-weight: 600;
492
+ font-size: 0.85rem;
493
+ }
494
+ </style>