@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,390 +1,390 @@
1
- <!--
2
- CnDashboardPage — Top-level dashboard page with GridStack widget grid.
3
-
4
- The dashboard equivalent of CnIndexPage. Assembles a complete dashboard
5
- from a widget definition array and a layout array. Supports:
6
- - Custom widgets via scoped slots (#widget-{widgetId})
7
- - Nextcloud Dashboard API widgets (auto-rendered)
8
- - Tile widgets (quick-access links)
9
- - Drag-and-drop editing mode
10
- - Header with title, actions, and edit toggle
11
- -->
12
- <template>
13
- <div class="cn-dashboard-page">
14
- <!-- Header -->
15
- <div class="cn-dashboard-page__header">
16
- <div class="cn-dashboard-page__header-left">
17
- <h2 v-if="title" class="cn-dashboard-page__title">
18
- {{ title }}
19
- </h2>
20
- <p v-if="description" class="cn-dashboard-page__description">
21
- {{ description }}
22
- </p>
23
- </div>
24
- <div class="cn-dashboard-page__header-actions">
25
- <slot name="header-actions" />
26
- <NcButton
27
- v-if="allowEdit"
28
- :type="isEditing ? 'primary' : 'secondary'"
29
- @click="toggleEdit">
30
- <template #icon>
31
- <Pencil v-if="!isEditing" :size="20" />
32
- <Check v-else :size="20" />
33
- </template>
34
- {{ isEditing ? doneLabel : editLabel }}
35
- </NcButton>
36
- </div>
37
- </div>
38
-
39
- <!-- Loading state -->
40
- <NcLoadingIcon v-if="loading" />
41
-
42
- <!-- Empty state -->
43
- <div v-else-if="!hasWidgets" class="cn-dashboard-page__empty">
44
- <slot name="empty">
45
- <NcEmptyContent :description="emptyLabel">
46
- <template #icon>
47
- <ViewDashboardOutline :size="48" />
48
- </template>
49
- </NcEmptyContent>
50
- </slot>
51
- </div>
52
-
53
- <!-- Dashboard grid -->
54
- <CnDashboardGrid
55
- v-else
56
- :layout="layout"
57
- :editable="isEditing"
58
- :columns="columns"
59
- :cell-height="cellHeight"
60
- :margin="gridMargin"
61
- @layout-change="onLayoutChange">
62
- <template #widget="{ item }">
63
- <!-- Tile widget -->
64
- <CnTileWidget
65
- v-if="isTile(item)"
66
- :tile="getTileConfig(item)" />
67
-
68
- <!-- Custom slot widget — apps provide their own rendering -->
69
- <template v-else-if="hasWidgetSlot(item.widgetId)">
70
- <CnWidgetWrapper
71
- :title="getWidgetTitle(item)"
72
- :icon-url="getWidgetIconUrl(item)"
73
- :icon-class="getWidgetIconClass(item)"
74
- :show-title="item.showTitle !== false"
75
- :buttons="getWidgetButtons(item)"
76
- :style-config="item.styleConfig || {}">
77
- <slot :name="'widget-' + item.widgetId" :item="item" :widget="getWidgetDef(item.widgetId)" />
78
- </CnWidgetWrapper>
79
- </template>
80
-
81
- <!-- NC Dashboard API widget -->
82
- <template v-else-if="isNcWidget(item)">
83
- <CnWidgetWrapper
84
- :title="getWidgetTitle(item)"
85
- :icon-url="getWidgetIconUrl(item)"
86
- :icon-class="getWidgetIconClass(item)"
87
- :show-title="item.showTitle !== false"
88
- :buttons="getWidgetButtons(item)"
89
- :style-config="item.styleConfig || {}">
90
- <CnWidgetRenderer
91
- :widget="getWidgetDef(item.widgetId)"
92
- :unavailable-text="unavailableLabel" />
93
- </CnWidgetWrapper>
94
- </template>
95
-
96
- <!-- Unknown widget fallback -->
97
- <CnWidgetWrapper
98
- v-else
99
- :title="getWidgetTitle(item)"
100
- :show-title="item.showTitle !== false">
101
- <div class="cn-dashboard-page__unknown">
102
- {{ unavailableLabel }}
103
- </div>
104
- </CnWidgetWrapper>
105
- </template>
106
- </CnDashboardGrid>
107
- </div>
108
- </template>
109
-
110
- <script>
111
- import { NcButton, NcEmptyContent, NcLoadingIcon } from '@nextcloud/vue'
112
- import Pencil from 'vue-material-design-icons/Pencil.vue'
113
- import Check from 'vue-material-design-icons/Check.vue'
114
- import ViewDashboardOutline from 'vue-material-design-icons/ViewDashboardOutline.vue'
115
- import CnDashboardGrid from '../CnDashboardGrid/CnDashboardGrid.vue'
116
- import CnWidgetWrapper from '../CnWidgetWrapper/CnWidgetWrapper.vue'
117
- import CnWidgetRenderer from '../CnWidgetRenderer/CnWidgetRenderer.vue'
118
- import CnTileWidget from '../CnTileWidget/CnTileWidget.vue'
119
-
120
- /**
121
- * CnDashboardPage — Top-level dashboard page component.
122
- *
123
- * The dashboard equivalent of CnIndexPage. Renders a configurable grid
124
- * of widgets from a `widgets` definition array and a `layout` array.
125
- *
126
- * Widget types:
127
- * 1. **Custom** — App provides rendering via `#widget-{widgetId}` slot
128
- * 2. **NC Dashboard API** — Widgets with `itemApiVersions` are auto-rendered
129
- * 3. **Tile** — Items with `type: 'tile'` render as quick-access tiles
130
- *
131
- * @example Basic usage with custom widgets
132
- * <CnDashboardPage
133
- * title="Dashboard"
134
- * :widgets="widgetDefs"
135
- * :layout="savedLayout"
136
- * @layout-change="saveLayout">
137
- * <template #widget-cases-by-status="{ item }">
138
- * <StatusChart :data="statusData" />
139
- * </template>
140
- * <template #widget-my-work="{ item }">
141
- * <MyWorkList :items="workItems" />
142
- * </template>
143
- * </CnDashboardPage>
144
- *
145
- * @example With NC Dashboard API widgets
146
- * <CnDashboardPage
147
- * title="Dashboard"
148
- * :widgets="[...appWidgets, ...ncWidgets]"
149
- * :layout="layout"
150
- * @layout-change="saveLayout" />
151
- */
152
- export default {
153
- name: 'CnDashboardPage',
154
-
155
- components: {
156
- NcButton,
157
- NcEmptyContent,
158
- NcLoadingIcon,
159
- Pencil,
160
- Check,
161
- ViewDashboardOutline,
162
- CnDashboardGrid,
163
- CnWidgetWrapper,
164
- CnWidgetRenderer,
165
- CnTileWidget,
166
- },
167
-
168
- props: {
169
- /** Page title */
170
- title: {
171
- type: String,
172
- default: '',
173
- },
174
- /** Page description (shown below title) */
175
- description: {
176
- type: String,
177
- default: '',
178
- },
179
- /**
180
- * Widget definitions array. Each widget defines metadata for rendering.
181
- *
182
- * Custom widgets: `{ id: 'my-widget', title: 'My Widget', type: 'custom' }`
183
- * NC API widgets: `{ id: 'calendar', title: 'Calendar', itemApiVersions: [1,2], ... }`
184
- * Tile widgets: `{ id: 'tile-files', type: 'tile', title: 'Files', icon: 'M12...', iconType: 'svg', backgroundColor: '#0082c9', textColor: '#fff', linkType: 'app', linkValue: 'files' }`
185
- *
186
- * @type {Array<{ id: string, title: string, type?: string, iconUrl?: string, iconClass?: string, buttons?: Array, itemApiVersions?: number[], reloadInterval?: number, [key: string]: any }>}
187
- */
188
- widgets: {
189
- type: Array,
190
- default: () => [],
191
- },
192
- /**
193
- * Layout array defining widget positions in the grid.
194
- *
195
- * Each item: `{ id: 'unique-id', widgetId: 'my-widget', gridX: 0, gridY: 0, gridWidth: 4, gridHeight: 3 }`
196
- *
197
- * Additional properties (showTitle, styleConfig, tile config) are passed through.
198
- *
199
- * @type {Array<{ id: string|number, widgetId: string, gridX: number, gridY: number, gridWidth: number, gridHeight: number, showTitle?: boolean, styleConfig?: object, [key: string]: any }>}
200
- */
201
- layout: {
202
- type: Array,
203
- default: () => [],
204
- },
205
- /** Whether the dashboard is loading */
206
- loading: {
207
- type: Boolean,
208
- default: false,
209
- },
210
- /** Whether to show the edit toggle button */
211
- allowEdit: {
212
- type: Boolean,
213
- default: false,
214
- },
215
- /** Number of grid columns */
216
- columns: {
217
- type: Number,
218
- default: 12,
219
- },
220
- /** Grid cell height in pixels */
221
- cellHeight: {
222
- type: Number,
223
- default: 80,
224
- },
225
- /** Grid margin in pixels */
226
- gridMargin: {
227
- type: Number,
228
- default: 12,
229
- },
230
- /** Label for the edit button */
231
- editLabel: {
232
- type: String,
233
- default: 'Edit',
234
- },
235
- /** Label for the done button (when editing) */
236
- doneLabel: {
237
- type: String,
238
- default: 'Done',
239
- },
240
- /** Label for the empty state */
241
- emptyLabel: {
242
- type: String,
243
- default: 'No widgets configured',
244
- },
245
- /** Label for unavailable widgets */
246
- unavailableLabel: {
247
- type: String,
248
- default: 'Widget not available',
249
- },
250
- },
251
-
252
- emits: ['layout-change', 'edit-toggle'],
253
-
254
- data() {
255
- return {
256
- isEditing: false,
257
- }
258
- },
259
-
260
- computed: {
261
- hasWidgets() {
262
- return this.layout.length > 0
263
- },
264
-
265
- widgetMap() {
266
- const map = {}
267
- for (const w of this.widgets) {
268
- map[w.id] = w
269
- }
270
- return map
271
- },
272
- },
273
-
274
- methods: {
275
- toggleEdit() {
276
- this.isEditing = !this.isEditing
277
- this.$emit('edit-toggle', this.isEditing)
278
- },
279
-
280
- onLayoutChange(updated) {
281
- this.$emit('layout-change', updated)
282
- },
283
-
284
- getWidgetDef(widgetId) {
285
- return this.widgetMap[widgetId] || null
286
- },
287
-
288
- getWidgetTitle(item) {
289
- const def = this.getWidgetDef(item.widgetId)
290
- return item.customTitle || def?.title || item.widgetId
291
- },
292
-
293
- getWidgetIconUrl(item) {
294
- const def = this.getWidgetDef(item.widgetId)
295
- return def?.iconUrl || null
296
- },
297
-
298
- getWidgetIconClass(item) {
299
- const def = this.getWidgetDef(item.widgetId)
300
- return def?.iconClass || null
301
- },
302
-
303
- getWidgetButtons(item) {
304
- const def = this.getWidgetDef(item.widgetId)
305
- return def?.buttons || []
306
- },
307
-
308
- isTile(item) {
309
- const def = this.getWidgetDef(item.widgetId)
310
- return def?.type === 'tile'
311
- },
312
-
313
- getTileConfig(item) {
314
- const def = this.getWidgetDef(item.widgetId)
315
- if (!def) return null
316
- return {
317
- title: def.title,
318
- icon: def.icon,
319
- iconType: def.iconType,
320
- backgroundColor: def.backgroundColor,
321
- textColor: def.textColor,
322
- linkType: def.linkType,
323
- linkValue: def.linkValue,
324
- }
325
- },
326
-
327
- isNcWidget(item) {
328
- const def = this.getWidgetDef(item.widgetId)
329
- return def?.itemApiVersions && def.itemApiVersions.length > 0
330
- },
331
-
332
- hasWidgetSlot(widgetId) {
333
- return !!this.$scopedSlots['widget-' + widgetId]
334
- },
335
- },
336
- }
337
- </script>
338
-
339
- <style scoped>
340
- .cn-dashboard-page {
341
- padding: 20px;
342
- max-width: 1400px;
343
- }
344
-
345
- .cn-dashboard-page__header {
346
- display: flex;
347
- justify-content: space-between;
348
- align-items: flex-start;
349
- margin-bottom: 20px;
350
- flex-wrap: wrap;
351
- gap: 12px;
352
- }
353
-
354
- .cn-dashboard-page__header-left {
355
- min-width: 0;
356
- }
357
-
358
- .cn-dashboard-page__title {
359
- margin: 0;
360
- font-size: 20px;
361
- font-weight: 700;
362
- }
363
-
364
- .cn-dashboard-page__description {
365
- margin: 4px 0 0;
366
- font-size: 14px;
367
- color: var(--color-text-maxcontrast);
368
- }
369
-
370
- .cn-dashboard-page__header-actions {
371
- display: flex;
372
- gap: 8px;
373
- flex-wrap: wrap;
374
- flex-shrink: 0;
375
- }
376
-
377
- .cn-dashboard-page__empty {
378
- padding: 60px 20px;
379
- }
380
-
381
- .cn-dashboard-page__unknown {
382
- display: flex;
383
- align-items: center;
384
- justify-content: center;
385
- height: 100%;
386
- color: var(--color-text-maxcontrast);
387
- font-size: 14px;
388
- padding: 16px;
389
- }
390
- </style>
1
+ <!--
2
+ CnDashboardPage — Top-level dashboard page with GridStack widget grid.
3
+
4
+ The dashboard equivalent of CnIndexPage. Assembles a complete dashboard
5
+ from a widget definition array and a layout array. Supports:
6
+ - Custom widgets via scoped slots (#widget-{widgetId})
7
+ - Nextcloud Dashboard API widgets (auto-rendered)
8
+ - Tile widgets (quick-access links)
9
+ - Drag-and-drop editing mode
10
+ - Header with title, actions, and edit toggle
11
+ -->
12
+ <template>
13
+ <div class="cn-dashboard-page">
14
+ <!-- Header -->
15
+ <div class="cn-dashboard-page__header">
16
+ <div class="cn-dashboard-page__header-left">
17
+ <h2 v-if="title" class="cn-dashboard-page__title">
18
+ {{ title }}
19
+ </h2>
20
+ <p v-if="description" class="cn-dashboard-page__description">
21
+ {{ description }}
22
+ </p>
23
+ </div>
24
+ <div class="cn-dashboard-page__header-actions">
25
+ <slot name="header-actions" />
26
+ <NcButton
27
+ v-if="allowEdit"
28
+ :type="isEditing ? 'primary' : 'secondary'"
29
+ @click="toggleEdit">
30
+ <template #icon>
31
+ <Pencil v-if="!isEditing" :size="20" />
32
+ <Check v-else :size="20" />
33
+ </template>
34
+ {{ isEditing ? doneLabel : editLabel }}
35
+ </NcButton>
36
+ </div>
37
+ </div>
38
+
39
+ <!-- Loading state -->
40
+ <NcLoadingIcon v-if="loading" />
41
+
42
+ <!-- Empty state -->
43
+ <div v-else-if="!hasWidgets" class="cn-dashboard-page__empty">
44
+ <slot name="empty">
45
+ <NcEmptyContent :description="emptyLabel">
46
+ <template #icon>
47
+ <ViewDashboardOutline :size="48" />
48
+ </template>
49
+ </NcEmptyContent>
50
+ </slot>
51
+ </div>
52
+
53
+ <!-- Dashboard grid -->
54
+ <CnDashboardGrid
55
+ v-else
56
+ :layout="layout"
57
+ :editable="isEditing"
58
+ :columns="columns"
59
+ :cell-height="cellHeight"
60
+ :margin="gridMargin"
61
+ @layout-change="onLayoutChange">
62
+ <template #widget="{ item }">
63
+ <!-- Tile widget -->
64
+ <CnTileWidget
65
+ v-if="isTile(item)"
66
+ :tile="getTileConfig(item)" />
67
+
68
+ <!-- Custom slot widget — apps provide their own rendering -->
69
+ <template v-else-if="hasWidgetSlot(item.widgetId)">
70
+ <CnWidgetWrapper
71
+ :title="getWidgetTitle(item)"
72
+ :icon-url="getWidgetIconUrl(item)"
73
+ :icon-class="getWidgetIconClass(item)"
74
+ :show-title="item.showTitle !== false"
75
+ :buttons="getWidgetButtons(item)"
76
+ :style-config="item.styleConfig || {}">
77
+ <slot :name="'widget-' + item.widgetId" :item="item" :widget="getWidgetDef(item.widgetId)" />
78
+ </CnWidgetWrapper>
79
+ </template>
80
+
81
+ <!-- NC Dashboard API widget -->
82
+ <template v-else-if="isNcWidget(item)">
83
+ <CnWidgetWrapper
84
+ :title="getWidgetTitle(item)"
85
+ :icon-url="getWidgetIconUrl(item)"
86
+ :icon-class="getWidgetIconClass(item)"
87
+ :show-title="item.showTitle !== false"
88
+ :buttons="getWidgetButtons(item)"
89
+ :style-config="item.styleConfig || {}">
90
+ <CnWidgetRenderer
91
+ :widget="getWidgetDef(item.widgetId)"
92
+ :unavailable-text="unavailableLabel" />
93
+ </CnWidgetWrapper>
94
+ </template>
95
+
96
+ <!-- Unknown widget fallback -->
97
+ <CnWidgetWrapper
98
+ v-else
99
+ :title="getWidgetTitle(item)"
100
+ :show-title="item.showTitle !== false">
101
+ <div class="cn-dashboard-page__unknown">
102
+ {{ unavailableLabel }}
103
+ </div>
104
+ </CnWidgetWrapper>
105
+ </template>
106
+ </CnDashboardGrid>
107
+ </div>
108
+ </template>
109
+
110
+ <script>
111
+ import { NcButton, NcEmptyContent, NcLoadingIcon } from '@nextcloud/vue'
112
+ import Pencil from 'vue-material-design-icons/Pencil.vue'
113
+ import Check from 'vue-material-design-icons/Check.vue'
114
+ import ViewDashboardOutline from 'vue-material-design-icons/ViewDashboardOutline.vue'
115
+ import CnDashboardGrid from '../CnDashboardGrid/CnDashboardGrid.vue'
116
+ import CnWidgetWrapper from '../CnWidgetWrapper/CnWidgetWrapper.vue'
117
+ import CnWidgetRenderer from '../CnWidgetRenderer/CnWidgetRenderer.vue'
118
+ import CnTileWidget from '../CnTileWidget/CnTileWidget.vue'
119
+
120
+ /**
121
+ * CnDashboardPage — Top-level dashboard page component.
122
+ *
123
+ * The dashboard equivalent of CnIndexPage. Renders a configurable grid
124
+ * of widgets from a `widgets` definition array and a `layout` array.
125
+ *
126
+ * Widget types:
127
+ * 1. **Custom** — App provides rendering via `#widget-{widgetId}` slot
128
+ * 2. **NC Dashboard API** — Widgets with `itemApiVersions` are auto-rendered
129
+ * 3. **Tile** — Items with `type: 'tile'` render as quick-access tiles
130
+ *
131
+ * @example Basic usage with custom widgets
132
+ * <CnDashboardPage
133
+ * title="Dashboard"
134
+ * :widgets="widgetDefs"
135
+ * :layout="savedLayout"
136
+ * @layout-change="saveLayout">
137
+ * <template #widget-cases-by-status="{ item }">
138
+ * <StatusChart :data="statusData" />
139
+ * </template>
140
+ * <template #widget-my-work="{ item }">
141
+ * <MyWorkList :items="workItems" />
142
+ * </template>
143
+ * </CnDashboardPage>
144
+ *
145
+ * @example With NC Dashboard API widgets
146
+ * <CnDashboardPage
147
+ * title="Dashboard"
148
+ * :widgets="[...appWidgets, ...ncWidgets]"
149
+ * :layout="layout"
150
+ * @layout-change="saveLayout" />
151
+ */
152
+ export default {
153
+ name: 'CnDashboardPage',
154
+
155
+ components: {
156
+ NcButton,
157
+ NcEmptyContent,
158
+ NcLoadingIcon,
159
+ Pencil,
160
+ Check,
161
+ ViewDashboardOutline,
162
+ CnDashboardGrid,
163
+ CnWidgetWrapper,
164
+ CnWidgetRenderer,
165
+ CnTileWidget,
166
+ },
167
+
168
+ props: {
169
+ /** Page title */
170
+ title: {
171
+ type: String,
172
+ default: '',
173
+ },
174
+ /** Page description (shown below title) */
175
+ description: {
176
+ type: String,
177
+ default: '',
178
+ },
179
+ /**
180
+ * Widget definitions array. Each widget defines metadata for rendering.
181
+ *
182
+ * Custom widgets: `{ id: 'my-widget', title: 'My Widget', type: 'custom' }`
183
+ * NC API widgets: `{ id: 'calendar', title: 'Calendar', itemApiVersions: [1,2], ... }`
184
+ * Tile widgets: `{ id: 'tile-files', type: 'tile', title: 'Files', icon: 'M12...', iconType: 'svg', backgroundColor: '#0082c9', textColor: '#fff', linkType: 'app', linkValue: 'files' }`
185
+ *
186
+ * @type {Array<{ id: string, title: string, type?: string, iconUrl?: string, iconClass?: string, buttons?: Array, itemApiVersions?: number[], reloadInterval?: number, [key: string]: any }>}
187
+ */
188
+ widgets: {
189
+ type: Array,
190
+ default: () => [],
191
+ },
192
+ /**
193
+ * Layout array defining widget positions in the grid.
194
+ *
195
+ * Each item: `{ id: 'unique-id', widgetId: 'my-widget', gridX: 0, gridY: 0, gridWidth: 4, gridHeight: 3 }`
196
+ *
197
+ * Additional properties (showTitle, styleConfig, tile config) are passed through.
198
+ *
199
+ * @type {Array<{ id: string|number, widgetId: string, gridX: number, gridY: number, gridWidth: number, gridHeight: number, showTitle?: boolean, styleConfig?: object, [key: string]: any }>}
200
+ */
201
+ layout: {
202
+ type: Array,
203
+ default: () => [],
204
+ },
205
+ /** Whether the dashboard is loading */
206
+ loading: {
207
+ type: Boolean,
208
+ default: false,
209
+ },
210
+ /** Whether to show the edit toggle button */
211
+ allowEdit: {
212
+ type: Boolean,
213
+ default: false,
214
+ },
215
+ /** Number of grid columns */
216
+ columns: {
217
+ type: Number,
218
+ default: 12,
219
+ },
220
+ /** Grid cell height in pixels */
221
+ cellHeight: {
222
+ type: Number,
223
+ default: 80,
224
+ },
225
+ /** Grid margin in pixels */
226
+ gridMargin: {
227
+ type: Number,
228
+ default: 12,
229
+ },
230
+ /** Label for the edit button */
231
+ editLabel: {
232
+ type: String,
233
+ default: 'Edit',
234
+ },
235
+ /** Label for the done button (when editing) */
236
+ doneLabel: {
237
+ type: String,
238
+ default: 'Done',
239
+ },
240
+ /** Label for the empty state */
241
+ emptyLabel: {
242
+ type: String,
243
+ default: 'No widgets configured',
244
+ },
245
+ /** Label for unavailable widgets */
246
+ unavailableLabel: {
247
+ type: String,
248
+ default: 'Widget not available',
249
+ },
250
+ },
251
+
252
+ emits: ['layout-change', 'edit-toggle'],
253
+
254
+ data() {
255
+ return {
256
+ isEditing: false,
257
+ }
258
+ },
259
+
260
+ computed: {
261
+ hasWidgets() {
262
+ return this.layout.length > 0
263
+ },
264
+
265
+ widgetMap() {
266
+ const map = {}
267
+ for (const w of this.widgets) {
268
+ map[w.id] = w
269
+ }
270
+ return map
271
+ },
272
+ },
273
+
274
+ methods: {
275
+ toggleEdit() {
276
+ this.isEditing = !this.isEditing
277
+ this.$emit('edit-toggle', this.isEditing)
278
+ },
279
+
280
+ onLayoutChange(updated) {
281
+ this.$emit('layout-change', updated)
282
+ },
283
+
284
+ getWidgetDef(widgetId) {
285
+ return this.widgetMap[widgetId] || null
286
+ },
287
+
288
+ getWidgetTitle(item) {
289
+ const def = this.getWidgetDef(item.widgetId)
290
+ return item.customTitle || def?.title || item.widgetId
291
+ },
292
+
293
+ getWidgetIconUrl(item) {
294
+ const def = this.getWidgetDef(item.widgetId)
295
+ return def?.iconUrl || null
296
+ },
297
+
298
+ getWidgetIconClass(item) {
299
+ const def = this.getWidgetDef(item.widgetId)
300
+ return def?.iconClass || null
301
+ },
302
+
303
+ getWidgetButtons(item) {
304
+ const def = this.getWidgetDef(item.widgetId)
305
+ return def?.buttons || []
306
+ },
307
+
308
+ isTile(item) {
309
+ const def = this.getWidgetDef(item.widgetId)
310
+ return def?.type === 'tile'
311
+ },
312
+
313
+ getTileConfig(item) {
314
+ const def = this.getWidgetDef(item.widgetId)
315
+ if (!def) return null
316
+ return {
317
+ title: def.title,
318
+ icon: def.icon,
319
+ iconType: def.iconType,
320
+ backgroundColor: def.backgroundColor,
321
+ textColor: def.textColor,
322
+ linkType: def.linkType,
323
+ linkValue: def.linkValue,
324
+ }
325
+ },
326
+
327
+ isNcWidget(item) {
328
+ const def = this.getWidgetDef(item.widgetId)
329
+ return def?.itemApiVersions && def.itemApiVersions.length > 0
330
+ },
331
+
332
+ hasWidgetSlot(widgetId) {
333
+ return !!this.$scopedSlots['widget-' + widgetId]
334
+ },
335
+ },
336
+ }
337
+ </script>
338
+
339
+ <style scoped>
340
+ .cn-dashboard-page {
341
+ padding: 20px;
342
+ max-width: 1400px;
343
+ }
344
+
345
+ .cn-dashboard-page__header {
346
+ display: flex;
347
+ justify-content: space-between;
348
+ align-items: flex-start;
349
+ margin-bottom: 20px;
350
+ flex-wrap: wrap;
351
+ gap: 12px;
352
+ }
353
+
354
+ .cn-dashboard-page__header-left {
355
+ min-width: 0;
356
+ }
357
+
358
+ .cn-dashboard-page__title {
359
+ margin: 0;
360
+ font-size: 20px;
361
+ font-weight: 700;
362
+ }
363
+
364
+ .cn-dashboard-page__description {
365
+ margin: 4px 0 0;
366
+ font-size: 14px;
367
+ color: var(--color-text-maxcontrast);
368
+ }
369
+
370
+ .cn-dashboard-page__header-actions {
371
+ display: flex;
372
+ gap: 8px;
373
+ flex-wrap: wrap;
374
+ flex-shrink: 0;
375
+ }
376
+
377
+ .cn-dashboard-page__empty {
378
+ padding: 60px 20px;
379
+ }
380
+
381
+ .cn-dashboard-page__unknown {
382
+ display: flex;
383
+ align-items: center;
384
+ justify-content: center;
385
+ height: 100%;
386
+ color: var(--color-text-maxcontrast);
387
+ font-size: 14px;
388
+ padding: 16px;
389
+ }
390
+ </style>