Skip to content

Commit f398583

Browse files
Merge pull request #2562 from IFRCGo/feature/admin-page-to-query-users
Better search for User groups – worldwise
2 parents 1b563c0 + e406b96 commit f398583

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

api/templates/admin/users_per_permission.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,19 @@
9797
}
9898

9999
function renderOptions(query) {
100-
const q = (query || '').toLowerCase();
101-
const filtered = allOptions.filter(o => o.selected || o.textLower.includes(q));
100+
const tokens = String(query || '')
101+
.toLowerCase()
102+
.trim()
103+
.split(/\s+/) // split by any whitespace
104+
.filter(Boolean); // remove empty tokens
105+
106+
const filtered = allOptions.filter(o => {
107+
if (o.selected) return true; // always keep selected visible
108+
if (tokens.length === 0) return true; // no filter -> show all
109+
// match if ALL tokens are contained in the label (order-independent)
110+
return tokens.every(t => o.textLower.includes(t));
111+
});
112+
102113
// Rebuild options while preserving selection
103114
selectEl.innerHTML = '';
104115
for (const o of filtered) {

0 commit comments

Comments
 (0)