@conduction/nextcloud-vue 2.165.0 → 2.166.0

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 (161) hide show
  1. package/dist/esm/components/CnActionButtons/CnActionButtons.vue.js +1 -1
  2. package/dist/esm/components/CnActionButtons/CnActionButtons.vue2.js +7 -0
  3. package/dist/esm/components/CnActionButtons/CnActionButtons.vue2.js.map +1 -1
  4. package/dist/esm/components/CnActionButtons/CnActionButtons.vue3.js.map +1 -1
  5. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue.js +1 -1
  6. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js +10 -0
  7. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue2.js.map +1 -1
  8. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue3.js +1 -1
  9. package/dist/esm/components/CnAuditTrailCard/CnAuditTrailCard.vue3.js.map +1 -1
  10. package/dist/esm/components/CnChipListManager/CnChipListManager.vue.js +1 -1
  11. package/dist/esm/components/CnChipListManager/CnChipListManager.vue2.js.map +1 -1
  12. package/dist/esm/components/CnChipListManager/CnChipListManager.vue3.js.map +1 -1
  13. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue.js +1 -1
  14. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue2.js +50 -7
  15. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue2.js.map +1 -1
  16. package/dist/esm/components/CnDashboardGrid/CnDashboardGrid.vue3.js.map +1 -1
  17. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js +13 -0
  18. package/dist/esm/components/CnDataTable/CnDataTable.vue2.js.map +1 -1
  19. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js +1 -0
  20. package/dist/esm/components/CnDataTable/CnDataTable.vue3.js.map +1 -1
  21. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js +39 -4
  22. package/dist/esm/components/CnDetailPage/CnDetailPage.vue2.js.map +1 -1
  23. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js +2 -1
  24. package/dist/esm/components/CnDetailPage/CnDetailPage.vue3.js.map +1 -1
  25. package/dist/esm/components/CnExpandableRow/CnExpandableRow.vue.js +1 -1
  26. package/dist/esm/components/CnExpandableRow/CnExpandableRow.vue2.js.map +1 -1
  27. package/dist/esm/components/CnExpandableRow/CnExpandableRow.vue3.js.map +1 -1
  28. package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue.js +9 -0
  29. package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue.js.map +1 -0
  30. package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue2.js +232 -0
  31. package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue2.js.map +1 -0
  32. package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue3.js +61 -0
  33. package/dist/esm/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue3.js.map +1 -0
  34. package/dist/esm/components/CnFieldGroupsWidget/index.js +28 -0
  35. package/dist/esm/components/CnFieldGroupsWidget/index.js.map +1 -0
  36. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue.js +1 -1
  37. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js +80 -6
  38. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js.map +1 -1
  39. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js +361 -289
  40. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js.map +1 -1
  41. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue.js +1 -1
  42. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js +9 -0
  43. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue2.js.map +1 -1
  44. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js +2 -1
  45. package/dist/esm/components/CnFlowDetail/CnFlowDetail.vue3.js.map +1 -1
  46. package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue.js +1 -1
  47. package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue2.js +21 -0
  48. package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue2.js.map +1 -1
  49. package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue3.js +12 -2
  50. package/dist/esm/components/CnFlowDetail/CnFlowRunSummary.vue3.js.map +1 -1
  51. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue.js +1 -1
  52. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js +17 -0
  53. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue2.js.map +1 -1
  54. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js +6 -3
  55. package/dist/esm/components/CnFlowsPage/CnFlowBoard.vue3.js.map +1 -1
  56. package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue2.js +33 -2
  57. package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue2.js.map +1 -1
  58. package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue3.js +2 -2
  59. package/dist/esm/components/CnGraphCanvas/CnGraphCanvas.vue3.js.map +1 -1
  60. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +83 -8
  61. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  62. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +2 -1
  63. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  64. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue.js +9 -0
  65. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue.js.map +1 -0
  66. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue2.js +187 -0
  67. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue2.js.map +1 -0
  68. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue3.js +106 -0
  69. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinkDialog.vue3.js.map +1 -0
  70. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue.js +9 -0
  71. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue.js.map +1 -0
  72. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue2.js +421 -0
  73. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue2.js.map +1 -0
  74. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue3.js +131 -0
  75. package/dist/esm/components/CnObjectLinksWidget/CnObjectLinksWidget.vue3.js.map +1 -0
  76. package/dist/esm/components/CnObjectLinksWidget/index.js +29 -0
  77. package/dist/esm/components/CnObjectLinksWidget/index.js.map +1 -0
  78. package/dist/esm/components/CnObjectLinksWidget/objectLinks.js +22 -0
  79. package/dist/esm/components/CnObjectLinksWidget/objectLinks.js.map +1 -0
  80. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue.js +1 -1
  81. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js +48 -13
  82. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js.map +1 -1
  83. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js +44 -20
  84. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js.map +1 -1
  85. package/dist/esm/components/CnPagination/CnPagination.vue2.js +26 -0
  86. package/dist/esm/components/CnPagination/CnPagination.vue2.js.map +1 -1
  87. package/dist/esm/components/CnPagination/CnPagination.vue3.js +40 -37
  88. package/dist/esm/components/CnPagination/CnPagination.vue3.js.map +1 -1
  89. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +2 -0
  90. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
  91. package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue.js +1 -1
  92. package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue2.js +4 -0
  93. package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue2.js.map +1 -1
  94. package/dist/esm/components/CnWidgetObjectTable/CnWidgetObjectTable.vue3.js.map +1 -1
  95. package/dist/esm/index.js +2 -0
  96. package/dist/esm/index.js.map +1 -1
  97. package/dist/esm/l10n/en.json.js +18 -1
  98. package/dist/esm/l10n/en.json.js.map +1 -1
  99. package/dist/esm/l10n/nl.json.js +18 -1
  100. package/dist/esm/l10n/nl.json.js.map +1 -1
  101. package/dist/esm/library-style.js +1 -1
  102. package/dist/esm/nextcloud-vue.css +635 -329
  103. package/dist/esm/utils/actionsDispatcher.js +9 -5
  104. package/dist/esm/utils/actionsDispatcher.js.map +1 -1
  105. package/dist/esm/utils/libraryWidgetKeys.js +2 -0
  106. package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
  107. package/dist/esm/utils/objectParties.js +68 -1
  108. package/dist/esm/utils/objectParties.js.map +1 -1
  109. package/dist/esm/utils/overlayInset.js +60 -0
  110. package/dist/esm/utils/overlayInset.js.map +1 -0
  111. package/dist/esm/utils/validateManifestV2.compiled.js +2 -2
  112. package/dist/esm/utils/validateManifestV2.compiled.js.map +1 -1
  113. package/dist/esm/utils/widgetDispatch.js +4 -1
  114. package/dist/esm/utils/widgetDispatch.js.map +1 -1
  115. package/dist/nextcloud-vue.cjs.js +8444 -6584
  116. package/dist/nextcloud-vue.cjs.js.map +2 -2
  117. package/dist/nextcloud-vue.css +635 -329
  118. package/l10n/en.json +18 -1
  119. package/l10n/nl.json +18 -1
  120. package/package.json +1 -1
  121. package/src/components/CnActionButtons/CnActionButtons.vue +7 -0
  122. package/src/components/CnAuditTrailCard/CnAuditTrailCard.vue +11 -1
  123. package/src/components/CnChipListManager/CnChipListManager.vue +4 -1
  124. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +50 -7
  125. package/src/components/CnDataTable/CnDataTable.md +1 -0
  126. package/src/components/CnDataTable/CnDataTable.vue +14 -0
  127. package/src/components/CnDetailPage/CnDetailPage.md +1 -0
  128. package/src/components/CnDetailPage/CnDetailPage.vue +40 -4
  129. package/src/components/CnExpandableRow/CnExpandableRow.vue +7 -4
  130. package/src/components/CnFieldGroupsWidget/CnFieldGroupsWidget.vue +287 -0
  131. package/src/components/CnFieldGroupsWidget/index.js +27 -0
  132. package/src/components/CnFieldListWidget/CnFieldListWidget.vue +162 -7
  133. package/src/components/CnFlowDetail/CnFlowDetail.vue +10 -0
  134. package/src/components/CnFlowDetail/CnFlowRunSummary.vue +26 -1
  135. package/src/components/CnFlowsPage/CnFlowBoard.vue +90 -4
  136. package/src/components/CnGraphCanvas/CnGraphCanvas.vue +35 -4
  137. package/src/components/CnIndexPage/CnIndexPage.md +1 -1
  138. package/src/components/CnIndexPage/CnIndexPage.vue +83 -7
  139. package/src/components/CnObjectLinksWidget/CnObjectLinkDialog.vue +267 -0
  140. package/src/components/CnObjectLinksWidget/CnObjectLinksWidget.vue +532 -0
  141. package/src/components/CnObjectLinksWidget/index.js +28 -0
  142. package/src/components/CnObjectLinksWidget/objectLinks.js +19 -0
  143. package/src/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue +65 -15
  144. package/src/components/CnPagination/CnPagination.md +1 -0
  145. package/src/components/CnPagination/CnPagination.vue +27 -1
  146. package/src/components/CnWidgetGrid/registerDashboardWidgets.js +2 -0
  147. package/src/components/CnWidgetObjectTable/CnWidgetObjectTable.vue +4 -0
  148. package/src/components/index.js +2 -0
  149. package/src/css/dialog.css +25 -3
  150. package/src/css/index-page.css +22 -8
  151. package/src/css/look-board-detail.css +41 -0
  152. package/src/css/look-board-index.css +52 -1
  153. package/src/css/look-board.css +17 -0
  154. package/src/index.js +2 -0
  155. package/src/schemas/app-manifest-v2.schema.json +3 -3
  156. package/src/utils/actionsDispatcher.js +9 -5
  157. package/src/utils/libraryWidgetKeys.js +2 -0
  158. package/src/utils/objectParties.js +67 -0
  159. package/src/utils/overlayInset.js +57 -0
  160. package/src/utils/validateManifestV2.compiled.js +2 -2
  161. package/src/utils/widgetDispatch.js +4 -1
@@ -0,0 +1,532 @@
1
+ <!--
2
+ - SPDX-FileCopyrightText: 2026 Conduction B.V.
3
+ - SPDX-License-Identifier: EUPL-1.2
4
+ -->
5
+
6
+ <template>
7
+ <div class="cn-object-links-widget" data-testid="cn-object-links-widget">
8
+ <p v-if="!loading && rows.length === 0" class="cn-object-links-widget__empty" data-testid="cn-object-links-empty">
9
+ {{ emptyLabel }}
10
+ </p>
11
+ <ul v-else class="cn-object-links-widget__rows">
12
+ <li
13
+ v-for="row in rows"
14
+ :key="row.id"
15
+ class="cn-object-links-widget__row"
16
+ :data-testid="`cn-object-links-row-${row.id}`">
17
+ <span class="cn-object-links-widget__text">
18
+ <span v-if="row.label" class="cn-object-links-widget__label">{{ `${row.label} ` }}</span>
19
+ <router-link v-if="row.route" :to="row.route" class="cn-object-links-widget__target">
20
+ {{ row.title }}
21
+ </router-link>
22
+ <span v-else class="cn-object-links-widget__target">{{ row.title }}</span>
23
+ </span>
24
+ <NcActions
25
+ v-if="canRemove"
26
+ :forceMenu="true"
27
+ :disabled="busy"
28
+ :ariaLabel="`${tr('More actions')}: ${row.title}`"
29
+ :data-testid="`cn-object-links-menu-${row.id}`">
30
+ <NcActionButton
31
+ :data-testid="`cn-object-links-remove-${row.id}`"
32
+ @click="removeLink(row)">
33
+ {{ removeLabel }}
34
+ </NcActionButton>
35
+ </NcActions>
36
+ </li>
37
+ </ul>
38
+
39
+ <p v-if="notice"
40
+ class="cn-object-links-widget__notice"
41
+ role="alert"
42
+ data-testid="cn-object-links-notice">
43
+ {{ notice }}
44
+ </p>
45
+
46
+ <div v-if="canAdd && !inTitle" class="cn-object-links-widget__footer">
47
+ <NcButton
48
+ variant="secondary"
49
+ :disabled="busy"
50
+ data-testid="cn-object-links-add"
51
+ @click="dialogOpen = true">
52
+ <template #icon>
53
+ <Plus :size="16" />
54
+ </template>
55
+ {{ addLabel }}
56
+ </NcButton>
57
+ </div>
58
+
59
+ <CnObjectLinkDialog
60
+ v-if="dialogOpen"
61
+ :content="content"
62
+ :objectId="recordId"
63
+ :save="createLink"
64
+ @close="dialogOpen = false" />
65
+ </div>
66
+ </template>
67
+
68
+ <script>
69
+ import { NcActionButton, NcActions, NcButton } from '@nextcloud/vue'
70
+ import Plus from 'vue-material-design-icons/Plus.vue'
71
+ import CnObjectLinkDialog from './CnObjectLinkDialog.vue'
72
+ import { prefixUrl } from '../../utils/headers.js'
73
+ import { readPath } from '../../utils/readPath.js'
74
+ import { serverErrorMessage } from '../../utils/serverErrorMessage.js'
75
+ import { objectsUrl } from './objectLinks.js'
76
+
77
+ /**
78
+ * CnObjectLinksWidget: the `object-links` widget: a record's links to other
79
+ * records, each kept as an object of a link schema that names this record
80
+ * (`from`) and the other one (`to`). Board PqKlant "Relaties": "Secretaris van
81
+ * Buurtvereniging Oost", "Partner van J. de Vries".
82
+ *
83
+ * A row reads the link's type as words (`types[].label`) and the other
84
+ * record's name, read from the schema its `toType` points at (`targets`), as a
85
+ * link to that record's page. Add opens a dialog (search the targets, pick a
86
+ * type, fill the extra `fields`) and writes the link; with `pair` it writes the
87
+ * inverse link from the other record too, and Remove deletes both. Every write
88
+ * goes to OpenRegister, which decides who may write; a refusal shows in the
89
+ * server's words.
90
+ *
91
+ * @spec openspec/changes/contact-side-cards-generic/specs/contact-side-cards-generic/spec.md#requirement-a-records-links-to-other-records-are-listed-added-and-removed
92
+ */
93
+ export default {
94
+ name: 'CnObjectLinksWidget',
95
+
96
+ components: { CnObjectLinkDialog, NcActionButton, NcActions, NcButton, Plus },
97
+
98
+ inject: {
99
+ cnTranslate: { default: () => (key) => key },
100
+ },
101
+
102
+ props: {
103
+ /**
104
+ * The widget configuration.
105
+ *
106
+ * - `register`, `schema` (required): where the link objects live.
107
+ * - `from`, `to` (required): the link fields naming this record and the other one.
108
+ * - `fromType`, `toType`, `selfType`: the fields that name each side's kind, and this record's kind.
109
+ * - `typeField`, `inverseField`, `groupField`: the fields the link's type, its inverse type and
110
+ * its group are written to.
111
+ * - `types`: `[{ value, label, inverse?, group?, groupLabel? }]`: the choices, and how a row words its type;
112
+ * `group` is written to `groupField`, `groupLabel` (else `group`) words it in the dialog.
113
+ * - `targets`: `[{ type, register, schema, titleField?, label?, route? }]`: the kinds of record a
114
+ * link may point at; a row reads the name from the target its `toType` names (else the first)
115
+ * and links to its `route` with `params.id`.
116
+ * - `pair`: write and remove the inverse link from the other record as well.
117
+ * - `fields`: `[{ key, label, type?: 'text'|'textarea'|'date' }]`: extra values the dialog asks.
118
+ * - `defaults`: values written on every new link.
119
+ * - `filter`: extra list filters; `limit` (default 100).
120
+ * - `add`: `{ label?, ariaLabel?, placement?: 'title'|'footer', dialogTitle? }`; `title` reports
121
+ * the add for the card's title row on the `header` event.
122
+ * - `remove`: `{ label? }`: a remove in each row's menu. Omitted: no remove.
123
+ * - `readOnly`, `emptyText`, `duplicateText`.
124
+ *
125
+ * @type {object}
126
+ */
127
+ content: {
128
+ type: Object,
129
+ default: () => ({}),
130
+ },
131
+
132
+ /** The current detail-page object. */
133
+ objectData: {
134
+ type: Object,
135
+ default: null,
136
+ },
137
+
138
+ /** The current object id. */
139
+ objectId: {
140
+ type: [String, Number],
141
+ default: '',
142
+ },
143
+ },
144
+
145
+ emits: ['header'],
146
+
147
+ data() {
148
+ return {
149
+ links: [],
150
+ /** Target names, by `<type>:<id>`. */
151
+ names: {},
152
+ loading: false,
153
+ busy: false,
154
+ notice: '',
155
+ dialogOpen: false,
156
+ }
157
+ },
158
+
159
+ computed: {
160
+ recordId() {
161
+ return String(this.objectId || this.objectData?.id || '')
162
+ },
163
+
164
+ /** Whether the configuration names a link list this record can read. */
165
+ configured() {
166
+ const c = this.content
167
+ return Boolean(c.register && c.schema && c.from && c.to && this.recordId)
168
+ },
169
+
170
+ readOnly() {
171
+ return this.content.readOnly === true
172
+ },
173
+
174
+ canAdd() {
175
+ return this.configured && !this.readOnly
176
+ },
177
+
178
+ canRemove() {
179
+ return this.configured && !this.readOnly && Boolean(this.content.remove)
180
+ },
181
+
182
+ inTitle() {
183
+ return this.content.add?.placement === 'title'
184
+ },
185
+
186
+ addLabel() {
187
+ return this.tr(this.content.add?.label || 'Add')
188
+ },
189
+
190
+ removeLabel() {
191
+ return this.tr(this.content.remove?.label || 'Remove')
192
+ },
193
+
194
+ emptyLabel() {
195
+ return this.tr(this.content.emptyText || 'Nothing linked yet')
196
+ },
197
+
198
+ types() {
199
+ return Array.isArray(this.content.types) ? this.content.types.filter((type) => type && type.value !== undefined) : []
200
+ },
201
+
202
+ targets() {
203
+ return Array.isArray(this.content.targets) ? this.content.targets.filter((target) => target && target.register && target.schema) : []
204
+ },
205
+
206
+ /**
207
+ * The rows: the type in words and the other record's name.
208
+ *
209
+ * @return {Array<{id: string, link: object, label: string, title: string, targetId: string, route: object|null}>}
210
+ */
211
+ rows() {
212
+ const c = this.content
213
+ return this.links.map((link) => {
214
+ const targetId = String(readPath(link, c.to) ?? '')
215
+ const target = this.targetOf(link)
216
+ const type = c.typeField ? readPath(link, c.typeField) : undefined
217
+ return {
218
+ id: String(link.id ?? link.uuid ?? targetId),
219
+ link,
220
+ label: this.typeLabel(type),
221
+ title: this.names[this.nameKey(target, targetId)] || targetId,
222
+ targetId,
223
+ route: target && target.route && targetId ? { name: target.route, params: { id: targetId } } : null,
224
+ }
225
+ })
226
+ },
227
+
228
+ /**
229
+ * The card title row's add.
230
+ *
231
+ * @return {{actions: Array<object>}}
232
+ */
233
+ header() {
234
+ if (!this.canAdd || !this.inTitle) {
235
+ return { actions: [] }
236
+ }
237
+ return {
238
+ actions: [{
239
+ label: this.addLabel,
240
+ ariaLabel: this.tr(this.content.add?.ariaLabel || '') || this.addLabel,
241
+ icon: 'Plus',
242
+ variant: 'secondary',
243
+ run: () => {
244
+ this.dialogOpen = true
245
+ },
246
+ }],
247
+ }
248
+ },
249
+ },
250
+
251
+ watch: {
252
+ header: {
253
+ immediate: true,
254
+ handler(header) {
255
+ /**
256
+ * @event header The card's title-row actions, `{ actions }`, for the host to draw.
257
+ */
258
+ this.$emit('header', header)
259
+ },
260
+ },
261
+
262
+ recordId: {
263
+ immediate: true,
264
+ handler() {
265
+ this.load()
266
+ },
267
+ },
268
+ },
269
+
270
+ methods: {
271
+ tr(text) {
272
+ if (typeof text !== 'string' || text === '') {
273
+ return ''
274
+ }
275
+ return typeof this.cnTranslate === 'function' ? this.cnTranslate(text) : text
276
+ },
277
+
278
+ async http() {
279
+ const { default: axios } = await import('@nextcloud/axios')
280
+ return axios
281
+ },
282
+
283
+ /**
284
+ * The target a link points at: the one its `toType` names, else the first.
285
+ *
286
+ * @param {object} link The link object.
287
+ * @return {object|null}
288
+ */
289
+ targetOf(link) {
290
+ const kind = this.content.toType ? readPath(link, this.content.toType) : undefined
291
+ return this.targets.find((target) => target.type === kind) || this.targets[0] || null
292
+ },
293
+
294
+ nameKey(target, id) {
295
+ return `${target ? target.type : ''}:${id}`
296
+ },
297
+
298
+ /**
299
+ * A link type in words: its `types[].label`, translated, else the stored value.
300
+ *
301
+ * @param {unknown} value The stored type.
302
+ * @return {string}
303
+ */
304
+ typeLabel(value) {
305
+ if (value === undefined || value === null || value === '') {
306
+ return ''
307
+ }
308
+ const type = this.types.find((candidate) => String(candidate.value) === String(value))
309
+ return type && type.label ? this.tr(type.label) : String(value)
310
+ },
311
+
312
+ /**
313
+ * Read this record's links, then the name of every record they point at.
314
+ *
315
+ * @return {Promise<void>}
316
+ * @spec openspec/changes/contact-side-cards-generic/specs/contact-side-cards-generic/spec.md#requirement-a-records-links-to-other-records-are-listed-added-and-removed
317
+ */
318
+ async load() {
319
+ if (!this.configured) {
320
+ this.links = []
321
+ return
322
+ }
323
+ const c = this.content
324
+ this.loading = true
325
+ try {
326
+ const axios = await this.http()
327
+ const { data } = await axios.get(prefixUrl(objectsUrl(c.register, c.schema)), {
328
+ params: { ...(c.filter || {}), [c.from]: this.recordId, _limit: c.limit || 100 },
329
+ })
330
+ this.links = Array.isArray(data?.results) ? data.results : (Array.isArray(data) ? data : [])
331
+ await this.loadNames(axios)
332
+ } catch (e) {
333
+ this.links = []
334
+ this.notice = serverErrorMessage(e)
335
+ } finally {
336
+ this.loading = false
337
+ }
338
+ },
339
+
340
+ /**
341
+ * Read the name of each linked record once.
342
+ *
343
+ * @param {object} axios The HTTP client.
344
+ * @return {Promise<void>}
345
+ */
346
+ async loadNames(axios) {
347
+ const wanted = new Map()
348
+ for (const link of this.links) {
349
+ const target = this.targetOf(link)
350
+ const id = String(readPath(link, this.content.to) ?? '')
351
+ const key = this.nameKey(target, id)
352
+ if (target && id && !(key in this.names)) {
353
+ wanted.set(key, { target, id })
354
+ }
355
+ }
356
+ const names = { ...this.names }
357
+ await Promise.all([...wanted.entries()].map(async ([key, { target, id }]) => {
358
+ try {
359
+ const { data } = await axios.get(prefixUrl(objectsUrl(target.register, target.schema, id)))
360
+ const title = readPath(data || {}, target.titleField || 'name')
361
+ names[key] = title ? String(title) : id
362
+ } catch {
363
+ names[key] = id
364
+ }
365
+ }))
366
+ this.names = names
367
+ },
368
+
369
+ /**
370
+ * The fields a link object is written with, from one side to the other.
371
+ *
372
+ * @param {object} side `{ fromId, fromKind, toId, toKind, type, inverse, group, values }`.
373
+ * @return {object}
374
+ */
375
+ linkBody(side) {
376
+ const c = this.content
377
+ const body = { ...(c.defaults || {}), ...(side.values || {}), [c.from]: side.fromId, [c.to]: side.toId }
378
+ const put = (field, value) => {
379
+ if (field && value !== undefined && value !== null && value !== '') {
380
+ body[field] = value
381
+ }
382
+ }
383
+ put(c.fromType, side.fromKind)
384
+ put(c.toType, side.toKind)
385
+ put(c.typeField, side.type)
386
+ put(c.inverseField, side.inverse)
387
+ put(c.groupField, side.group)
388
+ return body
389
+ },
390
+
391
+ /**
392
+ * Write a new link (and with `pair` its inverse), then read the list again.
393
+ *
394
+ * @param {{target: {id: string, type?: string}, type: string, values?: object}} pick What the dialog chose.
395
+ * @return {Promise<{ok: boolean, message?: string}>}
396
+ * @spec openspec/changes/contact-side-cards-generic/specs/contact-side-cards-generic/spec.md#requirement-a-records-links-to-other-records-are-listed-added-and-removed
397
+ */
398
+ async createLink(pick) {
399
+ const c = this.content
400
+ if (!this.canAdd || !pick || !pick.target || !pick.target.id) {
401
+ return { ok: false, message: this.tr('This link cannot be saved here.') }
402
+ }
403
+ const exists = this.links.some((link) => String(readPath(link, c.to)) === String(pick.target.id)
404
+ && (!c.typeField || String(readPath(link, c.typeField)) === String(pick.type)))
405
+ if (exists) {
406
+ return { ok: false, message: this.tr(c.duplicateText || 'This link already exists.') }
407
+ }
408
+ const type = this.types.find((candidate) => String(candidate.value) === String(pick.type))
409
+ const inverse = type && type.inverse !== undefined ? type.inverse : pick.type
410
+ const group = type ? type.group : undefined
411
+ this.busy = true
412
+ try {
413
+ const axios = await this.http()
414
+ const url = prefixUrl(objectsUrl(c.register, c.schema))
415
+ await axios.post(url, this.linkBody({
416
+ fromId: this.recordId,
417
+ fromKind: c.selfType,
418
+ toId: pick.target.id,
419
+ toKind: pick.target.type,
420
+ type: pick.type,
421
+ inverse,
422
+ group,
423
+ values: pick.values,
424
+ }))
425
+ if (c.pair) {
426
+ await axios.post(url, this.linkBody({
427
+ fromId: pick.target.id,
428
+ fromKind: pick.target.type,
429
+ toId: this.recordId,
430
+ toKind: c.selfType,
431
+ type: inverse,
432
+ inverse: pick.type,
433
+ group,
434
+ values: pick.values,
435
+ }))
436
+ }
437
+ await this.load()
438
+ return { ok: true }
439
+ } catch (e) {
440
+ return { ok: false, message: serverErrorMessage(e) }
441
+ } finally {
442
+ this.busy = false
443
+ }
444
+ },
445
+
446
+ /**
447
+ * Delete a link (and with `pair` the inverse from the other record), then read the list again.
448
+ *
449
+ * @param {object} row The row.
450
+ * @return {Promise<void>}
451
+ * @spec openspec/changes/contact-side-cards-generic/specs/contact-side-cards-generic/spec.md#requirement-a-records-links-to-other-records-are-listed-added-and-removed
452
+ */
453
+ async removeLink(row) {
454
+ const c = this.content
455
+ if (!this.canRemove || !row) {
456
+ return
457
+ }
458
+ this.busy = true
459
+ this.notice = ''
460
+ try {
461
+ const axios = await this.http()
462
+ await axios.delete(prefixUrl(objectsUrl(c.register, c.schema, row.id)))
463
+ if (c.pair && row.targetId) {
464
+ const type = c.typeField ? readPath(row.link, c.typeField) : undefined
465
+ const inverse = c.inverseField ? readPath(row.link, c.inverseField) : undefined
466
+ const known = this.types.find((candidate) => String(candidate.value) === String(type))
467
+ const inverseType = inverse ?? (known && known.inverse !== undefined ? known.inverse : undefined)
468
+ const { data } = await axios.get(prefixUrl(objectsUrl(c.register, c.schema)), {
469
+ params: { [c.from]: row.targetId, [c.to]: this.recordId, _limit: 10 },
470
+ })
471
+ const back = (Array.isArray(data?.results) ? data.results : [])
472
+ .filter((link) => inverseType === undefined || !c.typeField || String(readPath(link, c.typeField)) === String(inverseType))
473
+ for (const link of back) {
474
+ await axios.delete(prefixUrl(objectsUrl(c.register, c.schema, link.id ?? link.uuid)))
475
+ }
476
+ }
477
+ } catch (e) {
478
+ this.notice = serverErrorMessage(e)
479
+ return
480
+ } finally {
481
+ this.busy = false
482
+ }
483
+ await this.load()
484
+ },
485
+ },
486
+ }
487
+ </script>
488
+
489
+ <style scoped>
490
+ .cn-object-links-widget {
491
+ display: flex;
492
+ flex-direction: column;
493
+ gap: 10px;
494
+ font-size: 14px;
495
+ }
496
+
497
+ .cn-object-links-widget__rows {
498
+ display: flex;
499
+ flex-direction: column;
500
+ gap: 10px;
501
+ margin: 0;
502
+ padding: 0;
503
+ list-style: none;
504
+ }
505
+
506
+ .cn-object-links-widget__row {
507
+ display: flex;
508
+ align-items: center;
509
+ justify-content: space-between;
510
+ gap: 8px;
511
+ min-height: 20px;
512
+ }
513
+
514
+ .cn-object-links-widget__text {
515
+ min-width: 0;
516
+ overflow-wrap: anywhere;
517
+ }
518
+
519
+ .cn-object-links-widget__empty {
520
+ margin: 0;
521
+ color: var(--color-text-maxcontrast);
522
+ }
523
+
524
+ .cn-object-links-widget__notice {
525
+ margin: 0;
526
+ color: var(--color-error-text, var(--color-error));
527
+ }
528
+
529
+ .cn-object-links-widget__footer {
530
+ display: flex;
531
+ }
532
+ </style>
@@ -0,0 +1,28 @@
1
+ /**
2
+ * SPDX-FileCopyrightText: 2026 Conduction B.V.
3
+ * SPDX-License-Identifier: EUPL-1.2
4
+ *
5
+ * CnObjectLinksWidget: self-registers the `object-links` widget type (a
6
+ * record's links to other records, kept as objects of a link schema, listed,
7
+ * added and removed) into the shared dashboardWidgetRegistry at module load.
8
+ * Renderer only: declared in the manifest.
9
+ */
10
+
11
+ import CnObjectLinksWidget from './CnObjectLinksWidget.vue'
12
+ import { registerDashboardWidget } from '../CnWidgetGrid/dashboardWidgetRegistry.js'
13
+
14
+ registerDashboardWidget('object-links', {
15
+ renderer: CnObjectLinksWidget,
16
+ form: null,
17
+ defaultContent: {
18
+ types: [],
19
+ targets: [],
20
+ readOnly: false,
21
+ },
22
+ displayName: 'Object links',
23
+ icon: 'AccountMultipleOutline',
24
+ surfaces: ['detail-page'],
25
+ })
26
+
27
+ export { CnObjectLinksWidget }
28
+ export default CnObjectLinksWidget
@@ -0,0 +1,19 @@
1
+ /**
2
+ * SPDX-FileCopyrightText: 2026 Conduction B.V.
3
+ * SPDX-License-Identifier: EUPL-1.2
4
+ *
5
+ * The OpenRegister object URLs the object-links widget and its dialog use.
6
+ */
7
+
8
+ /**
9
+ * The objects URL of a register and schema, or of one object in it.
10
+ *
11
+ * @param {string} register The register slug.
12
+ * @param {string} schema The schema slug.
13
+ * @param {string} [id] One object's id.
14
+ * @return {string} The app-absolute URL.
15
+ */
16
+ export function objectsUrl(register, schema, id) {
17
+ const base = `/apps/openregister/api/objects/${encodeURIComponent(String(register))}/${encodeURIComponent(String(schema))}`
18
+ return id === undefined || id === null || id === '' ? base : `${base}/${encodeURIComponent(String(id))}`
19
+ }