Fix resource modal's LDAP-groups autocomplete going empty after first open (#122)
loadLdapGroups()'s cache guard (if (ldapGroupsCache) return;) also skipped the DOM-repopulation step on every call after the first, but #ldap-groups-datalist is rebuilt fresh and empty on every app.modal.open() -- so the "Associated LDAP Groups" tab's group-name autocomplete silently lost all its suggestions starting on the second Add/Edit. Now the fetch stays cached, but the datalist is always repopulated. Verified live: opened the resource modal on Proxy twice in a row, confirmed the datalist has all 17 options both times (would have been 0 on the second open with the old code).
This commit is contained in:
@@ -563,10 +563,15 @@
|
||||
|
||||
var ldapGroupsCache = null;
|
||||
async function loadLdapGroups() {
|
||||
if (ldapGroupsCache) return;
|
||||
try {
|
||||
const res = await app.api.get('group');
|
||||
ldapGroupsCache = res.results;
|
||||
if (!ldapGroupsCache) {
|
||||
const res = await app.api.get('group');
|
||||
ldapGroupsCache = res.results;
|
||||
}
|
||||
// Re-populate every call, not just the first -- #ldap-groups-datalist
|
||||
// is rebuilt fresh (empty) on every app.modal.open(), so returning
|
||||
// early here on a cache hit left the second and later modal opens
|
||||
// with no autocomplete options at all.
|
||||
const $datalist = $('#ldap-groups-datalist');
|
||||
$datalist.empty();
|
||||
for (const cn of ldapGroupsCache) {
|
||||
|
||||
Reference in New Issue
Block a user