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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/nextcloud-vue.cjs +67614 -0
  2. package/dist/nextcloud-vue.cjs.js +13518 -13617
  3. package/dist/nextcloud-vue.cjs.js.map +1 -1
  4. package/dist/nextcloud-vue.cjs.map +1 -0
  5. package/dist/nextcloud-vue.css +1796 -1800
  6. package/dist/nextcloud-vue.esm.js +13518 -13617
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/package.json +3 -2
  9. package/src/components/CnActionsBar/CnActionsBar.vue +254 -254
  10. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +570 -570
  11. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -217
  12. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -121
  13. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +422 -422
  14. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -247
  15. package/src/components/CnCard/CnCard.vue +415 -415
  16. package/src/components/CnCardGrid/CnCardGrid.vue +156 -156
  17. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  18. package/src/components/CnChartWidget/CnChartWidget.vue +346 -346
  19. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  20. package/src/components/CnContextMenu/CnContextMenu.vue +142 -142
  21. package/src/components/CnCopyDialog/CnCopyDialog.vue +266 -266
  22. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -229
  23. package/src/components/CnDashboardPage/CnDashboardPage.vue +397 -397
  24. package/src/components/CnDataTable/CnDataTable.vue +362 -362
  25. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -177
  26. package/src/components/CnDetailCard/CnDetailCard.vue +225 -225
  27. package/src/components/CnDetailGrid/CnDetailGrid.vue +256 -256
  28. package/src/components/CnDetailPage/CnDetailPage.vue +432 -432
  29. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +234 -234
  30. package/src/components/CnFilterBar/CnFilterBar.vue +153 -153
  31. package/src/components/CnFormDialog/CnFormDialog.vue +1047 -1047
  32. package/src/components/CnIcon/CnIcon.vue +89 -89
  33. package/src/components/CnIndexPage/CnIndexPage.vue +981 -980
  34. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +536 -536
  35. package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -219
  36. package/src/components/CnItemCard/CnItemCard.vue +134 -134
  37. package/src/components/CnJsonViewer/CnJsonViewer.vue +312 -312
  38. package/src/components/CnKpiGrid/CnKpiGrid.vue +93 -93
  39. package/src/components/CnMassActionBar/CnMassActionBar.vue +161 -161
  40. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +327 -327
  41. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +245 -245
  42. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +191 -191
  43. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +494 -494
  44. package/src/components/CnNoteCard/CnNoteCard.vue +149 -149
  45. package/src/components/CnNotesCard/CnNotesCard.vue +416 -416
  46. package/src/components/CnObjectCard/CnObjectCard.vue +294 -294
  47. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +854 -854
  48. package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +289 -289
  49. package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +369 -369
  50. package/src/components/CnObjectSidebar/CnFilesTab.vue +287 -287
  51. package/src/components/CnObjectSidebar/CnNotesTab.vue +250 -250
  52. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +255 -255
  53. package/src/components/CnObjectSidebar/CnTagsTab.vue +259 -259
  54. package/src/components/CnObjectSidebar/CnTasksTab.vue +483 -483
  55. package/src/components/CnPageHeader/CnPageHeader.vue +61 -61
  56. package/src/components/CnPagination/CnPagination.vue +253 -253
  57. package/src/components/CnProgressBar/CnProgressBar.vue +262 -262
  58. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +793 -793
  59. package/src/components/CnRowActions/CnRowActions.vue +95 -95
  60. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -226
  61. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +788 -788
  62. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -305
  63. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -1398
  64. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -236
  65. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  66. package/src/components/CnSettingsSection/CnSettingsSection.vue +267 -267
  67. package/src/components/CnStatsBlock/CnStatsBlock.vue +437 -437
  68. package/src/components/CnStatsPanel/CnStatsPanel.vue +321 -321
  69. package/src/components/CnStatusBadge/CnStatusBadge.vue +90 -90
  70. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +545 -545
  71. package/src/components/CnTableWidget/CnTableWidget.vue +333 -333
  72. package/src/components/CnTasksCard/CnTasksCard.vue +374 -374
  73. package/src/components/CnTileWidget/CnTileWidget.vue +159 -159
  74. package/src/components/CnTimelineStages/CnTimelineStages.vue +294 -294
  75. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +436 -436
  76. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +313 -313
  77. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -180
  78. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +248 -248
@@ -1,422 +1,422 @@
1
- <template>
2
- <div class="cn-advanced-form-dialog__table-container">
3
- <table class="cn-advanced-form-dialog__table">
4
- <thead>
5
- <tr class="cn-advanced-form-dialog__table-row">
6
- <th class="cn-advanced-form-dialog__table-col-constrained">
7
- {{ t('nextcloud-vue', 'Property') }}
8
- </th>
9
- <th class="cn-advanced-form-dialog__table-col-expanded">
10
- {{ t('nextcloud-vue', 'Value') }}
11
- </th>
12
- </tr>
13
- </thead>
14
- <tbody>
15
- <tr
16
- v-for="([key, value]) in objectProperties"
17
- :key="key"
18
- class="cn-advanced-form-dialog__table-row"
19
- :class="{
20
- 'cn-advanced-form-dialog__table-row--selected': selectedProperty === key,
21
- 'cn-advanced-form-dialog__table-row--edited': formData[key] !== undefined,
22
- 'cn-advanced-form-dialog__table-row--non-editable': !isPropertyEditable(key, resolvedValue(key, value)),
23
- [getPropertyValidationClass(key, value)]: validationDisplay === 'indicator',
24
- }"
25
- @click="handleRowClick(key, $event)">
26
- <td class="cn-advanced-form-dialog__table-col-constrained cn-advanced-form-dialog__prop-cell">
27
- <div class="cn-advanced-form-dialog__prop-cell-content">
28
- <AlertCircle
29
- v-if="validationDisplay === 'indicator' && getPropertyValidationState(key, resolvedValue(key, value)) === 'invalid'"
30
- class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--error"
31
- :size="16"
32
- :title="getPropertyErrorMessage(key, resolvedValue(key, value))" />
33
- <Alert
34
- v-else-if="validationDisplay === 'indicator' && getPropertyValidationState(key, resolvedValue(key, value)) === 'warning'"
35
- class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--warning"
36
- :size="16"
37
- :title="getPropertyWarningMessage(key, resolvedValue(key, value))" />
38
- <Plus
39
- v-else-if="validationDisplay === 'indicator' && getPropertyValidationState(key, resolvedValue(key, value)) === 'new'"
40
- class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--new"
41
- :size="16"
42
- :title="getPropertyNewMessage(key)" />
43
- <LockOutline
44
- v-else-if="!isPropertyEditable(key, resolvedValue(key, value))"
45
- class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--lock"
46
- :size="16"
47
- :title="getEditabilityWarning(key, resolvedValue(key, value)) || ''" />
48
- <span :title="getPropertyTooltip(key)">{{ getPropertyDisplayName(key) }}</span>
49
- </div>
50
- </td>
51
- <td class="cn-advanced-form-dialog__table-col-expanded cn-advanced-form-dialog__value-cell">
52
- <CnPropertyValueCell
53
- :ref="'cell-' + key"
54
- :property-key="key"
55
- :schema="schema"
56
- :value="resolvedValue(key, value)"
57
- :is-editable="isPropertyEditable(key, resolvedValue(key, value))"
58
- :is-editing="selectedProperty === key"
59
- :display-name="getPropertyDisplayName(key)"
60
- :editability-warning="getPropertyEditabilityWarning(key, resolvedValue(key, value))"
61
- @update:value="onPropertyValueUpdate(key, $event)" />
62
- </td>
63
- </tr>
64
- </tbody>
65
- </table>
66
- </div>
67
- </template>
68
-
69
- <script>
70
- import AlertCircle from 'vue-material-design-icons/AlertCircle.vue'
71
- import Alert from 'vue-material-design-icons/Alert.vue'
72
- import LockOutline from 'vue-material-design-icons/LockOutline.vue'
73
- import Plus from 'vue-material-design-icons/Plus.vue'
74
- import CnPropertyValueCell from './CnPropertyValueCell.vue'
75
-
76
- export default {
77
- name: 'CnPropertiesTab',
78
-
79
- components: {
80
- AlertCircle,
81
- Alert,
82
- LockOutline,
83
- Plus,
84
- CnPropertyValueCell,
85
- },
86
-
87
- props: {
88
- schema: { type: Object, default: null },
89
- item: { type: Object, default: null },
90
- formData: { type: Object, default: () => ({}) },
91
- selectedProperty: { type: String, default: null },
92
- editableTypes: { type: Array, default: () => ['string', 'number', 'integer', 'boolean'] },
93
- validationDisplay: { type: String, default: 'indicator' },
94
- excludeFields: { type: Array, default: () => [] },
95
- includeFields: { type: Array, default: null },
96
- },
97
-
98
- computed: {
99
- objectProperties() {
100
- const schemaProps = this.schema?.properties || {}
101
- const obj = this.item || {}
102
- const exclude = this.excludeFields || []
103
- const include = this.includeFields
104
- const filterKey = (k) => {
105
- if (k === '@self' || k === 'id') return false
106
- if (exclude.includes(k)) return false
107
- if (include && !include.includes(k)) return false
108
- return true
109
- }
110
- const existing = Object.entries(obj).filter(([k]) => filterKey(k))
111
- const missing = []
112
- for (const [key, prop] of Object.entries(schemaProps)) {
113
- if (!filterKey(key)) continue
114
- if (!Object.prototype.hasOwnProperty.call(obj, key)) {
115
- let def
116
- switch (prop.type) {
117
- case 'string': def = prop.const ?? ''; break
118
- case 'number':
119
- case 'integer': def = 0; break
120
- case 'boolean': def = false; break
121
- case 'array': def = []; break
122
- case 'object': def = {}; break
123
- default: def = ''
124
- }
125
- missing.push([key, def])
126
- }
127
- }
128
- return [...existing, ...missing]
129
- },
130
- },
131
-
132
- methods: {
133
- /**
134
- * The effective value for a key: formData override or the object's own value
135
- * @param {string} key - The property key to look up
136
- * @param {*} objectValue - The fallback value from the object
137
- */
138
- resolvedValue(key, objectValue) {
139
- return this.formData[key] !== undefined ? this.formData[key] : objectValue
140
- },
141
-
142
- onPropertyValueUpdate(key, value) {
143
- this.$emit('update:property-value', { key, value })
144
- },
145
-
146
- isPropertyEditable(key, value) {
147
- const prop = this.schema?.properties?.[key]
148
- if (!prop) return true
149
- if (prop.const !== undefined) return false
150
- if (prop.immutable && value != null && value !== '') return false
151
- const type = prop.type || 'string'
152
- return this.editableTypes.includes(type)
153
- },
154
-
155
- getPropertyDisplayName(key) {
156
- return (this.schema?.properties?.[key]?.title) || key
157
- },
158
-
159
- getPropertyTooltip(key) {
160
- const prop = this.schema?.properties?.[key]
161
- if (prop?.description) {
162
- if (prop.title && prop.title !== key) {
163
- return `${prop.title}: ${prop.description}`
164
- }
165
- return prop.description
166
- }
167
- return `Property: ${key}`
168
- },
169
-
170
- getPropertyValidationClass(key, value) {
171
- const state = this.getPropertyValidationState(key, value)
172
- switch (state) {
173
- case 'invalid': return 'cn-advanced-form-dialog__table-row--invalid'
174
- case 'warning': return 'cn-advanced-form-dialog__table-row--warning'
175
- case 'new': return 'cn-advanced-form-dialog__table-row--new'
176
- case 'valid': return 'cn-advanced-form-dialog__table-row--valid'
177
- default: return ''
178
- }
179
- },
180
-
181
- getPropertyValidationState(key, value) {
182
- const prop = this.schema?.properties?.[key]
183
- const existsInObject = this.item ? Object.prototype.hasOwnProperty.call(this.item, key) : false
184
- if (!prop) return 'warning'
185
- if (!existsInObject) return 'new'
186
- if (this.isValidPropertyValue(key, value, prop)) return 'valid'
187
- return 'invalid'
188
- },
189
-
190
- isValidPropertyValue(key, value, schemaProperty) {
191
- if (value === null || value === undefined || value === '') {
192
- const required = (this.schema?.required || []).includes(key) || schemaProperty?.required
193
- return !required
194
- }
195
- const type = schemaProperty?.type || 'string'
196
- switch (type) {
197
- case 'string':
198
- if (typeof value !== 'string') return false
199
- if (schemaProperty?.format === 'date-time' && !this.isValidDate(value)) return false
200
- if (schemaProperty?.const && value !== schemaProperty.const) return false
201
- return true
202
- case 'number':
203
- return typeof value === 'number' && !Number.isNaN(value)
204
- case 'boolean':
205
- return typeof value === 'boolean'
206
- case 'array':
207
- return Array.isArray(value)
208
- case 'object':
209
- return typeof value === 'object' && value !== null && !Array.isArray(value)
210
- default:
211
- return true
212
- }
213
- },
214
-
215
- getPropertyErrorMessage(key, value) {
216
- const prop = this.schema?.properties?.[key]
217
- if (!prop) {
218
- return `Property '${key}' is not defined in the current schema. This property exists in the object but is not part of the schema definition.`
219
- }
220
- const isRequired = (this.schema?.required || []).includes(key) || prop.required
221
- if ((value === null || value === undefined || value === '') && isRequired) {
222
- return `Required property '${key}' is missing or empty.`
223
- }
224
- const expectedType = prop.type
225
- const actualType = Array.isArray(value) ? 'array' : typeof value
226
- if (expectedType && expectedType !== actualType) {
227
- return `Property '${key}' should be ${expectedType} but is ${actualType}.`
228
- }
229
- if (prop.format === 'date-time' && !this.isValidDate(value)) {
230
- return `Property '${key}' should be a valid date-time value.`
231
- }
232
- if (prop.const && value !== prop.const) {
233
- return `Property '${key}' should be '${prop.const}' but is '${value}'.`
234
- }
235
- return `Property '${key}' has an invalid value.`
236
- },
237
-
238
- getPropertyWarningMessage(key, value) {
239
- const displayValue = String(value).length > 100 ? String(value).slice(0, 100) + '…' : String(value)
240
- return `Property '${key}' exists in the object but is not defined in the current schema. This might happen when property names are changed in the schema. Current value: '${displayValue}'.`
241
- },
242
-
243
- getPropertyNewMessage(key) {
244
- return `Property '${key}' is defined in the schema but doesn't have a value yet. Click to add a value.`
245
- },
246
-
247
- getPropertyEditabilityWarning(key, value) {
248
- if (!this.isPropertyEditable(key, value)) {
249
- return 'This property cannot be edited in the Properties tab. Use the Data tab to modify it.'
250
- }
251
- return null
252
- },
253
-
254
- getEditabilityWarning(key, value) {
255
- const prop = this.schema?.properties?.[key]
256
- if (prop?.const !== undefined) {
257
- return `This property is constant and must always be '${prop.const}'. Const properties cannot be modified to maintain data integrity.`
258
- }
259
- if (prop?.immutable && (value !== null && value !== undefined && value !== '')) {
260
- const displayValue = String(value).length > 100 ? String(value).slice(0, 100) + '…' : String(value)
261
- return `This property is immutable and cannot be changed once it has a value. Current value: '${displayValue}'. Immutable properties preserve data consistency.`
262
- }
263
- if (!this.isPropertyEditable(key, value)) {
264
- return this.getPropertyEditabilityWarning(key, value)
265
- }
266
- return null
267
- },
268
-
269
- handleRowClick(key, event) {
270
- if (event.target.tagName === 'INPUT' || event.target.tagName === 'BUTTON' || event.target.closest('.cn-advanced-form-dialog__value-input-container')) return
271
- const value = this.resolvedValue(key, this.objectProperties.find(([k]) => k === key)?.[1])
272
- if (!this.isPropertyEditable(key, value)) return
273
- const prop = this.schema?.properties?.[key]
274
- if (prop && !this.editableTypes.includes(prop.type || 'string')) return
275
- this.$emit('update:selected-property', key)
276
- this.$nextTick(() => {
277
- const ref = this.$refs['cell-' + key]
278
- const cell = ref && (Array.isArray(ref) ? ref[0] : ref)
279
- if (cell && cell.focus) cell.focus()
280
- })
281
- },
282
-
283
- isValidDate(v) {
284
- if (!v) return false
285
- const d = new Date(v)
286
- return d instanceof Date && !Number.isNaN(d.getTime())
287
- },
288
- },
289
- }
290
- </script>
291
-
292
- <style scoped>
293
- .cn-advanced-form-dialog__table-container {
294
- background: var(--color-main-background);
295
- border-radius: var(--border-radius);
296
- overflow: hidden;
297
- box-shadow: 0 2px 4px var(--color-box-shadow);
298
- border: 1px solid var(--color-border);
299
- margin-bottom: calc(5 * var(--default-grid-baseline));
300
- }
301
-
302
- .cn-advanced-form-dialog__table {
303
- width: 100%;
304
- border-collapse: collapse;
305
- background-color: var(--color-main-background);
306
- }
307
-
308
- .cn-advanced-form-dialog__table th,
309
- .cn-advanced-form-dialog__table td {
310
- padding: calc(3 * var(--default-grid-baseline));
311
- text-align: left;
312
- border-bottom: 1px solid var(--color-border);
313
- vertical-align: middle;
314
- }
315
-
316
- .cn-advanced-form-dialog__table th {
317
- background: var(--color-background-dark);
318
- font-weight: 500;
319
- color: var(--color-text-maxcontrast);
320
- }
321
-
322
- .cn-advanced-form-dialog__table-row {
323
- cursor: pointer;
324
- transition: background-color 0.2s ease;
325
- background-color: var(--color-main-background);
326
- }
327
-
328
- .cn-advanced-form-dialog__table-row:hover {
329
- background-color: var(--color-background-hover);
330
- }
331
-
332
- /* Active/selected row: light blue; ensure it wins over validation state classes */
333
- .cn-advanced-form-dialog__table-row.cn-advanced-form-dialog__table-row--selected,
334
- .cn-advanced-form-dialog__table-row--selected:hover {
335
- background-color: var(--color-primary-light);
336
- box-shadow: inset 3px 0 0 0 var(--color-primary);
337
- }
338
-
339
- .cn-advanced-form-dialog__table-row--edited {
340
- background-color: var(--color-success-light);
341
- box-shadow: inset 3px 0 0 0 var(--color-success);
342
- }
343
-
344
- .cn-advanced-form-dialog__table-row--non-editable {
345
- background-color: var(--color-background-dark);
346
- cursor: not-allowed;
347
- opacity: 0.7;
348
- }
349
-
350
- .cn-advanced-form-dialog__table-row--non-editable * {
351
- cursor: not-allowed !important;
352
- }
353
-
354
- .cn-advanced-form-dialog__table-row--valid {
355
- box-shadow: inset 3px 0 0 0 var(--color-success);
356
- }
357
-
358
- .cn-advanced-form-dialog__table-row--invalid {
359
- background-color: var(--color-error-light);
360
- box-shadow: inset 3px 0 0 0 var(--color-error);
361
- }
362
-
363
- .cn-advanced-form-dialog__table-row--warning {
364
- background-color: var(--color-warning-light);
365
- box-shadow: inset 3px 0 0 0 var(--color-warning);
366
- }
367
-
368
- .cn-advanced-form-dialog__table-row--new {
369
- box-shadow: inset 3px 0 0 0 var(--color-primary-element);
370
- }
371
-
372
- .cn-advanced-form-dialog__table-col-constrained {
373
- width: 150px;
374
- max-width: 150px;
375
- overflow: hidden;
376
- text-overflow: ellipsis;
377
- white-space: nowrap;
378
- }
379
-
380
- .cn-advanced-form-dialog__table-col-expanded {
381
- width: auto;
382
- min-width: 200px;
383
- }
384
-
385
- .cn-advanced-form-dialog__prop-cell {
386
- width: 30%;
387
- font-weight: 600;
388
- box-shadow: inset 3px 0 0 0 var(--color-primary);
389
- }
390
-
391
- .cn-advanced-form-dialog__value-cell {
392
- width: 70%;
393
- word-break: break-word;
394
- border-radius: 4px;
395
- }
396
-
397
- .cn-advanced-form-dialog__prop-cell-content {
398
- display: flex;
399
- align-items: center;
400
- gap: 8px;
401
- }
402
-
403
- .cn-advanced-form-dialog__validation-icon {
404
- flex-shrink: 0;
405
- }
406
-
407
- .cn-advanced-form-dialog__validation-icon--error {
408
- color: var(--color-error);
409
- }
410
-
411
- .cn-advanced-form-dialog__validation-icon--warning {
412
- color: var(--color-warning);
413
- }
414
-
415
- .cn-advanced-form-dialog__validation-icon--lock {
416
- color: var(--color-text-lighter);
417
- }
418
-
419
- .cn-advanced-form-dialog__validation-icon--new {
420
- color: var(--color-primary-element);
421
- }
422
- </style>
1
+ <template>
2
+ <div class="cn-advanced-form-dialog__table-container">
3
+ <table class="cn-advanced-form-dialog__table">
4
+ <thead>
5
+ <tr class="cn-advanced-form-dialog__table-row">
6
+ <th class="cn-advanced-form-dialog__table-col-constrained">
7
+ {{ t('nextcloud-vue', 'Property') }}
8
+ </th>
9
+ <th class="cn-advanced-form-dialog__table-col-expanded">
10
+ {{ t('nextcloud-vue', 'Value') }}
11
+ </th>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <tr
16
+ v-for="([key, value]) in objectProperties"
17
+ :key="key"
18
+ class="cn-advanced-form-dialog__table-row"
19
+ :class="{
20
+ 'cn-advanced-form-dialog__table-row--selected': selectedProperty === key,
21
+ 'cn-advanced-form-dialog__table-row--edited': formData[key] !== undefined,
22
+ 'cn-advanced-form-dialog__table-row--non-editable': !isPropertyEditable(key, resolvedValue(key, value)),
23
+ [getPropertyValidationClass(key, value)]: validationDisplay === 'indicator',
24
+ }"
25
+ @click="handleRowClick(key, $event)">
26
+ <td class="cn-advanced-form-dialog__table-col-constrained cn-advanced-form-dialog__prop-cell">
27
+ <div class="cn-advanced-form-dialog__prop-cell-content">
28
+ <AlertCircle
29
+ v-if="validationDisplay === 'indicator' && getPropertyValidationState(key, resolvedValue(key, value)) === 'invalid'"
30
+ class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--error"
31
+ :size="16"
32
+ :title="getPropertyErrorMessage(key, resolvedValue(key, value))" />
33
+ <Alert
34
+ v-else-if="validationDisplay === 'indicator' && getPropertyValidationState(key, resolvedValue(key, value)) === 'warning'"
35
+ class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--warning"
36
+ :size="16"
37
+ :title="getPropertyWarningMessage(key, resolvedValue(key, value))" />
38
+ <Plus
39
+ v-else-if="validationDisplay === 'indicator' && getPropertyValidationState(key, resolvedValue(key, value)) === 'new'"
40
+ class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--new"
41
+ :size="16"
42
+ :title="getPropertyNewMessage(key)" />
43
+ <LockOutline
44
+ v-else-if="!isPropertyEditable(key, resolvedValue(key, value))"
45
+ class="cn-advanced-form-dialog__validation-icon cn-advanced-form-dialog__validation-icon--lock"
46
+ :size="16"
47
+ :title="getEditabilityWarning(key, resolvedValue(key, value)) || ''" />
48
+ <span :title="getPropertyTooltip(key)">{{ getPropertyDisplayName(key) }}</span>
49
+ </div>
50
+ </td>
51
+ <td class="cn-advanced-form-dialog__table-col-expanded cn-advanced-form-dialog__value-cell">
52
+ <CnPropertyValueCell
53
+ :ref="'cell-' + key"
54
+ :property-key="key"
55
+ :schema="schema"
56
+ :value="resolvedValue(key, value)"
57
+ :is-editable="isPropertyEditable(key, resolvedValue(key, value))"
58
+ :is-editing="selectedProperty === key"
59
+ :display-name="getPropertyDisplayName(key)"
60
+ :editability-warning="getPropertyEditabilityWarning(key, resolvedValue(key, value))"
61
+ @update:value="onPropertyValueUpdate(key, $event)" />
62
+ </td>
63
+ </tr>
64
+ </tbody>
65
+ </table>
66
+ </div>
67
+ </template>
68
+
69
+ <script>
70
+ import AlertCircle from 'vue-material-design-icons/AlertCircle.vue'
71
+ import Alert from 'vue-material-design-icons/Alert.vue'
72
+ import LockOutline from 'vue-material-design-icons/LockOutline.vue'
73
+ import Plus from 'vue-material-design-icons/Plus.vue'
74
+ import CnPropertyValueCell from './CnPropertyValueCell.vue'
75
+
76
+ export default {
77
+ name: 'CnPropertiesTab',
78
+
79
+ components: {
80
+ AlertCircle,
81
+ Alert,
82
+ LockOutline,
83
+ Plus,
84
+ CnPropertyValueCell,
85
+ },
86
+
87
+ props: {
88
+ schema: { type: Object, default: null },
89
+ item: { type: Object, default: null },
90
+ formData: { type: Object, default: () => ({}) },
91
+ selectedProperty: { type: String, default: null },
92
+ editableTypes: { type: Array, default: () => ['string', 'number', 'integer', 'boolean'] },
93
+ validationDisplay: { type: String, default: 'indicator' },
94
+ excludeFields: { type: Array, default: () => [] },
95
+ includeFields: { type: Array, default: null },
96
+ },
97
+
98
+ computed: {
99
+ objectProperties() {
100
+ const schemaProps = this.schema?.properties || {}
101
+ const obj = this.item || {}
102
+ const exclude = this.excludeFields || []
103
+ const include = this.includeFields
104
+ const filterKey = (k) => {
105
+ if (k === '@self' || k === 'id') return false
106
+ if (exclude.includes(k)) return false
107
+ if (include && !include.includes(k)) return false
108
+ return true
109
+ }
110
+ const existing = Object.entries(obj).filter(([k]) => filterKey(k))
111
+ const missing = []
112
+ for (const [key, prop] of Object.entries(schemaProps)) {
113
+ if (!filterKey(key)) continue
114
+ if (!Object.prototype.hasOwnProperty.call(obj, key)) {
115
+ let def
116
+ switch (prop.type) {
117
+ case 'string': def = prop.const ?? ''; break
118
+ case 'number':
119
+ case 'integer': def = 0; break
120
+ case 'boolean': def = false; break
121
+ case 'array': def = []; break
122
+ case 'object': def = {}; break
123
+ default: def = ''
124
+ }
125
+ missing.push([key, def])
126
+ }
127
+ }
128
+ return [...existing, ...missing]
129
+ },
130
+ },
131
+
132
+ methods: {
133
+ /**
134
+ * The effective value for a key: formData override or the object's own value
135
+ * @param {string} key - The property key to look up
136
+ * @param {*} objectValue - The fallback value from the object
137
+ */
138
+ resolvedValue(key, objectValue) {
139
+ return this.formData[key] !== undefined ? this.formData[key] : objectValue
140
+ },
141
+
142
+ onPropertyValueUpdate(key, value) {
143
+ this.$emit('update:property-value', { key, value })
144
+ },
145
+
146
+ isPropertyEditable(key, value) {
147
+ const prop = this.schema?.properties?.[key]
148
+ if (!prop) return true
149
+ if (prop.const !== undefined) return false
150
+ if (prop.immutable && value != null && value !== '') return false
151
+ const type = prop.type || 'string'
152
+ return this.editableTypes.includes(type)
153
+ },
154
+
155
+ getPropertyDisplayName(key) {
156
+ return (this.schema?.properties?.[key]?.title) || key
157
+ },
158
+
159
+ getPropertyTooltip(key) {
160
+ const prop = this.schema?.properties?.[key]
161
+ if (prop?.description) {
162
+ if (prop.title && prop.title !== key) {
163
+ return `${prop.title}: ${prop.description}`
164
+ }
165
+ return prop.description
166
+ }
167
+ return `Property: ${key}`
168
+ },
169
+
170
+ getPropertyValidationClass(key, value) {
171
+ const state = this.getPropertyValidationState(key, value)
172
+ switch (state) {
173
+ case 'invalid': return 'cn-advanced-form-dialog__table-row--invalid'
174
+ case 'warning': return 'cn-advanced-form-dialog__table-row--warning'
175
+ case 'new': return 'cn-advanced-form-dialog__table-row--new'
176
+ case 'valid': return 'cn-advanced-form-dialog__table-row--valid'
177
+ default: return ''
178
+ }
179
+ },
180
+
181
+ getPropertyValidationState(key, value) {
182
+ const prop = this.schema?.properties?.[key]
183
+ const existsInObject = this.item ? Object.prototype.hasOwnProperty.call(this.item, key) : false
184
+ if (!prop) return 'warning'
185
+ if (!existsInObject) return 'new'
186
+ if (this.isValidPropertyValue(key, value, prop)) return 'valid'
187
+ return 'invalid'
188
+ },
189
+
190
+ isValidPropertyValue(key, value, schemaProperty) {
191
+ if (value === null || value === undefined || value === '') {
192
+ const required = (this.schema?.required || []).includes(key) || schemaProperty?.required
193
+ return !required
194
+ }
195
+ const type = schemaProperty?.type || 'string'
196
+ switch (type) {
197
+ case 'string':
198
+ if (typeof value !== 'string') return false
199
+ if (schemaProperty?.format === 'date-time' && !this.isValidDate(value)) return false
200
+ if (schemaProperty?.const && value !== schemaProperty.const) return false
201
+ return true
202
+ case 'number':
203
+ return typeof value === 'number' && !Number.isNaN(value)
204
+ case 'boolean':
205
+ return typeof value === 'boolean'
206
+ case 'array':
207
+ return Array.isArray(value)
208
+ case 'object':
209
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
210
+ default:
211
+ return true
212
+ }
213
+ },
214
+
215
+ getPropertyErrorMessage(key, value) {
216
+ const prop = this.schema?.properties?.[key]
217
+ if (!prop) {
218
+ return `Property '${key}' is not defined in the current schema. This property exists in the object but is not part of the schema definition.`
219
+ }
220
+ const isRequired = (this.schema?.required || []).includes(key) || prop.required
221
+ if ((value === null || value === undefined || value === '') && isRequired) {
222
+ return `Required property '${key}' is missing or empty.`
223
+ }
224
+ const expectedType = prop.type
225
+ const actualType = Array.isArray(value) ? 'array' : typeof value
226
+ if (expectedType && expectedType !== actualType) {
227
+ return `Property '${key}' should be ${expectedType} but is ${actualType}.`
228
+ }
229
+ if (prop.format === 'date-time' && !this.isValidDate(value)) {
230
+ return `Property '${key}' should be a valid date-time value.`
231
+ }
232
+ if (prop.const && value !== prop.const) {
233
+ return `Property '${key}' should be '${prop.const}' but is '${value}'.`
234
+ }
235
+ return `Property '${key}' has an invalid value.`
236
+ },
237
+
238
+ getPropertyWarningMessage(key, value) {
239
+ const displayValue = String(value).length > 100 ? String(value).slice(0, 100) + '…' : String(value)
240
+ return `Property '${key}' exists in the object but is not defined in the current schema. This might happen when property names are changed in the schema. Current value: '${displayValue}'.`
241
+ },
242
+
243
+ getPropertyNewMessage(key) {
244
+ return `Property '${key}' is defined in the schema but doesn't have a value yet. Click to add a value.`
245
+ },
246
+
247
+ getPropertyEditabilityWarning(key, value) {
248
+ if (!this.isPropertyEditable(key, value)) {
249
+ return 'This property cannot be edited in the Properties tab. Use the Data tab to modify it.'
250
+ }
251
+ return null
252
+ },
253
+
254
+ getEditabilityWarning(key, value) {
255
+ const prop = this.schema?.properties?.[key]
256
+ if (prop?.const !== undefined) {
257
+ return `This property is constant and must always be '${prop.const}'. Const properties cannot be modified to maintain data integrity.`
258
+ }
259
+ if (prop?.immutable && (value !== null && value !== undefined && value !== '')) {
260
+ const displayValue = String(value).length > 100 ? String(value).slice(0, 100) + '…' : String(value)
261
+ return `This property is immutable and cannot be changed once it has a value. Current value: '${displayValue}'. Immutable properties preserve data consistency.`
262
+ }
263
+ if (!this.isPropertyEditable(key, value)) {
264
+ return this.getPropertyEditabilityWarning(key, value)
265
+ }
266
+ return null
267
+ },
268
+
269
+ handleRowClick(key, event) {
270
+ if (event.target.tagName === 'INPUT' || event.target.tagName === 'BUTTON' || event.target.closest('.cn-advanced-form-dialog__value-input-container')) return
271
+ const value = this.resolvedValue(key, this.objectProperties.find(([k]) => k === key)?.[1])
272
+ if (!this.isPropertyEditable(key, value)) return
273
+ const prop = this.schema?.properties?.[key]
274
+ if (prop && !this.editableTypes.includes(prop.type || 'string')) return
275
+ this.$emit('update:selected-property', key)
276
+ this.$nextTick(() => {
277
+ const ref = this.$refs['cell-' + key]
278
+ const cell = ref && (Array.isArray(ref) ? ref[0] : ref)
279
+ if (cell && cell.focus) cell.focus()
280
+ })
281
+ },
282
+
283
+ isValidDate(v) {
284
+ if (!v) return false
285
+ const d = new Date(v)
286
+ return d instanceof Date && !Number.isNaN(d.getTime())
287
+ },
288
+ },
289
+ }
290
+ </script>
291
+
292
+ <style scoped>
293
+ .cn-advanced-form-dialog__table-container {
294
+ background: var(--color-main-background);
295
+ border-radius: var(--border-radius);
296
+ overflow: hidden;
297
+ box-shadow: 0 2px 4px var(--color-box-shadow);
298
+ border: 1px solid var(--color-border);
299
+ margin-bottom: calc(5 * var(--default-grid-baseline));
300
+ }
301
+
302
+ .cn-advanced-form-dialog__table {
303
+ width: 100%;
304
+ border-collapse: collapse;
305
+ background-color: var(--color-main-background);
306
+ }
307
+
308
+ .cn-advanced-form-dialog__table th,
309
+ .cn-advanced-form-dialog__table td {
310
+ padding: calc(3 * var(--default-grid-baseline));
311
+ text-align: left;
312
+ border-bottom: 1px solid var(--color-border);
313
+ vertical-align: middle;
314
+ }
315
+
316
+ .cn-advanced-form-dialog__table th {
317
+ background: var(--color-background-dark);
318
+ font-weight: 500;
319
+ color: var(--color-text-maxcontrast);
320
+ }
321
+
322
+ .cn-advanced-form-dialog__table-row {
323
+ cursor: pointer;
324
+ transition: background-color 0.2s ease;
325
+ background-color: var(--color-main-background);
326
+ }
327
+
328
+ .cn-advanced-form-dialog__table-row:hover {
329
+ background-color: var(--color-background-hover);
330
+ }
331
+
332
+ /* Active/selected row: light blue; ensure it wins over validation state classes */
333
+ .cn-advanced-form-dialog__table-row.cn-advanced-form-dialog__table-row--selected,
334
+ .cn-advanced-form-dialog__table-row--selected:hover {
335
+ background-color: var(--color-primary-light);
336
+ box-shadow: inset 3px 0 0 0 var(--color-primary);
337
+ }
338
+
339
+ .cn-advanced-form-dialog__table-row--edited {
340
+ background-color: var(--color-success-light);
341
+ box-shadow: inset 3px 0 0 0 var(--color-success);
342
+ }
343
+
344
+ .cn-advanced-form-dialog__table-row--non-editable {
345
+ background-color: var(--color-background-dark);
346
+ cursor: not-allowed;
347
+ opacity: 0.7;
348
+ }
349
+
350
+ .cn-advanced-form-dialog__table-row--non-editable * {
351
+ cursor: not-allowed !important;
352
+ }
353
+
354
+ .cn-advanced-form-dialog__table-row--valid {
355
+ box-shadow: inset 3px 0 0 0 var(--color-success);
356
+ }
357
+
358
+ .cn-advanced-form-dialog__table-row--invalid {
359
+ background-color: var(--color-error-light);
360
+ box-shadow: inset 3px 0 0 0 var(--color-error);
361
+ }
362
+
363
+ .cn-advanced-form-dialog__table-row--warning {
364
+ background-color: var(--color-warning-light);
365
+ box-shadow: inset 3px 0 0 0 var(--color-warning);
366
+ }
367
+
368
+ .cn-advanced-form-dialog__table-row--new {
369
+ box-shadow: inset 3px 0 0 0 var(--color-primary-element);
370
+ }
371
+
372
+ .cn-advanced-form-dialog__table-col-constrained {
373
+ width: 150px;
374
+ max-width: 150px;
375
+ overflow: hidden;
376
+ text-overflow: ellipsis;
377
+ white-space: nowrap;
378
+ }
379
+
380
+ .cn-advanced-form-dialog__table-col-expanded {
381
+ width: auto;
382
+ min-width: 200px;
383
+ }
384
+
385
+ .cn-advanced-form-dialog__prop-cell {
386
+ width: 30%;
387
+ font-weight: 600;
388
+ box-shadow: inset 3px 0 0 0 var(--color-primary);
389
+ }
390
+
391
+ .cn-advanced-form-dialog__value-cell {
392
+ width: 70%;
393
+ word-break: break-word;
394
+ border-radius: 4px;
395
+ }
396
+
397
+ .cn-advanced-form-dialog__prop-cell-content {
398
+ display: flex;
399
+ align-items: center;
400
+ gap: 8px;
401
+ }
402
+
403
+ .cn-advanced-form-dialog__validation-icon {
404
+ flex-shrink: 0;
405
+ }
406
+
407
+ .cn-advanced-form-dialog__validation-icon--error {
408
+ color: var(--color-error);
409
+ }
410
+
411
+ .cn-advanced-form-dialog__validation-icon--warning {
412
+ color: var(--color-warning);
413
+ }
414
+
415
+ .cn-advanced-form-dialog__validation-icon--lock {
416
+ color: var(--color-text-lighter);
417
+ }
418
+
419
+ .cn-advanced-form-dialog__validation-icon--new {
420
+ color: var(--color-primary-element);
421
+ }
422
+ </style>