@conduction/nextcloud-vue 2.133.0 → 2.134.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 (39) hide show
  1. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue.js +1 -1
  2. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js +85 -10
  3. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue2.js.map +1 -1
  4. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js +60 -36
  5. package/dist/esm/components/CnFieldListWidget/CnFieldListWidget.vue3.js.map +1 -1
  6. package/dist/esm/components/CnIntegrationWidget/CnIntegrationWidget.vue.js +1 -1
  7. package/dist/esm/components/CnIntegrationWidget/CnIntegrationWidget.vue2.js +10 -0
  8. package/dist/esm/components/CnIntegrationWidget/CnIntegrationWidget.vue2.js.map +1 -1
  9. package/dist/esm/components/CnIntegrationWidget/CnIntegrationWidget.vue3.js.map +1 -1
  10. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue.js +1 -1
  11. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js +202 -6
  12. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue2.js.map +1 -1
  13. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js +137 -55
  14. package/dist/esm/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue3.js.map +1 -1
  15. package/dist/esm/dialogs/CnPartyAddDialog.vue.js +9 -0
  16. package/dist/esm/dialogs/CnPartyAddDialog.vue.js.map +1 -0
  17. package/dist/esm/dialogs/CnPartyAddDialog.vue2.js +184 -0
  18. package/dist/esm/dialogs/CnPartyAddDialog.vue2.js.map +1 -0
  19. package/dist/esm/dialogs/CnPartyAddDialog.vue3.js +168 -0
  20. package/dist/esm/dialogs/CnPartyAddDialog.vue3.js.map +1 -0
  21. package/dist/esm/l10n/en.json.js +11 -1
  22. package/dist/esm/l10n/en.json.js.map +1 -1
  23. package/dist/esm/l10n/nl.json.js +11 -1
  24. package/dist/esm/l10n/nl.json.js.map +1 -1
  25. package/dist/esm/library-style.js +1 -1
  26. package/dist/esm/nextcloud-vue.css +95 -70
  27. package/dist/esm/utils/objectParties.js +79 -1
  28. package/dist/esm/utils/objectParties.js.map +1 -1
  29. package/dist/nextcloud-vue.cjs.js +5683 -4860
  30. package/dist/nextcloud-vue.cjs.js.map +2 -2
  31. package/dist/nextcloud-vue.css +95 -70
  32. package/l10n/en.json +11 -1
  33. package/l10n/nl.json +11 -1
  34. package/package.json +1 -1
  35. package/src/components/CnFieldListWidget/CnFieldListWidget.vue +105 -12
  36. package/src/components/CnIntegrationWidget/CnIntegrationWidget.vue +10 -0
  37. package/src/components/CnObjectPartiesWidget/CnObjectPartiesWidget.vue +264 -3
  38. package/src/dialogs/CnPartyAddDialog.vue +309 -0
  39. package/src/utils/objectParties.js +78 -0
@@ -13,6 +13,7 @@
13
13
  */
14
14
 
15
15
  import { translate as t } from '@nextcloud/l10n'
16
+ import { readPath } from './readPath.js'
16
17
 
17
18
  /**
18
19
  * What a role is called: the app's own word (`roleLabels`), else the label
@@ -174,3 +175,80 @@ export function documentsOfParty(documents, identifier, fields = {}) {
174
175
  export function kindCode(kind) {
175
176
  return String(kind?.code || kind?.key || '')
176
177
  }
178
+
179
+ /**
180
+ * Write a value at a dotted path, creating the objects on the way.
181
+ *
182
+ * @param {object} target The object written into.
183
+ * @param {string} path The dotted path (`name.surname`).
184
+ * @param {unknown} value The value.
185
+ * @return {void}
186
+ */
187
+ function writePath(target, path, value) {
188
+ const keys = String(path).split('.').filter((key) => key !== '')
189
+ let node = target
190
+ keys.slice(0, -1).forEach((key) => {
191
+ if (!node[key] || typeof node[key] !== 'object') {
192
+ node[key] = {}
193
+ }
194
+ node = node[key]
195
+ })
196
+ if (keys.length > 0) {
197
+ node[keys[keys.length - 1]] = value
198
+ }
199
+ }
200
+
201
+ /**
202
+ * The record a new party is saved as, from the fields a host declares.
203
+ *
204
+ * Each field `{ key, path?, address? }` writes its trimmed value at `path`
205
+ * (default `key`); a field with `address: { path, kind, type }` instead adds
206
+ * `{ kind, type, value }` to the list at that path, the shape OpenRegister's
207
+ * party model reads as the party's addresses. `compose` names the paths a
208
+ * derived field joins with a space, skipping the empty ones
209
+ * (`{ displayName: ["name.givenNames", "name.namePrefix", "name.surname"] }`).
210
+ * A field of `type: "integer"` is saved as a number when it reads as one.
211
+ * An empty value is left out.
212
+ *
213
+ * @param {{fields?: Array<object>, compose?: Record<string, Array<string>>}} create The declaration.
214
+ * @param {Record<string, string>} values The values by field key.
215
+ * @return {object} The record.
216
+ * @spec openspec/changes/object-parties-manage/specs/record-widgets/spec.md#requirement-the-parties-widget-can-add-and-remove-parties
217
+ */
218
+ export function newPartyRecord(create, values) {
219
+ const record = {}
220
+ for (const field of Array.isArray(create?.fields) ? create.fields : []) {
221
+ const value = String(values?.[field?.key] ?? '').trim()
222
+ if (!field || !field.key || value === '') {
223
+ continue
224
+ }
225
+ if (field.address && field.address.path) {
226
+ const list = readPath(record, field.address.path)
227
+ const entry = { kind: field.address.kind || 'correspondence', type: field.address.type || 'email', value }
228
+ writePath(record, field.address.path, [...(Array.isArray(list) ? list : []), entry])
229
+ continue
230
+ }
231
+ writePath(record, field.path || field.key, field.type === 'integer' && /^-?\d+$/.test(value) ? Number(value) : value)
232
+ }
233
+ for (const [target, paths] of Object.entries(create?.compose && typeof create.compose === 'object' ? create.compose : {})) {
234
+ const joined = (Array.isArray(paths) ? paths : [])
235
+ .map((path) => String(readPath(record, path) ?? '').trim())
236
+ .filter((part) => part !== '')
237
+ .join(' ')
238
+ if (joined !== '') {
239
+ writePath(record, target, joined)
240
+ }
241
+ }
242
+ return record
243
+ }
244
+
245
+ /**
246
+ * The uuid a create answered with: `id`, `uuid` or `@self.id`.
247
+ *
248
+ * @param {object} saved The saved object.
249
+ * @return {string} The uuid, or ''.
250
+ * @spec openspec/changes/object-parties-manage/specs/record-widgets/spec.md#requirement-the-parties-widget-can-add-and-remove-parties
251
+ */
252
+ export function savedUuid(saved) {
253
+ return String(saved?.['@self']?.id || saved?.uuid || saved?.id || '')
254
+ }