mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: support search by displayname (#621)
This commit is contained in:
1 parent
28a32869e2
commit
ced52792be
3 files changed
+6
-3
No files matched your search
@@ -399,7 +399,9 @@ class UserModel {
|
|||||||
const $regex = `^${escapeRegExp(prefix.toLowerCase())}`;
|
const $regex = `^${escapeRegExp(prefix.toLowerCase())}`;
|
||||||
const udocs = await coll.find({ unameLower: { $regex } })
|
const udocs = await coll.find({ unameLower: { $regex } })
|
||||||
.limit(limit).project({ _id: 1 }).toArray();
|
.limit(limit).project({ _id: 1 }).toArray();
|
||||||
return await Promise.all(udocs.map(({ _id }) => UserModel.getById(domainId, _id)));
|
const dudocs = await domain.getMultiUserInDomain(domainId, { displayName: { $regex } }).limit(limit).project({ uid: 1 }).toArray();
|
||||||
|
const uids = uniq([...udocs.map(({ _id }) => _id), ...dudocs.map(({ uid }) => uid)]);
|
||||||
|
return await Promise.all(uids.map(({ _id }) => UserModel.getById(domainId, _id)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ArgMethod
|
@ArgMethod
|
||||||
|
|||||||
@@ -36,8 +36,9 @@ function searchUser() {
|
|||||||
$('.enroll_user_menu_item').each((i, e) => {
|
$('.enroll_user_menu_item').each((i, e) => {
|
||||||
const $item = $(e);
|
const $item = $(e);
|
||||||
const $username = $item.data('uname').toString().toLowerCase();
|
const $username = $item.data('uname').toString().toLowerCase();
|
||||||
|
const $displayName = $item.data('displayname')?.toString().toLowerCase();
|
||||||
const $uid = $item.data('uid').toString();
|
const $uid = $item.data('uid').toString();
|
||||||
$item.toggle(($username.includes(val) && (group === 'all' || group.split(',').includes($uid))) || $uid === val);
|
$item.toggle((($displayName?.includes(val) || $username.includes(val)) && (group === 'all' || group.split(',').includes($uid))) || $uid === val);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<ul class="enroll_user_menu">
|
<ul class="enroll_user_menu">
|
||||||
{%- for uid, udoc in udict -%}
|
{%- for uid, udoc in udict -%}
|
||||||
<li class="menu__item enroll_user_menu_item" data-uid="{{ uid }}" data-uname="{{ udoc.uname }}">
|
<li class="menu__item enroll_user_menu_item" data-uid="{{ uid }}" data-uname="{{ udoc.uname }}" {% if handler.user.hasPerm(perm.PREM_VIEW_DISPLAYNAME) and udoc.displayName %}data-displayname="{{ udoc.displayName }}"{% endif %}>
|
||||||
<a href="./{{ tdoc._id }}?uid={{ uid }}" class="menu__link{% if (handler.request.query.uid or handler.user._id) == uid %} active{% endif %}">
|
<a href="./{{ tdoc._id }}?uid={{ uid }}" class="menu__link{% if (handler.request.query.uid or handler.user._id) == uid %} active{% endif %}">
|
||||||
<span class="user-profile-link">
|
<span class="user-profile-link">
|
||||||
<img class="small user-profile-avatar v-center" loading="lazy" src="{{ avatarUrl(udoc.avatar|default('')) }}" width="20" height="20">
|
<img class="small user-profile-avatar v-center" loading="lazy" src="{{ avatarUrl(udoc.avatar|default('')) }}" width="20" height="20">
|
||||||
|
|||||||
Reference in new issue
Block a user