@conduction/nextcloud-vue 2.186.1 → 2.187.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.
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget.vue.js +1 -1
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget2.vue.js +281 -27
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget3.vue.js +86 -33
- package/dist/esm/components/CnPeopleWidget/CnPeopleWidget3.vue.js.map +1 -1
- package/dist/esm/components/CnPeopleWidget/peopleCache.js +76 -0
- package/dist/esm/components/CnPeopleWidget/peopleCache.js.map +1 -0
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm.vue.js +1 -1
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm2.vue.js +40 -9
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm2.vue.js.map +1 -1
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm3.vue.js +35 -26
- package/dist/esm/components/CnPeopleWidgetForm/CnPeopleWidgetForm3.vue.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget.vue.js +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget2.vue.js +32 -12
- package/dist/esm/components/CnTextWidget/CnTextWidget2.vue.js.map +1 -1
- package/dist/esm/components/CnTextWidget/CnTextWidget3.vue.js.map +1 -1
- package/dist/esm/l10n/nl.json.js +4 -0
- package/dist/esm/l10n/nl.json.js.map +1 -1
- package/dist/esm/library-style.js +1 -1
- package/dist/esm/nextcloud-vue.css +128 -72
- package/dist/nextcloud-vue.cjs.js +1305 -861
- package/dist/nextcloud-vue.cjs.js.map +2 -2
- package/dist/nextcloud-vue.css +128 -72
- package/l10n/nl.json +4 -0
- package/package.json +1 -1
- package/src/components/CnPeopleWidget/CnPeopleWidget.vue +402 -56
- package/src/components/CnPeopleWidget/peopleCache.js +73 -0
- package/src/components/CnPeopleWidgetForm/CnPeopleWidgetForm.vue +45 -11
- package/src/components/CnTextWidget/CnTextWidget.vue +32 -12
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPDX-FileCopyrightText: 2026 Conduction B.V.
|
|
3
|
+
* SPDX-License-Identifier: EUPL-1.2
|
|
4
|
+
*
|
|
5
|
+
* In-memory page cache for CnPeopleWidget. It lives at module level so a
|
|
6
|
+
* widget that is unmounted and mounted again (switching dashboards) is
|
|
7
|
+
* served from it instead of asking the directory again.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** How long a cached page stays fresh, in milliseconds. */
|
|
11
|
+
export const PEOPLE_CACHE_TTL_MS = 60 * 1000
|
|
12
|
+
|
|
13
|
+
const pages = new Map()
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The cache key of one page.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} baseKey the serialised fetch arguments, without the offset.
|
|
19
|
+
* @param {number} offset the page offset.
|
|
20
|
+
* @return {string} the key.
|
|
21
|
+
*/
|
|
22
|
+
function keyOf(baseKey, offset) {
|
|
23
|
+
return `${baseKey}|${offset}`
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* A cached page that is still fresh, or `null`.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} baseKey the serialised fetch arguments.
|
|
30
|
+
* @param {number} offset the page offset.
|
|
31
|
+
* @return {object|null} the cached `{users, total, hasMore}` page.
|
|
32
|
+
*/
|
|
33
|
+
export function readPeoplePage(baseKey, offset) {
|
|
34
|
+
const entry = pages.get(keyOf(baseKey, offset))
|
|
35
|
+
if (!entry) {
|
|
36
|
+
return null
|
|
37
|
+
}
|
|
38
|
+
if (Date.now() - entry.storedAt >= PEOPLE_CACHE_TTL_MS) {
|
|
39
|
+
pages.delete(keyOf(baseKey, offset))
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
42
|
+
return entry.page
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Keep a page.
|
|
47
|
+
*
|
|
48
|
+
* @param {string} baseKey the serialised fetch arguments.
|
|
49
|
+
* @param {number} offset the page offset.
|
|
50
|
+
* @param {object} page the `{users, total, hasMore}` page.
|
|
51
|
+
* @return {void}
|
|
52
|
+
*/
|
|
53
|
+
export function storePeoplePage(baseKey, offset, page) {
|
|
54
|
+
pages.set(keyOf(baseKey, offset), { page, storedAt: Date.now() })
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Drop every cached page of one argument set, or the whole cache.
|
|
59
|
+
*
|
|
60
|
+
* @param {string} [baseKey] the serialised fetch arguments; all when omitted.
|
|
61
|
+
* @return {void}
|
|
62
|
+
*/
|
|
63
|
+
export function clearPeoplePages(baseKey) {
|
|
64
|
+
if (baseKey === undefined) {
|
|
65
|
+
pages.clear()
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
for (const key of [...pages.keys()]) {
|
|
69
|
+
if (key.startsWith(`${baseKey}|`)) {
|
|
70
|
+
pages.delete(key)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -21,7 +21,10 @@
|
|
|
21
21
|
:reduce="(option) => option.value"
|
|
22
22
|
label="label"
|
|
23
23
|
:clearable="false"
|
|
24
|
-
@update:modelValue="
|
|
24
|
+
@update:modelValue="updateSortBy($event)" />
|
|
25
|
+
<p v-if="sortByError" class="cn-people-widget-form__error" role="alert">
|
|
26
|
+
{{ sortByError }}
|
|
27
|
+
</p>
|
|
25
28
|
|
|
26
29
|
<label class="cn-people-widget-form__field">
|
|
27
30
|
{{ t('nextcloud-vue', 'Group filter (comma-separated, blank for all)') }}
|
|
@@ -58,7 +61,7 @@
|
|
|
58
61
|
max="30"
|
|
59
62
|
:value="birthdayWindowDays"
|
|
60
63
|
@input="updateBirthdayWindow($event.target.value)">
|
|
61
|
-
<span v-if="birthdayWindowError" class="cn-people-widget-form__error">
|
|
64
|
+
<span v-if="birthdayWindowError" class="cn-people-widget-form__error" role="alert">
|
|
62
65
|
{{ birthdayWindowError }}
|
|
63
66
|
</span>
|
|
64
67
|
</label>
|
|
@@ -87,6 +90,8 @@
|
|
|
87
90
|
import { translate as t } from '@nextcloud/l10n'
|
|
88
91
|
import { NcSelect } from '@nextcloud/vue'
|
|
89
92
|
|
|
93
|
+
const SORT_KEYS = ['displayName', 'group']
|
|
94
|
+
|
|
90
95
|
const DEFAULT_CONTENT = Object.freeze({
|
|
91
96
|
layout: 'grid',
|
|
92
97
|
selectionMode: 'filter',
|
|
@@ -116,7 +121,10 @@ const DEFAULT_CONTENT = Object.freeze({
|
|
|
116
121
|
* (selectionMode, selectedUsers, filterOperator, showFields) travel through
|
|
117
122
|
* untouched from their defaults. Group filter persists as the canonical
|
|
118
123
|
* `[{fieldName:'group', operator:'in', values:[...]}]` shape. Emits
|
|
119
|
-
* `update:content` on change and exposes `validate()
|
|
124
|
+
* `update:content` on change and exposes `validate()`: a birthday window
|
|
125
|
+
* typed outside 0..30 keeps the form invalid until it is corrected, and a
|
|
126
|
+
* stored unknown `sortBy` is shown as Display name with a message, keeping
|
|
127
|
+
* the form invalid until a sort key is picked.
|
|
120
128
|
*/
|
|
121
129
|
export default {
|
|
122
130
|
name: 'CnPeopleWidgetForm',
|
|
@@ -151,6 +159,8 @@ export default {
|
|
|
151
159
|
|
|
152
160
|
data() {
|
|
153
161
|
const initial = this.editingWidget?.content || this.value || {}
|
|
162
|
+
const storedSortBy = initial.sortBy ?? DEFAULT_CONTENT.sortBy
|
|
163
|
+
const sortByKnown = SORT_KEYS.includes(storedSortBy)
|
|
154
164
|
const groupFilter = (initial.filters || [])
|
|
155
165
|
.find((f) => f && f.fieldName === 'group')
|
|
156
166
|
return {
|
|
@@ -173,7 +183,11 @@ export default {
|
|
|
173
183
|
? initial.birthdayWindowDays
|
|
174
184
|
: DEFAULT_CONTENT.birthdayWindowDays,
|
|
175
185
|
|
|
176
|
-
sortBy:
|
|
186
|
+
sortBy: sortByKnown ? storedSortBy : DEFAULT_CONTENT.sortBy,
|
|
187
|
+
sortByError: sortByKnown
|
|
188
|
+
? ''
|
|
189
|
+
: t('nextcloud-vue', 'Unknown sort key "{key}". Display name is used instead.', { key: String(storedSortBy) }),
|
|
190
|
+
|
|
177
191
|
columns: typeof initial.columns === 'number'
|
|
178
192
|
? initial.columns
|
|
179
193
|
: DEFAULT_CONTENT.columns,
|
|
@@ -255,6 +269,18 @@ export default {
|
|
|
255
269
|
this.$emit('update:content', this.assembledContent)
|
|
256
270
|
},
|
|
257
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Set the sort key; picking one confirms it and clears the
|
|
274
|
+
* unknown-key message.
|
|
275
|
+
*
|
|
276
|
+
* @param {string} value the chosen sort key.
|
|
277
|
+
* @return {void}
|
|
278
|
+
*/
|
|
279
|
+
updateSortBy(value) {
|
|
280
|
+
this.sortByError = ''
|
|
281
|
+
this.updateField('sortBy', value)
|
|
282
|
+
},
|
|
283
|
+
|
|
258
284
|
/**
|
|
259
285
|
* Parse the comma-separated group input into the canonical filters
|
|
260
286
|
* shape and re-emit the assembled content.
|
|
@@ -271,20 +297,22 @@ export default {
|
|
|
271
297
|
},
|
|
272
298
|
|
|
273
299
|
/**
|
|
274
|
-
* Validate
|
|
275
|
-
* localised inline error
|
|
300
|
+
* Validate the birthday window against the 0..30 range. An out-of-range
|
|
301
|
+
* value records a localised inline error, which keeps `validate()`
|
|
302
|
+
* failing until a valid value is typed; the last valid value stays in
|
|
303
|
+
* the content.
|
|
276
304
|
*
|
|
277
305
|
* @param {string|number} raw the input value.
|
|
278
306
|
* @return {void}
|
|
279
307
|
*/
|
|
280
308
|
updateBirthdayWindow(raw) {
|
|
281
309
|
const numeric = Number(raw)
|
|
282
|
-
if (!Number.isFinite(numeric) || numeric < 0 || numeric > 30) {
|
|
310
|
+
if (raw === '' || !Number.isFinite(numeric) || numeric < 0 || numeric > 30) {
|
|
283
311
|
this.birthdayWindowError = t('nextcloud-vue', 'Must be between 0 and 30')
|
|
284
|
-
|
|
312
|
+
} else {
|
|
313
|
+
this.birthdayWindowError = ''
|
|
314
|
+
this.birthdayWindowDays = Math.floor(numeric)
|
|
285
315
|
}
|
|
286
|
-
this.birthdayWindowError = ''
|
|
287
|
-
this.birthdayWindowDays = Math.floor(numeric)
|
|
288
316
|
this.$emit('update:content', this.assembledContent)
|
|
289
317
|
},
|
|
290
318
|
|
|
@@ -295,6 +323,12 @@ export default {
|
|
|
295
323
|
*/
|
|
296
324
|
validate() {
|
|
297
325
|
const errors = []
|
|
326
|
+
if (this.sortByError) {
|
|
327
|
+
errors.push(this.sortByError)
|
|
328
|
+
}
|
|
329
|
+
if (this.showBirthdays && this.birthdayWindowError) {
|
|
330
|
+
errors.push(this.birthdayWindowError)
|
|
331
|
+
}
|
|
298
332
|
if (typeof this.birthdayWindowDays !== 'number'
|
|
299
333
|
|| this.birthdayWindowDays < 0
|
|
300
334
|
|| this.birthdayWindowDays > 30) {
|
|
@@ -303,7 +337,7 @@ export default {
|
|
|
303
337
|
if (!['card', 'grid', 'list'].includes(this.layout)) {
|
|
304
338
|
errors.push(t('nextcloud-vue', 'Invalid layout'))
|
|
305
339
|
}
|
|
306
|
-
if (!
|
|
340
|
+
if (!SORT_KEYS.includes(this.sortBy)) {
|
|
307
341
|
errors.push(t('nextcloud-vue', 'Invalid sort key'))
|
|
308
342
|
}
|
|
309
343
|
return errors
|
|
@@ -113,6 +113,24 @@ function ensureDomPurifyHook() {
|
|
|
113
113
|
hookRegistered = true
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// The widget's own sanitiser config: `target` survives (the hook above adds
|
|
117
|
+
// `rel`), `data-*` attributes do not.
|
|
118
|
+
const SANITIZE_CONFIG = {
|
|
119
|
+
ADD_ATTR: ['target'],
|
|
120
|
+
ALLOW_DATA_ATTR: false,
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Sanitise author HTML with the widget's own config.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} html The HTML.
|
|
127
|
+
* @return {string} HTML safe for `v-html`.
|
|
128
|
+
*/
|
|
129
|
+
function sanitize(html) {
|
|
130
|
+
ensureDomPurifyHook()
|
|
131
|
+
return DOMPurify.sanitize(html, SANITIZE_CONFIG)
|
|
132
|
+
}
|
|
133
|
+
|
|
116
134
|
/**
|
|
117
135
|
* CnTextWidget — renders user-authored multi-line text (or a small table)
|
|
118
136
|
* inside a dashboard cell. Text content is passed through DOMPurify before
|
|
@@ -178,7 +196,11 @@ export default {
|
|
|
178
196
|
|
|
179
197
|
computed: {
|
|
180
198
|
/**
|
|
181
|
-
* The text: `content.textField` of the object as it is, else
|
|
199
|
+
* The text: `content.textField` of the object as it is, else
|
|
200
|
+
* `content.text`; '' when absent. Plain text goes through the app's
|
|
201
|
+
* translate function; text holding markup (`<`, `>`, `&`) is author
|
|
202
|
+
* content and is shown as written, because the translate function
|
|
203
|
+
* sanitises with its own allow-list (which drops `target`).
|
|
182
204
|
*
|
|
183
205
|
* @spec openspec/changes/text-widget-monospace/tasks.md#task-2
|
|
184
206
|
*/
|
|
@@ -188,7 +210,11 @@ export default {
|
|
|
188
210
|
const value = this.objectData?.[field]
|
|
189
211
|
return value === undefined || value === null ? '' : String(value)
|
|
190
212
|
}
|
|
191
|
-
|
|
213
|
+
const text = this.content?.text
|
|
214
|
+
if (typeof text !== 'string') {
|
|
215
|
+
return ''
|
|
216
|
+
}
|
|
217
|
+
return /[<>&]/.test(text) ? text : this.tr(text)
|
|
192
218
|
},
|
|
193
219
|
|
|
194
220
|
/**
|
|
@@ -274,9 +300,7 @@ export default {
|
|
|
274
300
|
} else {
|
|
275
301
|
html = this.text
|
|
276
302
|
}
|
|
277
|
-
return
|
|
278
|
-
ADD_ATTR: ['target'],
|
|
279
|
-
})
|
|
303
|
+
return sanitize(html)
|
|
280
304
|
},
|
|
281
305
|
|
|
282
306
|
/** Localised placeholder shown when there is no text content. */
|
|
@@ -342,8 +366,8 @@ export default {
|
|
|
342
366
|
height: '100%',
|
|
343
367
|
padding: '16px',
|
|
344
368
|
display: 'flex',
|
|
345
|
-
'align-items': 'center',
|
|
346
|
-
'justify-content': 'center',
|
|
369
|
+
'align-items': 'safe center',
|
|
370
|
+
'justify-content': 'safe center',
|
|
347
371
|
overflow: 'auto',
|
|
348
372
|
'background-color': this.backgroundColor,
|
|
349
373
|
...(this.link ? { 'flex-direction': 'column', gap: '8px', 'align-items': 'flex-start' } : {}),
|
|
@@ -376,10 +400,6 @@ export default {
|
|
|
376
400
|
},
|
|
377
401
|
},
|
|
378
402
|
|
|
379
|
-
created() {
|
|
380
|
-
ensureDomPurifyHook()
|
|
381
|
-
},
|
|
382
|
-
|
|
383
403
|
methods: {
|
|
384
404
|
/**
|
|
385
405
|
* A manifest string through the app's translate function.
|
|
@@ -410,7 +430,7 @@ export default {
|
|
|
410
430
|
* @return {string} sanitised HTML safe to render via `v-html`.
|
|
411
431
|
*/
|
|
412
432
|
sanitizeCell(text) {
|
|
413
|
-
return
|
|
433
|
+
return sanitize(typeof text === 'string' ? text : '')
|
|
414
434
|
},
|
|
415
435
|
|
|
416
436
|
/**
|