@conduction/nextcloud-vue 0.1.0-beta.4 → 0.1.0-beta.6

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