fix(core): improve User Management filtering and scope support
- Updated load_ae_obj_li__user to use search_ae_obj_v3 for complex account OR global filtering. - Fixed zero-results issue by defaulting to 'All' scope (Current Account + Global). - Added visual 'Account' vs 'Global' badges to user cards. - Added 'Scope' selector to User Management page.
This commit is contained in:
@@ -60,11 +60,12 @@ export async function load_ae_obj_id__user({
|
||||
return ae_promises.load__user_obj;
|
||||
}
|
||||
|
||||
// Updated 2026-01-06
|
||||
// Updated 2026-01-15
|
||||
export async function load_ae_obj_li__user({
|
||||
api_cfg,
|
||||
for_obj_type = 'account',
|
||||
for_obj_id = null,
|
||||
include_global = true,
|
||||
qry_str = null,
|
||||
enabled = 'enabled',
|
||||
hidden = 'not_hidden',
|
||||
@@ -79,6 +80,7 @@ export async function load_ae_obj_li__user({
|
||||
api_cfg: any;
|
||||
for_obj_type?: string;
|
||||
for_obj_id?: string | null;
|
||||
include_global?: boolean;
|
||||
qry_str?: string | null;
|
||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||
@@ -92,18 +94,46 @@ export async function load_ae_obj_li__user({
|
||||
}): Promise<ae_User[]> {
|
||||
let promise;
|
||||
|
||||
// Use search if we have a query string OR if we are filtering by account (to support include_global OR logic)
|
||||
if (qry_str || for_obj_id) {
|
||||
const search_query: any = { and: [] };
|
||||
|
||||
|
||||
if (qry_str) {
|
||||
search_query.q = qry_str;
|
||||
}
|
||||
|
||||
// If filtering by account, we might want to include users where account_id is NULL
|
||||
if (for_obj_id) {
|
||||
if (include_global) {
|
||||
search_query.and.push({
|
||||
or: [
|
||||
{
|
||||
field: `${for_obj_type}_id_random`,
|
||||
op: 'eq',
|
||||
value: for_obj_id
|
||||
},
|
||||
{
|
||||
field: `account_id`, // Try direct field name if random doesn't work on backend for user
|
||||
op: 'eq',
|
||||
value: null
|
||||
}
|
||||
]
|
||||
});
|
||||
} else {
|
||||
search_query.and.push({
|
||||
field: `${for_obj_type}_id_random`,
|
||||
op: 'eq',
|
||||
value: for_obj_id
|
||||
});
|
||||
}
|
||||
} else if (include_global && !qry_str) {
|
||||
// If NO account filter AND include_global is requested explicitly (and no qry_str)
|
||||
// we could filter for account_id IS NULL, but usually "all" means everything.
|
||||
// However, the component sets for_obj_id to null for 'global' scope.
|
||||
search_query.and.push({
|
||||
field: `${for_obj_type}_id_random`,
|
||||
field: `account_id`,
|
||||
op: 'eq',
|
||||
value: for_obj_id
|
||||
value: null
|
||||
});
|
||||
}
|
||||
|
||||
@@ -123,6 +153,11 @@ export async function load_ae_obj_li__user({
|
||||
api_cfg,
|
||||
obj_type: 'user',
|
||||
search_query,
|
||||
for_obj_type: for_obj_id ? for_obj_type : undefined,
|
||||
for_obj_id: for_obj_id || undefined,
|
||||
enabled,
|
||||
hidden,
|
||||
view,
|
||||
order_by_li,
|
||||
limit,
|
||||
offset,
|
||||
|
||||
Reference in New Issue
Block a user