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

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 (208) hide show
  1. package/README.md +226 -0
  2. package/css/index.css +5 -0
  3. package/dist/nextcloud-vue.cjs.js +79416 -7715
  4. package/dist/nextcloud-vue.cjs.js.map +1 -1
  5. package/dist/nextcloud-vue.css +3583 -504
  6. package/dist/nextcloud-vue.esm.js +79343 -7692
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/l10n/en.json +164 -0
  9. package/l10n/nl.json +164 -0
  10. package/package.json +104 -63
  11. package/src/components/CnActionsBar/CnActionsBar.vue +254 -0
  12. package/src/components/CnActionsBar/index.js +1 -0
  13. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -0
  14. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -0
  15. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -0
  16. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -0
  17. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -0
  18. package/src/components/CnAdvancedFormDialog/index.js +1 -0
  19. package/src/components/CnCard/CnCard.vue +415 -0
  20. package/src/components/CnCard/index.js +1 -0
  21. package/src/components/CnCardGrid/CnCardGrid.vue +156 -152
  22. package/src/components/CnCardGrid/index.js +1 -1
  23. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  24. package/src/components/CnCellRenderer/index.js +1 -1
  25. package/src/components/CnChartWidget/CnChartWidget.vue +346 -0
  26. package/src/components/CnChartWidget/index.js +1 -0
  27. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  28. package/src/components/CnConfigurationCard/index.js +1 -1
  29. package/src/components/CnContextMenu/CnContextMenu.vue +142 -0
  30. package/src/components/CnContextMenu/index.js +1 -0
  31. package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -0
  32. package/src/components/CnCopyDialog/index.js +1 -0
  33. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -0
  34. package/src/components/CnDashboardGrid/index.js +1 -0
  35. package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -0
  36. package/src/components/CnDashboardPage/index.js +1 -0
  37. package/src/components/CnDataTable/CnDataTable.vue +362 -354
  38. package/src/components/CnDataTable/index.js +1 -1
  39. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -0
  40. package/src/components/CnDeleteDialog/index.js +1 -0
  41. package/src/components/CnDetailCard/CnDetailCard.vue +225 -0
  42. package/src/components/CnDetailCard/index.js +1 -0
  43. package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -0
  44. package/src/components/CnDetailGrid/index.js +1 -0
  45. package/src/components/CnDetailPage/CnDetailPage.vue +432 -0
  46. package/src/components/CnDetailPage/index.js +1 -0
  47. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -223
  48. package/src/components/CnFacetSidebar/index.js +1 -1
  49. package/src/components/CnFilterBar/CnFilterBar.vue +153 -152
  50. package/src/components/CnFilterBar/index.js +1 -1
  51. package/src/components/CnFormDialog/CnFormDialog.vue +1047 -0
  52. package/src/components/CnFormDialog/index.js +1 -0
  53. package/src/components/CnIcon/CnIcon.vue +89 -0
  54. package/src/components/CnIcon/index.js +1 -0
  55. package/src/components/CnIndexPage/CnIndexPage.vue +980 -682
  56. package/src/components/CnIndexPage/index.js +1 -1
  57. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -0
  58. package/src/components/CnIndexSidebar/index.js +1 -0
  59. package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -0
  60. package/src/components/CnInfoWidget/index.js +1 -0
  61. package/src/components/CnItemCard/CnItemCard.vue +134 -0
  62. package/src/components/CnItemCard/index.js +1 -0
  63. package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -0
  64. package/src/components/CnJsonViewer/index.js +1 -0
  65. package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -89
  66. package/src/components/CnKpiGrid/index.js +1 -1
  67. package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -160
  68. package/src/components/CnMassActionBar/index.js +1 -1
  69. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -320
  70. package/src/components/CnMassCopyDialog/index.js +1 -1
  71. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -238
  72. package/src/components/CnMassDeleteDialog/index.js +1 -1
  73. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -190
  74. package/src/components/CnMassExportDialog/index.js +1 -1
  75. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -491
  76. package/src/components/CnMassImportDialog/index.js +1 -1
  77. package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
  78. package/src/components/CnNoteCard/index.js +1 -0
  79. package/src/components/CnNotesCard/CnNotesCard.vue +416 -0
  80. package/src/components/CnNotesCard/index.js +1 -0
  81. package/src/components/CnObjectCard/CnObjectCard.vue +294 -292
  82. package/src/components/CnObjectCard/index.js +1 -1
  83. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -0
  84. package/src/components/CnObjectDataWidget/index.js +1 -0
  85. package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -0
  86. package/src/components/CnObjectMetadataWidget/index.js +1 -0
  87. package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -0
  88. package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -0
  89. package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -0
  90. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -0
  91. package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -0
  92. package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -0
  93. package/src/components/CnObjectSidebar/index.js +6 -0
  94. package/src/components/CnPageHeader/CnPageHeader.vue +61 -0
  95. package/src/components/CnPageHeader/index.js +1 -0
  96. package/src/components/CnPagination/CnPagination.vue +253 -252
  97. package/src/components/CnPagination/index.js +1 -1
  98. package/src/components/CnProgressBar/CnProgressBar.vue +262 -0
  99. package/src/components/CnProgressBar/index.js +1 -0
  100. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -0
  101. package/src/components/CnRegisterMapping/index.js +1 -0
  102. package/src/components/CnRowActions/CnRowActions.vue +95 -73
  103. package/src/components/CnRowActions/index.js +1 -1
  104. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
  105. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -0
  106. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
  107. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
  108. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
  109. package/src/components/CnSchemaFormDialog/index.js +1 -0
  110. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  111. package/src/components/CnSettingsCard/index.js +1 -1
  112. package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -266
  113. package/src/components/CnSettingsSection/index.js +1 -1
  114. package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -366
  115. package/src/components/CnStatsBlock/index.js +1 -1
  116. package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -0
  117. package/src/components/CnStatsPanel/index.js +1 -0
  118. package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -77
  119. package/src/components/CnStatusBadge/index.js +1 -1
  120. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -0
  121. package/src/components/CnTabbedFormDialog/index.js +1 -0
  122. package/src/components/CnTableWidget/CnTableWidget.vue +333 -0
  123. package/src/components/CnTableWidget/index.js +1 -0
  124. package/src/components/CnTasksCard/CnTasksCard.vue +374 -0
  125. package/src/components/CnTasksCard/index.js +1 -0
  126. package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
  127. package/src/components/CnTileWidget/index.js +1 -0
  128. package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -0
  129. package/src/components/CnTimelineStages/index.js +1 -0
  130. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -0
  131. package/src/components/CnUserActionMenu/index.js +1 -0
  132. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -312
  133. package/src/components/CnVersionInfoCard/index.js +1 -1
  134. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
  135. package/src/components/CnWidgetRenderer/index.js +1 -0
  136. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -0
  137. package/src/components/CnWidgetWrapper/index.js +1 -0
  138. package/src/components/index.js +57 -25
  139. package/src/composables/index.js +5 -3
  140. package/src/composables/useContextMenu.js +126 -0
  141. package/src/composables/useDashboardView.js +286 -0
  142. package/src/composables/useDetailView.js +290 -132
  143. package/src/composables/useListView.js +364 -153
  144. package/src/composables/useSubResource.js +142 -142
  145. package/src/constants/metadata.js +30 -0
  146. package/src/css/CnSchemaFormDialog.css +546 -0
  147. package/src/css/__sample_nextcloud_tokens.css +110 -0
  148. package/src/css/actions-bar.css +54 -0
  149. package/src/css/badge.css +83 -51
  150. package/src/css/card.css +129 -128
  151. package/src/css/context-menu.css +20 -0
  152. package/src/css/dashboard.css +70 -0
  153. package/src/css/detail-page.css +235 -0
  154. package/src/css/detail.css +68 -68
  155. package/src/css/index-page.css +44 -0
  156. package/src/css/index-sidebar.css +193 -0
  157. package/src/css/index.css +17 -8
  158. package/src/css/layout.css +90 -90
  159. package/src/css/page-header.css +35 -0
  160. package/src/css/pagination.css +72 -72
  161. package/src/css/table.css +142 -143
  162. package/src/css/timeline-stages.css +220 -0
  163. package/src/css/utilities.css +46 -46
  164. package/src/index.js +95 -50
  165. package/src/l10n/index.js +12 -0
  166. package/src/mixins/gridLayout.js +118 -0
  167. package/src/store/createCrudStore.d.ts +350 -0
  168. package/src/store/createCrudStore.js +413 -0
  169. package/src/store/createSubResourcePlugin.js +125 -135
  170. package/src/store/index.js +4 -3
  171. package/src/store/pluginMerge.js +55 -0
  172. package/src/store/plugins/auditTrails.js +357 -17
  173. package/src/store/plugins/files.js +250 -186
  174. package/src/store/plugins/index.js +8 -4
  175. package/src/store/plugins/lifecycle.js +180 -180
  176. package/src/store/plugins/logs.d.ts +22 -0
  177. package/src/store/plugins/logs.js +172 -0
  178. package/src/store/plugins/registerMapping.js +195 -0
  179. package/src/store/plugins/relations.js +68 -68
  180. package/src/store/plugins/search.js +385 -0
  181. package/src/store/plugins/selection.js +104 -0
  182. package/src/store/useObjectStore.js +793 -625
  183. package/src/types/auditTrail.d.ts +32 -32
  184. package/src/types/file.d.ts +23 -23
  185. package/src/types/index.d.ts +67 -35
  186. package/src/types/notification.d.ts +36 -36
  187. package/src/types/object.d.ts +40 -40
  188. package/src/types/organisation.d.ts +41 -41
  189. package/src/types/register.d.ts +25 -25
  190. package/src/types/schema.d.ts +39 -39
  191. package/src/types/shared.d.ts +79 -79
  192. package/src/types/source.d.ts +14 -14
  193. package/src/types/task.d.ts +31 -31
  194. package/src/utils/errors.js +96 -96
  195. package/src/utils/getTheme.js +9 -0
  196. package/src/utils/headers.js +80 -44
  197. package/src/utils/id.js +13 -0
  198. package/src/utils/index.js +4 -3
  199. package/src/utils/schema.js +423 -287
  200. package/src/utils/widgetVisibility.js +162 -0
  201. package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
  202. package/src/components/CnDetailViewLayout/index.js +0 -1
  203. package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
  204. package/src/components/CnEmptyState/index.js +0 -1
  205. package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
  206. package/src/components/CnListViewLayout/index.js +0 -1
  207. package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
  208. package/src/components/CnViewModeToggle/index.js +0 -1
@@ -1,491 +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">{{ 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">
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>