Main update
This commit is contained in:
@@ -48,6 +48,7 @@
|
||||
username: String(user?.username || ''),
|
||||
display_name: String(user?.display_name || ''),
|
||||
email: String(user?.email || ''),
|
||||
group_dns: Array.isArray(user?.group_dns) ? user.group_dns.map((group) => String(group || '')) : [],
|
||||
search: [
|
||||
String(user?.username || ''),
|
||||
String(user?.display_name || ''),
|
||||
@@ -74,6 +75,35 @@
|
||||
}
|
||||
input.dataset.umPickerBound = '1';
|
||||
|
||||
const syncGroupSelection = (username) => {
|
||||
const normalizedUsername = String(username || '').trim().toLowerCase();
|
||||
host.querySelectorAll('input[name="manual_group_dns[]"]').forEach((checkbox) => {
|
||||
if (!(checkbox instanceof HTMLInputElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.checked = false;
|
||||
});
|
||||
|
||||
if (normalizedUsername === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
const user = normalizedUsers.find((entry) => entry.username.toLowerCase() === normalizedUsername);
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selectedGroups = new Set(user.group_dns);
|
||||
host.querySelectorAll('input[name="manual_group_dns[]"]').forEach((checkbox) => {
|
||||
if (!(checkbox instanceof HTMLInputElement)) {
|
||||
return;
|
||||
}
|
||||
|
||||
checkbox.checked = selectedGroups.has(checkbox.value);
|
||||
});
|
||||
};
|
||||
|
||||
const renderMatches = () => {
|
||||
const needle = input.value.trim().toLowerCase();
|
||||
const matches = normalizedUsers
|
||||
@@ -109,8 +139,17 @@
|
||||
input.value = String(option.dataset.userPickerValue || '');
|
||||
list.hidden = true;
|
||||
list.innerHTML = '';
|
||||
syncGroupSelection(input.value);
|
||||
input.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
});
|
||||
|
||||
input.addEventListener('change', () => {
|
||||
syncGroupSelection(input.value);
|
||||
});
|
||||
|
||||
if (input.value.trim() !== '') {
|
||||
syncGroupSelection(input.value);
|
||||
}
|
||||
});
|
||||
|
||||
if (!host.dataset.umPickerOutsideBound) {
|
||||
|
||||
Reference in New Issue
Block a user