@conduction/nextcloud-vue 2.56.0-beta.5 → 2.56.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/CnRelatedObjectsWidget/CnRelatedObjectsWidget.vue2.js +100 -3
- package/dist/esm/components/CnRelatedObjectsWidget/CnRelatedObjectsWidget.vue2.js.map +1 -1
- package/dist/esm/components/CnRelatedObjectsWidget/CnRelatedObjectsWidget.vue3.js.map +1 -1
- package/dist/nextcloud-vue.cjs.js +100 -3
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/package.json +1 -1
- package/src/components/CnRelatedObjectsWidget/CnRelatedObjectsWidget.vue +100 -3
|
@@ -43,6 +43,26 @@ const CORE_TABS = ['files', 'notes', 'tags', 'tasks', 'auditTrail', 'shares'];
|
|
|
43
43
|
/** One-time guard so the legacy-path deprecation warning logs only once. */
|
|
44
44
|
let legacyWarned = false;
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Schema titles by numeric schema id, shared by every widget on the page so a
|
|
48
|
+
* schema is asked for once. OpenRegister's `/uses` and `/used` answer
|
|
49
|
+
* `@self.schema` as that id ("120"), which is not a word anyone can read.
|
|
50
|
+
*
|
|
51
|
+
* @type {Map<string, Promise<string>>}
|
|
52
|
+
*/
|
|
53
|
+
const schemaTitleCache = new Map();
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether a value is a bare number, the way OpenRegister names a schema by id.
|
|
57
|
+
*
|
|
58
|
+
* @param {string|number|undefined|null} value The value.
|
|
59
|
+
* @return {boolean}
|
|
60
|
+
*/
|
|
61
|
+
function isNumericId(value) {
|
|
62
|
+
return (typeof value === 'number' && Number.isFinite(value))
|
|
63
|
+
|| (typeof value === 'string' && /^\d+$/.test(value.trim()))
|
|
64
|
+
}
|
|
65
|
+
|
|
46
66
|
/**
|
|
47
67
|
* Leaf groups surfaced by the aggregated `/relations` endpoint, in tab order.
|
|
48
68
|
* `responseKey` is the key in the `/relations` payload; `integrationId` is the
|
|
@@ -125,6 +145,14 @@ var script = {
|
|
|
125
145
|
NcEmptyContent,
|
|
126
146
|
},
|
|
127
147
|
|
|
148
|
+
inject: {
|
|
149
|
+
/**
|
|
150
|
+
* The host app's translator (CnAppRoot provides it), so a schema title
|
|
151
|
+
* reads in the app's language. Without it a title reads as stored.
|
|
152
|
+
*/
|
|
153
|
+
cnTranslate: { default: () => (key) => key },
|
|
154
|
+
},
|
|
155
|
+
|
|
128
156
|
props: {
|
|
129
157
|
/** Widget title shown in the header. */
|
|
130
158
|
title: {
|
|
@@ -388,6 +416,8 @@ var script = {
|
|
|
388
416
|
* @type {HTMLInputElement|null}
|
|
389
417
|
*/
|
|
390
418
|
fileInputEl: null,
|
|
419
|
+
/** Schema titles by numeric schema id, for object rows. */
|
|
420
|
+
schemaTitles: {},
|
|
391
421
|
/** Whether any section/tab is currently fetching. */
|
|
392
422
|
loading: false,
|
|
393
423
|
/** True once the first fetch has completed (gates the empty state). */
|
|
@@ -1080,9 +1110,74 @@ var script = {
|
|
|
1080
1110
|
self.name,
|
|
1081
1111
|
raw.summary,
|
|
1082
1112
|
raw.description,
|
|
1083
|
-
].find((v) => typeof v === 'string' && v.trim() && !isUuid(v))
|
|
1084
|
-
|
|
1085
|
-
|
|
1113
|
+
].find((v) => typeof v === 'string' && v.trim() && !isUuid(v))
|
|
1114
|
+
|| [raw.givenName, raw.familyName].filter((v) => typeof v === 'string' && v.trim()).join(' ');
|
|
1115
|
+
// OpenRegister names the schema by numeric id: show its title, never the number.
|
|
1116
|
+
const schema = this.schemaName(self.schema || raw.schema);
|
|
1117
|
+
const finalLabel = label || schema || String(id);
|
|
1118
|
+
return { id, label: finalLabel, meta: schema === finalLabel ? '' : schema, raw }
|
|
1119
|
+
},
|
|
1120
|
+
|
|
1121
|
+
/**
|
|
1122
|
+
* How a row names its schema: the translated title for a numeric id
|
|
1123
|
+
* (empty until it is read, or when it cannot be), a slug as it is.
|
|
1124
|
+
*
|
|
1125
|
+
* @param {string|number|undefined|null} schema - `@self.schema` of the related object.
|
|
1126
|
+
* @return {string}
|
|
1127
|
+
*/
|
|
1128
|
+
schemaName(schema) {
|
|
1129
|
+
if (isNumericId(schema)) {
|
|
1130
|
+
const title = this.schemaTitles[String(schema).trim()];
|
|
1131
|
+
return title ? this.cnTranslate(title) : ''
|
|
1132
|
+
}
|
|
1133
|
+
return typeof schema === 'string' ? schema : ''
|
|
1134
|
+
},
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Read the titles of the numeric schema ids in these envelopes once,
|
|
1138
|
+
* before the rows are built, so no row shows a number first.
|
|
1139
|
+
*
|
|
1140
|
+
* @param {Array<object|null>} envelopes - The `{ results }` payloads.
|
|
1141
|
+
* @return {Promise<void>}
|
|
1142
|
+
*/
|
|
1143
|
+
async resolveSchemaTitles(envelopes) {
|
|
1144
|
+
const ids = new Set();
|
|
1145
|
+
for (const envelope of envelopes) {
|
|
1146
|
+
for (const raw of ((envelope && envelope.results) || [])) {
|
|
1147
|
+
const schema = (raw && (raw['@self'] || {}).schema) ?? (raw && raw.schema);
|
|
1148
|
+
if (isNumericId(schema)) {
|
|
1149
|
+
ids.add(String(schema).trim());
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
const titles = { ...this.schemaTitles };
|
|
1154
|
+
await Promise.all([...ids].filter((id) => !(id in titles)).map(async (id) => {
|
|
1155
|
+
if (!schemaTitleCache.has(id)) {
|
|
1156
|
+
schemaTitleCache.set(id, this.fetchSchemaTitle(id));
|
|
1157
|
+
}
|
|
1158
|
+
titles[id] = await schemaTitleCache.get(id);
|
|
1159
|
+
}));
|
|
1160
|
+
this.schemaTitles = titles;
|
|
1161
|
+
},
|
|
1162
|
+
|
|
1163
|
+
/**
|
|
1164
|
+
* GET one schema's title; '' when it cannot be read.
|
|
1165
|
+
*
|
|
1166
|
+
* @param {string} id - The numeric schema id.
|
|
1167
|
+
* @return {Promise<string>}
|
|
1168
|
+
*/
|
|
1169
|
+
async fetchSchemaTitle(id) {
|
|
1170
|
+
try {
|
|
1171
|
+
const response = await fetch(generateUrl('/apps/openregister/api/schemas/{id}', { id }), { method: 'GET', headers: buildHeaders() });
|
|
1172
|
+
if (!response.ok) {
|
|
1173
|
+
return ''
|
|
1174
|
+
}
|
|
1175
|
+
const schema = await response.json();
|
|
1176
|
+
const title = schema && (schema.title || schema.slug);
|
|
1177
|
+
return typeof title === 'string' ? title : ''
|
|
1178
|
+
} catch {
|
|
1179
|
+
return ''
|
|
1180
|
+
}
|
|
1086
1181
|
},
|
|
1087
1182
|
|
|
1088
1183
|
/**
|
|
@@ -1186,6 +1281,7 @@ var script = {
|
|
|
1186
1281
|
const groups = [];
|
|
1187
1282
|
|
|
1188
1283
|
if (this.showObjects) {
|
|
1284
|
+
await this.resolveSchemaTitles([uses, used, contracts]);
|
|
1189
1285
|
const objectItems = this.mergeObjectResults([uses, used, contracts]);
|
|
1190
1286
|
groups.push({ key: 'objects', label: this.objectsLabel, icon: 'FileTreeOutline', integrationId: '', items: objectItems, total: objectItems.length });
|
|
1191
1287
|
}
|
|
@@ -1311,6 +1407,7 @@ var script = {
|
|
|
1311
1407
|
calls.push(store.fetchContracts(type, id));
|
|
1312
1408
|
}
|
|
1313
1409
|
const groups = await Promise.all(calls);
|
|
1410
|
+
await this.resolveSchemaTitles(groups.map((results) => ({ results: results || [] })));
|
|
1314
1411
|
const seen = new Set();
|
|
1315
1412
|
const merged = [];
|
|
1316
1413
|
for (const group of groups) {
|