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

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 (197) hide show
  1. package/README.md +226 -0
  2. package/css/index.css +5 -0
  3. package/dist/nextcloud-vue.cjs +67614 -0
  4. package/dist/nextcloud-vue.cjs.js +76311 -5905
  5. package/dist/nextcloud-vue.cjs.js.map +1 -1
  6. package/dist/nextcloud-vue.cjs.map +1 -0
  7. package/dist/nextcloud-vue.css +3279 -203
  8. package/dist/nextcloud-vue.esm.js +76240 -5882
  9. package/dist/nextcloud-vue.esm.js.map +1 -1
  10. package/package.json +89 -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 +569 -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 +23 -20
  22. package/src/components/CnCardGrid/index.js +1 -1
  23. package/src/components/CnCellRenderer/index.js +1 -1
  24. package/src/components/CnChartWidget/CnChartWidget.vue +318 -0
  25. package/src/components/CnChartWidget/index.js +1 -0
  26. package/src/components/CnConfigurationCard/index.js +1 -1
  27. package/src/components/CnContextMenu/CnContextMenu.vue +142 -0
  28. package/src/components/CnContextMenu/index.js +1 -0
  29. package/src/components/CnCopyDialog/CnCopyDialog.vue +257 -0
  30. package/src/components/CnCopyDialog/index.js +1 -0
  31. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +229 -0
  32. package/src/components/CnDashboardGrid/index.js +1 -0
  33. package/src/components/CnDashboardPage/CnDashboardPage.vue +396 -0
  34. package/src/components/CnDashboardPage/index.js +1 -0
  35. package/src/components/CnDataTable/CnDataTable.vue +24 -16
  36. package/src/components/CnDataTable/index.js +1 -1
  37. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +177 -0
  38. package/src/components/CnDeleteDialog/index.js +1 -0
  39. package/src/components/CnDetailCard/CnDetailCard.vue +225 -0
  40. package/src/components/CnDetailCard/index.js +1 -0
  41. package/src/components/CnDetailGrid/CnDetailGrid.vue +254 -0
  42. package/src/components/CnDetailGrid/index.js +1 -0
  43. package/src/components/CnDetailPage/CnDetailPage.vue +431 -0
  44. package/src/components/CnDetailPage/index.js +1 -0
  45. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +12 -2
  46. package/src/components/CnFacetSidebar/index.js +1 -1
  47. package/src/components/CnFilterBar/index.js +1 -1
  48. package/src/components/CnFormDialog/CnFormDialog.vue +934 -0
  49. package/src/components/CnFormDialog/index.js +1 -0
  50. package/src/components/CnIcon/CnIcon.vue +89 -0
  51. package/src/components/CnIcon/index.js +1 -0
  52. package/src/components/CnIndexPage/CnIndexPage.vue +589 -291
  53. package/src/components/CnIndexPage/index.js +1 -1
  54. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +535 -0
  55. package/src/components/CnIndexSidebar/index.js +1 -0
  56. package/src/components/CnInfoWidget/CnInfoWidget.vue +219 -0
  57. package/src/components/CnInfoWidget/index.js +1 -0
  58. package/src/components/CnItemCard/CnItemCard.vue +134 -0
  59. package/src/components/CnItemCard/index.js +1 -0
  60. package/src/components/CnJsonViewer/CnJsonViewer.vue +283 -0
  61. package/src/components/CnJsonViewer/index.js +1 -0
  62. package/src/components/CnKpiGrid/CnKpiGrid.vue +5 -1
  63. package/src/components/CnKpiGrid/index.js +1 -1
  64. package/src/components/CnMassActionBar/CnMassActionBar.vue +6 -5
  65. package/src/components/CnMassActionBar/index.js +1 -1
  66. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +16 -9
  67. package/src/components/CnMassCopyDialog/index.js +1 -1
  68. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +16 -9
  69. package/src/components/CnMassDeleteDialog/index.js +1 -1
  70. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +8 -7
  71. package/src/components/CnMassExportDialog/index.js +1 -1
  72. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +20 -17
  73. package/src/components/CnMassImportDialog/index.js +1 -1
  74. package/src/components/CnNoteCard/CnNoteCard.vue +149 -0
  75. package/src/components/CnNoteCard/index.js +1 -0
  76. package/src/components/CnNotesCard/CnNotesCard.vue +415 -0
  77. package/src/components/CnNotesCard/index.js +1 -0
  78. package/src/components/CnObjectCard/CnObjectCard.vue +3 -1
  79. package/src/components/CnObjectCard/index.js +1 -1
  80. package/src/components/CnObjectDataWidget/CnObjectDataWidget.vue +853 -0
  81. package/src/components/CnObjectDataWidget/index.js +1 -0
  82. package/src/components/CnObjectMetadataWidget/CnObjectMetadataWidget.vue +288 -0
  83. package/src/components/CnObjectMetadataWidget/index.js +1 -0
  84. package/src/components/CnObjectSidebar/CnAuditTrailTab.vue +368 -0
  85. package/src/components/CnObjectSidebar/CnFilesTab.vue +286 -0
  86. package/src/components/CnObjectSidebar/CnNotesTab.vue +249 -0
  87. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +254 -0
  88. package/src/components/CnObjectSidebar/CnTagsTab.vue +258 -0
  89. package/src/components/CnObjectSidebar/CnTasksTab.vue +482 -0
  90. package/src/components/CnObjectSidebar/index.js +6 -0
  91. package/src/components/CnPageHeader/CnPageHeader.vue +61 -0
  92. package/src/components/CnPageHeader/index.js +1 -0
  93. package/src/components/CnPagination/CnPagination.vue +7 -6
  94. package/src/components/CnPagination/index.js +1 -1
  95. package/src/components/CnProgressBar/CnProgressBar.vue +262 -0
  96. package/src/components/CnProgressBar/index.js +1 -0
  97. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +792 -0
  98. package/src/components/CnRegisterMapping/index.js +1 -0
  99. package/src/components/CnRowActions/CnRowActions.vue +25 -3
  100. package/src/components/CnRowActions/index.js +1 -1
  101. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -0
  102. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -0
  103. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -0
  104. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -0
  105. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -0
  106. package/src/components/CnSchemaFormDialog/index.js +1 -0
  107. package/src/components/CnSettingsCard/index.js +1 -1
  108. package/src/components/CnSettingsSection/index.js +1 -1
  109. package/src/components/CnStatsBlock/CnStatsBlock.vue +89 -19
  110. package/src/components/CnStatsBlock/index.js +1 -1
  111. package/src/components/CnStatsPanel/CnStatsPanel.vue +320 -0
  112. package/src/components/CnStatsPanel/index.js +1 -0
  113. package/src/components/CnStatusBadge/CnStatusBadge.vue +15 -2
  114. package/src/components/CnStatusBadge/index.js +1 -1
  115. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +544 -0
  116. package/src/components/CnTabbedFormDialog/index.js +1 -0
  117. package/src/components/CnTableWidget/CnTableWidget.vue +332 -0
  118. package/src/components/CnTableWidget/index.js +1 -0
  119. package/src/components/CnTasksCard/CnTasksCard.vue +373 -0
  120. package/src/components/CnTasksCard/index.js +1 -0
  121. package/src/components/CnTileWidget/CnTileWidget.vue +159 -0
  122. package/src/components/CnTileWidget/index.js +1 -0
  123. package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -0
  124. package/src/components/CnTimelineStages/index.js +1 -0
  125. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -0
  126. package/src/components/CnUserActionMenu/index.js +1 -0
  127. package/src/components/CnVersionInfoCard/index.js +1 -1
  128. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -0
  129. package/src/components/CnWidgetRenderer/index.js +1 -0
  130. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +246 -0
  131. package/src/components/CnWidgetWrapper/index.js +1 -0
  132. package/src/components/index.js +57 -25
  133. package/src/composables/index.js +5 -3
  134. package/src/composables/useContextMenu.js +126 -0
  135. package/src/composables/useDashboardView.js +286 -0
  136. package/src/composables/useDetailView.js +290 -132
  137. package/src/composables/useListView.js +364 -153
  138. package/src/composables/useSubResource.js +142 -142
  139. package/src/constants/metadata.js +30 -0
  140. package/src/css/CnSchemaFormDialog.css +546 -0
  141. package/src/css/__sample_nextcloud_tokens.css +110 -0
  142. package/src/css/actions-bar.css +54 -0
  143. package/src/css/badge.css +83 -51
  144. package/src/css/card.css +129 -128
  145. package/src/css/context-menu.css +20 -0
  146. package/src/css/dashboard.css +70 -0
  147. package/src/css/detail-page.css +235 -0
  148. package/src/css/detail.css +68 -68
  149. package/src/css/index-page.css +44 -0
  150. package/src/css/index-sidebar.css +193 -0
  151. package/src/css/index.css +17 -8
  152. package/src/css/layout.css +90 -90
  153. package/src/css/page-header.css +35 -0
  154. package/src/css/pagination.css +72 -72
  155. package/src/css/table.css +142 -143
  156. package/src/css/timeline-stages.css +220 -0
  157. package/src/css/utilities.css +46 -46
  158. package/src/index.js +91 -50
  159. package/src/mixins/gridLayout.js +118 -0
  160. package/src/store/createCrudStore.js +360 -0
  161. package/src/store/createSubResourcePlugin.js +125 -135
  162. package/src/store/index.js +4 -3
  163. package/src/store/plugins/auditTrails.js +357 -17
  164. package/src/store/plugins/files.js +250 -186
  165. package/src/store/plugins/index.js +7 -4
  166. package/src/store/plugins/lifecycle.js +180 -180
  167. package/src/store/plugins/registerMapping.js +195 -0
  168. package/src/store/plugins/relations.js +68 -68
  169. package/src/store/plugins/search.js +385 -0
  170. package/src/store/plugins/selection.js +104 -0
  171. package/src/store/useObjectStore.js +823 -625
  172. package/src/types/auditTrail.d.ts +32 -32
  173. package/src/types/file.d.ts +23 -23
  174. package/src/types/index.d.ts +35 -35
  175. package/src/types/notification.d.ts +36 -36
  176. package/src/types/object.d.ts +40 -40
  177. package/src/types/organisation.d.ts +41 -41
  178. package/src/types/register.d.ts +25 -25
  179. package/src/types/schema.d.ts +39 -39
  180. package/src/types/shared.d.ts +79 -79
  181. package/src/types/source.d.ts +14 -14
  182. package/src/types/task.d.ts +31 -31
  183. package/src/utils/errors.js +96 -96
  184. package/src/utils/getTheme.js +9 -0
  185. package/src/utils/headers.js +80 -44
  186. package/src/utils/id.js +13 -0
  187. package/src/utils/index.js +4 -3
  188. package/src/utils/schema.js +422 -287
  189. package/src/utils/widgetVisibility.js +162 -0
  190. package/src/components/CnDetailViewLayout/CnDetailViewLayout.vue +0 -88
  191. package/src/components/CnDetailViewLayout/index.js +0 -1
  192. package/src/components/CnEmptyState/CnEmptyState.vue +0 -78
  193. package/src/components/CnEmptyState/index.js +0 -1
  194. package/src/components/CnListViewLayout/CnListViewLayout.vue +0 -80
  195. package/src/components/CnListViewLayout/index.js +0 -1
  196. package/src/components/CnViewModeToggle/CnViewModeToggle.vue +0 -77
  197. package/src/components/CnViewModeToggle/index.js +0 -1
@@ -0,0 +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
+ Property
8
+ </th>
9
+ <th class="cn-advanced-form-dialog__table-col-expanded">
10
+ 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>
@@ -0,0 +1,247 @@
1
+ <template>
2
+ <!-- Edit mode -->
3
+ <div
4
+ v-if="isEditable && (inputComponent === 'NcCheckboxRadioSwitch' || isEditing)"
5
+ class="cn-advanced-form-dialog__value-input-container"
6
+ @click.stop>
7
+ <div
8
+ v-if="inputComponent === 'NcCheckboxRadioSwitch'"
9
+ class="cn-advanced-form-dialog__boolean-input-row">
10
+ <NcCheckboxRadioSwitch
11
+ :checked="value"
12
+ type="switch"
13
+ class="cn-advanced-form-dialog__boolean-input-row__input"
14
+ @update:checked="emit($event)">
15
+ {{ displayName }}
16
+ </NcCheckboxRadioSwitch>
17
+ <InformationOutline
18
+ v-if="schemaProp && schemaProp.description"
19
+ v-tooltip="schemaProp.description"
20
+ class="cn-advanced-form-dialog__info-icon"
21
+ :size="16" />
22
+ </div>
23
+ <NcDateTimePickerNative
24
+ v-else-if="inputComponent === 'NcDateTimePickerNative'"
25
+ :value="value"
26
+ :type="inputType"
27
+ :label="displayName"
28
+ @update:value="emit($event)" />
29
+ <NcTextField
30
+ v-else
31
+ ref="inputRef"
32
+ :value="stringValue"
33
+ :type="inputType"
34
+ :placeholder="displayName"
35
+ :min="minimum"
36
+ :max="maximum"
37
+ :step="step"
38
+ @update:value="emitConverted($event)" />
39
+ </div>
40
+
41
+ <!-- Display mode -->
42
+ <div
43
+ v-else
44
+ :title="editabilityWarning">
45
+ <pre
46
+ v-if="typeof value === 'object' && value !== null"
47
+ class="cn-advanced-form-dialog__json-value">{{ formattedObjectValue }}</pre>
48
+ <span
49
+ v-else-if="inputComponent === 'NcDateTimePickerNative' && isValidDate(value)">{{
50
+ new Date(value).toLocaleString()
51
+ }}</span>
52
+ <span v-else>{{ displayValue }}</span>
53
+ </div>
54
+ </template>
55
+
56
+ <script>
57
+ import {
58
+ NcTextField,
59
+ NcCheckboxRadioSwitch,
60
+ NcDateTimePickerNative,
61
+ } from '@nextcloud/vue'
62
+ import InformationOutline from 'vue-material-design-icons/InformationOutline.vue'
63
+ import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip.js'
64
+ import { formatValue } from '../../utils/schema.js'
65
+
66
+ export default {
67
+ name: 'CnPropertyValueCell',
68
+
69
+ directives: { tooltip: Tooltip },
70
+
71
+ components: {
72
+ NcTextField,
73
+ NcCheckboxRadioSwitch,
74
+ NcDateTimePickerNative,
75
+ InformationOutline,
76
+ },
77
+
78
+ props: {
79
+ /** The schema property key */
80
+ propertyKey: { type: String, required: true },
81
+ /** Full JSON schema object */
82
+ schema: { type: Object, default: null },
83
+ /** Resolved current value (formData[key] ?? objectValue) */
84
+ value: { type: [String, Number, Boolean, Object, Array], default: null },
85
+ /** Whether this property is editable at all */
86
+ isEditable: { type: Boolean, default: true },
87
+ /** Whether this row is currently selected for editing */
88
+ isEditing: { type: Boolean, default: false },
89
+ /** Display name for the property (used in labels/placeholders) */
90
+ displayName: { type: String, default: '' },
91
+ /** Editability warning message shown as title when not editable */
92
+ editabilityWarning: { type: String, default: null },
93
+ },
94
+
95
+ computed: {
96
+ schemaProp() {
97
+ return this.schema?.properties?.[this.propertyKey] || null
98
+ },
99
+
100
+ inputComponent() {
101
+ const prop = this.schemaProp
102
+ if (!prop) return 'NcTextField'
103
+ if (prop.type === 'boolean') return 'NcCheckboxRadioSwitch'
104
+ if (prop.type === 'string' && ['date', 'time', 'date-time'].includes(prop.format)) {
105
+ return 'NcDateTimePickerNative'
106
+ }
107
+ return 'NcTextField'
108
+ },
109
+
110
+ inputType() {
111
+ const prop = this.schemaProp
112
+ if (!prop) return 'text'
113
+ const fmt = prop.format || ''
114
+ if (prop.type === 'string') {
115
+ if (fmt === 'date') return 'date'
116
+ if (fmt === 'time') return 'time'
117
+ if (fmt === 'date-time') return 'datetime-local'
118
+ if (fmt === 'email') return 'email'
119
+ if (fmt === 'url' || fmt === 'uri') return 'url'
120
+ }
121
+ if (prop.type === 'number' || prop.type === 'integer') return 'number'
122
+ return 'text'
123
+ },
124
+
125
+ minimum() {
126
+ return this.schemaProp?.minimum
127
+ },
128
+
129
+ maximum() {
130
+ return this.schemaProp?.maximum
131
+ },
132
+
133
+ step() {
134
+ const prop = this.schemaProp
135
+ if (prop?.type === 'integer') return '1'
136
+ if (prop?.type === 'number') return 'any'
137
+ return undefined
138
+ },
139
+
140
+ stringValue() {
141
+ const v = this.value
142
+ if (v == null) return ''
143
+ if (typeof v === 'string') return v
144
+ if (typeof v === 'object') return JSON.stringify(v)
145
+ return String(v)
146
+ },
147
+
148
+ formattedObjectValue() {
149
+ return formatValue(this.value, this.schemaProp || {})
150
+ },
151
+
152
+ displayValue() {
153
+ const prop = this.schemaProp
154
+ if (prop?.const !== undefined) return prop.const
155
+ const v = this.value
156
+ if (v === null || v === undefined || v === '') return '—'
157
+ return formatValue(v, prop || {})
158
+ },
159
+ },
160
+
161
+ methods: {
162
+ /** Focus the underlying text input (called by parent after row click) */
163
+ focus() {
164
+ const ref = this.$refs.inputRef
165
+ if (!ref) return
166
+ const input = ref.$el?.querySelector('input')
167
+ if (input) {
168
+ input.focus()
169
+ input.select()
170
+ }
171
+ },
172
+
173
+ emit(newVal) {
174
+ this.$emit('update:value', newVal)
175
+ },
176
+
177
+ emitConverted(newVal) {
178
+ const prop = this.schemaProp
179
+ let converted = newVal
180
+ if (prop) {
181
+ switch (prop.type) {
182
+ case 'number':
183
+ converted = newVal === '' ? null : parseFloat(newVal)
184
+ if (Number.isNaN(converted)) converted = null
185
+ break
186
+ case 'integer':
187
+ converted = newVal === '' ? null : parseInt(newVal, 10)
188
+ if (Number.isNaN(converted)) converted = null
189
+ break
190
+ case 'boolean':
191
+ converted = Boolean(newVal)
192
+ break
193
+ default:
194
+ converted = newVal
195
+ }
196
+ }
197
+ this.$emit('update:value', converted)
198
+ },
199
+
200
+ isValidDate(v) {
201
+ if (!v) return false
202
+ const d = new Date(v)
203
+ return d instanceof Date && !Number.isNaN(d.getTime())
204
+ },
205
+ },
206
+ }
207
+ </script>
208
+
209
+ <style scoped>
210
+ .cn-advanced-form-dialog__value-input-container :deep(.text-field) {
211
+ margin: 0;
212
+ padding: 0;
213
+ }
214
+
215
+ .cn-advanced-form-dialog__boolean-input-row {
216
+ display: flex;
217
+ align-items: center;
218
+ gap: 6px;
219
+ }
220
+
221
+ /* patch extreme size in field */
222
+ .cn-advanced-form-dialog__boolean-input-row__input > span {
223
+ padding-left: 0;
224
+ padding-block: 0;
225
+ }
226
+ .cn-advanced-form-dialog__boolean-input-row__input > input {
227
+ margin: 0;
228
+ }
229
+
230
+ .cn-advanced-form-dialog__info-icon {
231
+ flex-shrink: 0;
232
+ color: var(--color-text-maxcontrast);
233
+ cursor: help;
234
+ }
235
+
236
+ .cn-advanced-form-dialog__json-value {
237
+ max-height: 200px;
238
+ overflow-y: auto;
239
+ white-space: pre-wrap;
240
+ font-family: monospace;
241
+ font-size: 12px;
242
+ background: var(--color-background-dark);
243
+ padding: 8px;
244
+ border-radius: 4px;
245
+ margin: 0;
246
+ }
247
+ </style>
@@ -0,0 +1 @@
1
+ export { default as CnAdvancedFormDialog } from './CnAdvancedFormDialog.vue'