@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
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
type="search"
|
|
12
12
|
class="cn-people-widget__search"
|
|
13
13
|
:aria-label="t('nextcloud-vue', 'Search by name or email')"
|
|
14
|
-
:placeholder="
|
|
14
|
+
:placeholder="searchPlaceholder">
|
|
15
15
|
<button
|
|
16
16
|
type="button"
|
|
17
17
|
class="cn-people-widget__refresh"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
</button>
|
|
23
23
|
</header>
|
|
24
24
|
|
|
25
|
-
<div v-if="loading &&
|
|
25
|
+
<div v-if="(loading || searchPending) && displayedUsers.length === 0" class="cn-people-widget__state">
|
|
26
26
|
{{ t('nextcloud-vue', 'Loading…') }}
|
|
27
27
|
</div>
|
|
28
28
|
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
{{ t('nextcloud-vue', 'No people directory available') }}
|
|
38
38
|
</div>
|
|
39
39
|
|
|
40
|
-
<div v-else-if="
|
|
41
|
-
{{ search ? t('nextcloud-vue', 'No users match your search') : t('nextcloud-vue', 'No
|
|
40
|
+
<div v-else-if="displayedUsers.length === 0" class="cn-people-widget__state">
|
|
41
|
+
{{ search.trim() ? t('nextcloud-vue', 'No users match your search') : t('nextcloud-vue', 'No matching users.') }}
|
|
42
42
|
</div>
|
|
43
43
|
|
|
44
44
|
<div
|
|
@@ -46,31 +46,57 @@
|
|
|
46
46
|
class="cn-people-widget__items"
|
|
47
47
|
:style="gridStyle"
|
|
48
48
|
role="list">
|
|
49
|
-
<
|
|
50
|
-
v-for="user in
|
|
49
|
+
<div
|
|
50
|
+
v-for="user in displayedUsers"
|
|
51
51
|
:key="user.uid"
|
|
52
|
-
:href="profileUrl(user.uid)"
|
|
53
52
|
class="cn-people-widget__item"
|
|
54
53
|
role="listitem">
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
54
|
+
<a :href="profileUrl(user.uid)" class="cn-people-widget__link">
|
|
55
|
+
<img
|
|
56
|
+
v-if="showAvatar && user.avatarUrl"
|
|
57
|
+
:src="user.avatarUrl"
|
|
58
|
+
:width="avatarSize"
|
|
59
|
+
:height="avatarSize"
|
|
60
|
+
alt=""
|
|
61
|
+
class="cn-people-widget__avatar">
|
|
62
|
+
<div class="cn-people-widget__meta">
|
|
63
|
+
<strong class="cn-people-widget__name">{{ user.displayName || user.uid }}</strong>
|
|
64
|
+
<template v-if="layout !== 'grid'">
|
|
65
|
+
<span v-if="shows('role') && user.role" class="cn-people-widget__sub">{{ user.role }}</span>
|
|
66
|
+
<span v-if="shows('organisation') && (user.organisation || user.department)" class="cn-people-widget__sub">
|
|
67
|
+
{{ user.organisation || user.department }}
|
|
68
|
+
</span>
|
|
69
|
+
<span v-if="shows('email') && user.email" class="cn-people-widget__sub">{{ user.email }}</span>
|
|
70
|
+
<span v-if="shows('phone') && user.phone" class="cn-people-widget__sub">{{ user.phone }}</span>
|
|
71
|
+
</template>
|
|
72
|
+
</div>
|
|
73
|
+
</a>
|
|
74
|
+
<div v-if="layout !== 'grid' && customFieldsOf(user).length > 0" class="cn-people-widget__fields">
|
|
75
|
+
<template v-for="field in customFieldsOf(user)" :key="field.key">
|
|
76
|
+
<ul
|
|
77
|
+
v-if="field.type === 'tags'"
|
|
78
|
+
class="cn-people-widget__tags"
|
|
79
|
+
:aria-label="field.label">
|
|
80
|
+
<li v-for="tag in field.values" :key="tag">
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
class="cn-people-widget__tag"
|
|
84
|
+
:class="{ 'cn-people-widget__tag--match': tagMatches(tag) }"
|
|
85
|
+
:aria-label="t('nextcloud-vue', 'Find everyone tagged {tag}', { tag })"
|
|
86
|
+
@click="searchTag(tag)">
|
|
87
|
+
{{ tag }}
|
|
88
|
+
</button>
|
|
89
|
+
</li>
|
|
90
|
+
</ul>
|
|
91
|
+
<span v-else class="cn-people-widget__sub cn-people-widget__field">
|
|
92
|
+
{{ field.label }}: {{ field.values.join(', ') }}
|
|
93
|
+
</span>
|
|
94
|
+
</template>
|
|
69
95
|
</div>
|
|
70
|
-
</
|
|
96
|
+
</div>
|
|
71
97
|
</div>
|
|
72
98
|
|
|
73
|
-
<footer v-if="
|
|
99
|
+
<footer v-if="canLoadMore && !error" class="cn-people-widget__footer">
|
|
74
100
|
<button
|
|
75
101
|
type="button"
|
|
76
102
|
class="cn-people-widget__load-more"
|
|
@@ -84,10 +110,13 @@
|
|
|
84
110
|
|
|
85
111
|
<script>
|
|
86
112
|
import { translate as t } from '@nextcloud/l10n'
|
|
113
|
+
import { clearPeoplePages, readPeoplePage, storePeoplePage } from './peopleCache.js'
|
|
87
114
|
|
|
88
115
|
const ALLOWED_LAYOUTS = ['card', 'grid', 'list']
|
|
89
116
|
const DEFAULT_LAYOUT = 'grid'
|
|
90
117
|
const PAGE_SIZE = 50
|
|
118
|
+
const MIN_SERVER_QUERY = 2
|
|
119
|
+
const SEARCH_DEBOUNCE_MS = 300
|
|
91
120
|
|
|
92
121
|
/**
|
|
93
122
|
* CnPeopleWidget — renders a paginated, group-filterable user directory in one
|
|
@@ -96,16 +125,28 @@ const PAGE_SIZE = 50
|
|
|
96
125
|
* Data origin (decoupling seam): the people directory is read through a
|
|
97
126
|
* consumer-supplied `dataSource` prop OR the `cnPeopleSource` injection — an
|
|
98
127
|
* object exposing `fetchPeople({ offset, limit, filters, excludeDisabled,
|
|
99
|
-
* sortBy }) => Promise<{ users, total, hasMore }
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
128
|
+
* sortBy, showBirthdays }) => Promise<{ users, total, hasMore }>` and,
|
|
129
|
+
* optionally, `searchPeople({ q, ...same }) => Promise<{ users, total,
|
|
130
|
+
* hasMore }>` for a directory-wide search. When neither prop nor injection is
|
|
131
|
+
* supplied the widget degrades to an empty state ("No people directory
|
|
132
|
+
* available") and performs no request.
|
|
104
133
|
*
|
|
105
|
-
* Search
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
134
|
+
* Search: with a `searchPeople` source, a query of {@link MIN_SERVER_QUERY} or
|
|
135
|
+
* more characters is asked of the source (debounced, never cached, a late
|
|
136
|
+
* answer to an older query is dropped); shorter queries, and sources without
|
|
137
|
+
* `searchPeople`, filter the loaded page on name and email. A tag on a card is
|
|
138
|
+
* a button that searches for it; tags matching the query are highlighted.
|
|
139
|
+
*
|
|
140
|
+
* Fields: `content.showFields` picks the role, organisation, email and phone
|
|
141
|
+
* lines on card and list layouts. When it is an object, only the keys set to
|
|
142
|
+
* `true` show; the avatar and each custom profile field (`user.customFields`,
|
|
143
|
+
* `[{key, label, type: 'text'|'tags', values}]`) show unless their key is
|
|
144
|
+
* explicitly `false`. The grid layout shows avatar and name only.
|
|
145
|
+
*
|
|
146
|
+
* Pages are cached in memory for 60 seconds per argument set, across
|
|
147
|
+
* remounts; Refresh drops the cache and fetches again. Pagination is
|
|
148
|
+
* offset-based: each "Load more" appends one {@link PAGE_SIZE} page. A failed
|
|
149
|
+
* fetch surfaces a retryable error state rather than throwing.
|
|
109
150
|
*
|
|
110
151
|
* @spec openspec/changes/cn-widget-library/specs/cn-widget-library/spec.md
|
|
111
152
|
*/
|
|
@@ -121,7 +162,7 @@ export default {
|
|
|
121
162
|
props: {
|
|
122
163
|
/**
|
|
123
164
|
* Persisted widget content `{layout, filters, excludeDisabled,
|
|
124
|
-
* sortBy, columns}`.
|
|
165
|
+
* showBirthdays, sortBy, columns, showFields}`.
|
|
125
166
|
*
|
|
126
167
|
* @type {object}
|
|
127
168
|
*/
|
|
@@ -132,8 +173,9 @@ export default {
|
|
|
132
173
|
|
|
133
174
|
/**
|
|
134
175
|
* Consumer-supplied data source overriding the `cnPeopleSource`
|
|
135
|
-
* injection. Must expose `fetchPeople(args)
|
|
136
|
-
*
|
|
176
|
+
* injection. Must expose `fetchPeople(args)` and may expose
|
|
177
|
+
* `searchPeople(args)`. When `null` the injection (then the empty
|
|
178
|
+
* state) is used.
|
|
137
179
|
*
|
|
138
180
|
* @type {object|null}
|
|
139
181
|
*/
|
|
@@ -151,6 +193,12 @@ export default {
|
|
|
151
193
|
loading: false,
|
|
152
194
|
error: null,
|
|
153
195
|
search: '',
|
|
196
|
+
searchResults: [],
|
|
197
|
+
searchHasMore: false,
|
|
198
|
+
searchPending: false,
|
|
199
|
+
searchTimer: null,
|
|
200
|
+
searchSeq: 0,
|
|
201
|
+
pageSeq: 0,
|
|
154
202
|
}
|
|
155
203
|
},
|
|
156
204
|
|
|
@@ -174,6 +222,26 @@ export default {
|
|
|
174
222
|
return this.source !== null
|
|
175
223
|
},
|
|
176
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Whether the source can search the whole directory.
|
|
227
|
+
*
|
|
228
|
+
* @return {boolean} true when it exposes `searchPeople`.
|
|
229
|
+
*/
|
|
230
|
+
canSearchServer() {
|
|
231
|
+
return this.source !== null && typeof this.source.searchPeople === 'function'
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* The search box placeholder.
|
|
236
|
+
*
|
|
237
|
+
* @return {string} the localised placeholder.
|
|
238
|
+
*/
|
|
239
|
+
searchPlaceholder() {
|
|
240
|
+
return this.canSearchServer
|
|
241
|
+
? t('nextcloud-vue', 'Search by name, email or expertise…')
|
|
242
|
+
: t('nextcloud-vue', 'Search by name or email…')
|
|
243
|
+
},
|
|
244
|
+
|
|
177
245
|
/**
|
|
178
246
|
* The validated layout mode (defaults to `grid`).
|
|
179
247
|
*
|
|
@@ -234,11 +302,47 @@ export default {
|
|
|
234
302
|
},
|
|
235
303
|
|
|
236
304
|
/**
|
|
237
|
-
* The
|
|
305
|
+
* The `showFields` map when one is configured, else `null` (show all).
|
|
306
|
+
*
|
|
307
|
+
* @return {object|null} the field map.
|
|
308
|
+
*/
|
|
309
|
+
showFields() {
|
|
310
|
+
const value = this.content && this.content.showFields
|
|
311
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : null
|
|
312
|
+
},
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Whether avatars show (unless `showFields.avatar` is `false`).
|
|
238
316
|
*
|
|
239
|
-
* @return {
|
|
317
|
+
* @return {boolean} true when avatars show.
|
|
240
318
|
*/
|
|
241
|
-
|
|
319
|
+
showAvatar() {
|
|
320
|
+
return !(this.showFields && this.showFields.avatar === false)
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The trimmed query when it goes to the source, else ''.
|
|
325
|
+
*
|
|
326
|
+
* @return {string} the server query.
|
|
327
|
+
*/
|
|
328
|
+
serverQuery() {
|
|
329
|
+
if (!this.canSearchServer) {
|
|
330
|
+
return ''
|
|
331
|
+
}
|
|
332
|
+
const query = (this.search || '').trim()
|
|
333
|
+
return query.length >= MIN_SERVER_QUERY ? query : ''
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* The users to show: server results for a server query, else the
|
|
338
|
+
* loaded pages filtered on name and email.
|
|
339
|
+
*
|
|
340
|
+
* @return {object[]} the users.
|
|
341
|
+
*/
|
|
342
|
+
displayedUsers() {
|
|
343
|
+
if (this.serverQuery) {
|
|
344
|
+
return this.searchResults
|
|
345
|
+
}
|
|
242
346
|
if (!this.search) {
|
|
243
347
|
return this.users
|
|
244
348
|
}
|
|
@@ -250,6 +354,15 @@ export default {
|
|
|
250
354
|
})
|
|
251
355
|
},
|
|
252
356
|
|
|
357
|
+
/**
|
|
358
|
+
* Whether another page can be appended.
|
|
359
|
+
*
|
|
360
|
+
* @return {boolean} true when Load more applies.
|
|
361
|
+
*/
|
|
362
|
+
canLoadMore() {
|
|
363
|
+
return this.serverQuery ? this.searchHasMore : this.hasMore
|
|
364
|
+
},
|
|
365
|
+
|
|
253
366
|
/**
|
|
254
367
|
* The fetch arguments derived from content (drives the reload watch).
|
|
255
368
|
*
|
|
@@ -260,24 +373,53 @@ export default {
|
|
|
260
373
|
return {
|
|
261
374
|
filters,
|
|
262
375
|
excludeDisabled: !(this.content && this.content.excludeDisabled === false),
|
|
376
|
+
showBirthdays: !(this.content && this.content.showBirthdays === false),
|
|
263
377
|
sortBy: (this.content && this.content.sortBy) || 'displayName',
|
|
264
378
|
}
|
|
265
379
|
},
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* The cache key of the current argument set.
|
|
383
|
+
*
|
|
384
|
+
* @return {string} the serialised arguments.
|
|
385
|
+
*/
|
|
386
|
+
cacheKey() {
|
|
387
|
+
return JSON.stringify({ ...this.fetchArgs, limit: PAGE_SIZE })
|
|
388
|
+
},
|
|
266
389
|
},
|
|
267
390
|
|
|
268
391
|
watch: {
|
|
269
392
|
fetchArgs: {
|
|
270
393
|
deep: true,
|
|
271
394
|
handler() {
|
|
272
|
-
this.
|
|
395
|
+
this.resetPages()
|
|
396
|
+
this.fetchPage(0)
|
|
397
|
+
if (this.serverQuery) {
|
|
398
|
+
this.fetchSearch(0)
|
|
399
|
+
}
|
|
273
400
|
},
|
|
274
401
|
},
|
|
402
|
+
|
|
403
|
+
serverQuery(query) {
|
|
404
|
+
clearTimeout(this.searchTimer)
|
|
405
|
+
this.searchSeq++
|
|
406
|
+
this.searchResults = []
|
|
407
|
+
this.searchHasMore = false
|
|
408
|
+
this.searchPending = query !== ''
|
|
409
|
+
if (query) {
|
|
410
|
+
this.searchTimer = setTimeout(() => this.fetchSearch(0), SEARCH_DEBOUNCE_MS)
|
|
411
|
+
}
|
|
412
|
+
},
|
|
275
413
|
},
|
|
276
414
|
|
|
277
415
|
mounted() {
|
|
278
416
|
this.fetchPage(0)
|
|
279
417
|
},
|
|
280
418
|
|
|
419
|
+
beforeUnmount() {
|
|
420
|
+
clearTimeout(this.searchTimer)
|
|
421
|
+
},
|
|
422
|
+
|
|
281
423
|
methods: {
|
|
282
424
|
t,
|
|
283
425
|
|
|
@@ -292,32 +434,98 @@ export default {
|
|
|
292
434
|
},
|
|
293
435
|
|
|
294
436
|
/**
|
|
295
|
-
*
|
|
437
|
+
* Whether a standard field line shows under `showFields`.
|
|
438
|
+
*
|
|
439
|
+
* @param {string} field the field name.
|
|
440
|
+
* @return {boolean} true when it shows.
|
|
441
|
+
*/
|
|
442
|
+
shows(field) {
|
|
443
|
+
return this.showFields === null || this.showFields[field] === true
|
|
444
|
+
},
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The custom profile fields of a user that have values and are not
|
|
448
|
+
* switched off in `showFields`.
|
|
449
|
+
*
|
|
450
|
+
* @param {object} user the user record.
|
|
451
|
+
* @return {object[]} the fields.
|
|
452
|
+
*/
|
|
453
|
+
customFieldsOf(user) {
|
|
454
|
+
if (!Array.isArray(user.customFields)) {
|
|
455
|
+
return []
|
|
456
|
+
}
|
|
457
|
+
return user.customFields.filter((field) => field
|
|
458
|
+
&& Array.isArray(field.values)
|
|
459
|
+
&& field.values.length > 0
|
|
460
|
+
&& !(this.showFields && this.showFields[field.key] === false))
|
|
461
|
+
},
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Whether a tag holds the current query, for highlighting.
|
|
465
|
+
*
|
|
466
|
+
* @param {string} tag the tag.
|
|
467
|
+
* @return {boolean} true when it matches.
|
|
468
|
+
*/
|
|
469
|
+
tagMatches(tag) {
|
|
470
|
+
const query = (this.search || '').trim().toLowerCase()
|
|
471
|
+
return query.length >= MIN_SERVER_QUERY && String(tag).toLowerCase().includes(query)
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Search for everyone with this tag.
|
|
476
|
+
*
|
|
477
|
+
* @param {string} tag the tag.
|
|
478
|
+
* @return {void}
|
|
479
|
+
*/
|
|
480
|
+
searchTag(tag) {
|
|
481
|
+
this.search = String(tag)
|
|
482
|
+
},
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Append the next page of users or search results.
|
|
296
486
|
*
|
|
297
487
|
* @return {Promise<void>}
|
|
298
488
|
*/
|
|
299
489
|
async loadMore() {
|
|
300
|
-
if (this.loading || !this.
|
|
490
|
+
if (this.loading || !this.canLoadMore) {
|
|
491
|
+
return
|
|
492
|
+
}
|
|
493
|
+
if (this.serverQuery) {
|
|
494
|
+
await this.fetchSearch(this.searchResults.length)
|
|
301
495
|
return
|
|
302
496
|
}
|
|
303
497
|
await this.fetchPage(this.users.length)
|
|
304
498
|
},
|
|
305
499
|
|
|
306
500
|
/**
|
|
307
|
-
*
|
|
501
|
+
* Forget the loaded pages (not the cache).
|
|
308
502
|
*
|
|
309
503
|
* @return {void}
|
|
310
504
|
*/
|
|
311
|
-
|
|
505
|
+
resetPages() {
|
|
312
506
|
this.users = []
|
|
313
507
|
this.total = 0
|
|
314
508
|
this.hasMore = false
|
|
509
|
+
},
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Drop the cache and refetch from the first page.
|
|
513
|
+
*
|
|
514
|
+
* @return {void}
|
|
515
|
+
*/
|
|
516
|
+
forceRefresh() {
|
|
517
|
+
clearPeoplePages(this.cacheKey)
|
|
518
|
+
this.resetPages()
|
|
315
519
|
this.fetchPage(0)
|
|
520
|
+
if (this.serverQuery) {
|
|
521
|
+
this.fetchSearch(0)
|
|
522
|
+
}
|
|
316
523
|
},
|
|
317
524
|
|
|
318
525
|
/**
|
|
319
|
-
* Fetch one page from the configured source
|
|
320
|
-
*
|
|
526
|
+
* Fetch one page from the configured source, or take it from the
|
|
527
|
+
* cache while fresh. A missing source or a fetch failure degrades to
|
|
528
|
+
* the empty / error state without throwing.
|
|
321
529
|
*
|
|
322
530
|
* @param {number} offset the page offset.
|
|
323
531
|
* @return {Promise<void>}
|
|
@@ -327,6 +535,13 @@ export default {
|
|
|
327
535
|
this.users = []
|
|
328
536
|
return
|
|
329
537
|
}
|
|
538
|
+
const cacheKey = this.cacheKey
|
|
539
|
+
const cached = readPeoplePage(cacheKey, offset)
|
|
540
|
+
if (cached) {
|
|
541
|
+
this.applyPage(cached, offset)
|
|
542
|
+
return
|
|
543
|
+
}
|
|
544
|
+
const seq = ++this.pageSeq
|
|
330
545
|
this.loading = true
|
|
331
546
|
this.error = null
|
|
332
547
|
try {
|
|
@@ -335,17 +550,82 @@ export default {
|
|
|
335
550
|
limit: PAGE_SIZE,
|
|
336
551
|
...this.fetchArgs,
|
|
337
552
|
}) || {}
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
553
|
+
if (seq !== this.pageSeq) {
|
|
554
|
+
return
|
|
555
|
+
}
|
|
556
|
+
const page = {
|
|
557
|
+
users: Array.isArray(data.users) ? data.users : [],
|
|
558
|
+
total: data.total,
|
|
559
|
+
hasMore: data.hasMore === true,
|
|
560
|
+
}
|
|
561
|
+
storePeoplePage(cacheKey, offset, page)
|
|
562
|
+
this.applyPage(page, offset)
|
|
342
563
|
} catch (err) {
|
|
564
|
+
if (seq !== this.pageSeq) {
|
|
565
|
+
return
|
|
566
|
+
}
|
|
343
567
|
this.error = err
|
|
344
568
|
if (offset === 0) {
|
|
345
569
|
this.users = []
|
|
346
570
|
}
|
|
347
571
|
} finally {
|
|
348
|
-
this.
|
|
572
|
+
if (seq === this.pageSeq) {
|
|
573
|
+
this.loading = false
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
},
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Put a fetched or cached page into the loaded set.
|
|
580
|
+
*
|
|
581
|
+
* @param {object} page the `{users, total, hasMore}` page.
|
|
582
|
+
* @param {number} offset the page offset.
|
|
583
|
+
* @return {void}
|
|
584
|
+
*/
|
|
585
|
+
applyPage(page, offset) {
|
|
586
|
+
this.error = null
|
|
587
|
+
this.users = offset === 0 ? page.users : this.users.concat(page.users)
|
|
588
|
+
this.total = typeof page.total === 'number' ? page.total : this.users.length
|
|
589
|
+
this.hasMore = page.hasMore
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Fetch one page of directory-wide search results. Never cached; a late
|
|
594
|
+
* answer to an older query is dropped.
|
|
595
|
+
*
|
|
596
|
+
* @param {number} offset the index of the first match.
|
|
597
|
+
* @return {Promise<void>}
|
|
598
|
+
*/
|
|
599
|
+
async fetchSearch(offset) {
|
|
600
|
+
const query = this.serverQuery
|
|
601
|
+
if (!query) {
|
|
602
|
+
return
|
|
603
|
+
}
|
|
604
|
+
const seq = ++this.searchSeq
|
|
605
|
+
this.loading = true
|
|
606
|
+
this.error = null
|
|
607
|
+
try {
|
|
608
|
+
const data = await this.source.searchPeople({
|
|
609
|
+
q: query,
|
|
610
|
+
offset,
|
|
611
|
+
limit: PAGE_SIZE,
|
|
612
|
+
...this.fetchArgs,
|
|
613
|
+
}) || {}
|
|
614
|
+
if (seq !== this.searchSeq) {
|
|
615
|
+
return
|
|
616
|
+
}
|
|
617
|
+
const incoming = Array.isArray(data.users) ? data.users : []
|
|
618
|
+
this.searchResults = offset === 0 ? incoming : this.searchResults.concat(incoming)
|
|
619
|
+
this.searchHasMore = data.hasMore === true
|
|
620
|
+
} catch (err) {
|
|
621
|
+
if (seq === this.searchSeq) {
|
|
622
|
+
this.error = err
|
|
623
|
+
}
|
|
624
|
+
} finally {
|
|
625
|
+
if (seq === this.searchSeq) {
|
|
626
|
+
this.loading = false
|
|
627
|
+
this.searchPending = false
|
|
628
|
+
}
|
|
349
629
|
}
|
|
350
630
|
},
|
|
351
631
|
},
|
|
@@ -404,28 +684,94 @@ export default {
|
|
|
404
684
|
|
|
405
685
|
.cn-people-widget__item {
|
|
406
686
|
display: flex;
|
|
407
|
-
|
|
408
|
-
|
|
687
|
+
flex-direction: column;
|
|
688
|
+
gap: 6px;
|
|
409
689
|
padding: 6px;
|
|
410
690
|
border-radius: var(--border-radius);
|
|
691
|
+
border: 1px solid transparent;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.cn-people-widget--list .cn-people-widget__item {
|
|
695
|
+
flex-direction: row;
|
|
696
|
+
flex-wrap: wrap;
|
|
697
|
+
align-items: center;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
.cn-people-widget__link {
|
|
701
|
+
display: flex;
|
|
702
|
+
gap: 8px;
|
|
703
|
+
align-items: center;
|
|
704
|
+
min-width: 0;
|
|
411
705
|
color: var(--color-main-text);
|
|
412
706
|
text-decoration: none;
|
|
413
|
-
border: 1px solid transparent;
|
|
414
707
|
}
|
|
415
708
|
|
|
416
|
-
.cn-people-widget--
|
|
417
|
-
|
|
709
|
+
.cn-people-widget--list .cn-people-widget__link {
|
|
710
|
+
flex: 1 1 auto;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
.cn-people-widget--card .cn-people-widget__link,
|
|
714
|
+
.cn-people-widget--grid .cn-people-widget__link {
|
|
715
|
+
flex-direction: column;
|
|
716
|
+
text-align: center;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
.cn-people-widget__fields {
|
|
720
|
+
display: flex;
|
|
418
721
|
flex-direction: column;
|
|
722
|
+
gap: 4px;
|
|
723
|
+
min-width: 0;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
.cn-people-widget--card .cn-people-widget__fields {
|
|
727
|
+
align-items: center;
|
|
419
728
|
text-align: center;
|
|
420
729
|
}
|
|
421
730
|
|
|
731
|
+
.cn-people-widget__tags {
|
|
732
|
+
display: flex;
|
|
733
|
+
flex-wrap: wrap;
|
|
734
|
+
gap: 4px;
|
|
735
|
+
margin: 0;
|
|
736
|
+
padding: 0;
|
|
737
|
+
list-style: none;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
.cn-people-widget--card .cn-people-widget__tags {
|
|
741
|
+
justify-content: center;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
.cn-people-widget__tag {
|
|
745
|
+
padding: 0 8px;
|
|
746
|
+
border: 1px solid var(--color-border);
|
|
747
|
+
border-radius: var(--border-radius-pill, 999px);
|
|
748
|
+
background: var(--color-main-background);
|
|
749
|
+
color: var(--color-main-text);
|
|
750
|
+
font-size: 12px;
|
|
751
|
+
line-height: 20px;
|
|
752
|
+
cursor: pointer;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.cn-people-widget__tag:hover,
|
|
756
|
+
.cn-people-widget__tag:focus-visible {
|
|
757
|
+
background: var(--color-background-hover);
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.cn-people-widget__tag--match {
|
|
761
|
+
border-color: var(--color-primary-element);
|
|
762
|
+
background: var(--color-primary-element-light);
|
|
763
|
+
color: var(--color-primary-element-light-text, var(--color-main-text));
|
|
764
|
+
font-weight: 600;
|
|
765
|
+
}
|
|
766
|
+
|
|
422
767
|
.cn-people-widget--card .cn-people-widget__item {
|
|
423
768
|
border: 1px solid var(--color-border);
|
|
424
769
|
background: var(--color-main-background);
|
|
425
770
|
min-height: 200px;
|
|
426
771
|
}
|
|
427
772
|
|
|
428
|
-
.cn-people-widget__item:hover
|
|
773
|
+
.cn-people-widget__item:hover,
|
|
774
|
+
.cn-people-widget__item:focus-within {
|
|
429
775
|
background: var(--color-background-hover);
|
|
430
776
|
border-color: var(--color-border);
|
|
431
777
|
}
|