feat(core): default User Management to current account context

- Updated load_ae_obj_li__user to support for_obj_id filtering.
- Updated create_ae_obj__user to support account_id for new users.
- Updated User Management page to default to current account_id for listing and creation.
This commit is contained in:
Scott Idem
2026-01-15 14:40:09 -05:00
parent df9e14d896
commit 111c828a04
2 changed files with 40 additions and 7 deletions

View File

@@ -63,6 +63,8 @@ export async function load_ae_obj_id__user({
// Updated 2026-01-06
export async function load_ae_obj_li__user({
api_cfg,
for_obj_type = 'account',
for_obj_id = null,
qry_str = null,
enabled = 'enabled',
hidden = 'not_hidden',
@@ -75,6 +77,8 @@ export async function load_ae_obj_li__user({
log_lvl = 0
}: {
api_cfg: any;
for_obj_type?: string;
for_obj_id?: string | null;
qry_str?: string | null;
enabled?: 'enabled' | 'all' | 'not_enabled';
hidden?: 'hidden' | 'all' | 'not_hidden';
@@ -88,18 +92,40 @@ export async function load_ae_obj_li__user({
}): Promise<ae_User[]> {
let promise;
if (qry_str) {
const search_query: any = { q: qry_str };
if (qry_str || for_obj_id) {
const search_query: any = { and: [] };
if (qry_str) {
search_query.q = qry_str;
}
if (for_obj_id) {
search_query.and.push({
field: `${for_obj_type}_id_random`,
op: 'eq',
value: for_obj_id
});
}
if (enabled === 'enabled') {
search_query.and.push({ field: 'enable', op: 'eq', value: true });
} else if (enabled === 'not_enabled') {
search_query.and.push({ field: 'enable', op: 'eq', value: false });
}
if (hidden === 'hidden') {
search_query.and.push({ field: 'hide', op: 'eq', value: true });
} else if (hidden === 'not_hidden') {
search_query.and.push({ field: 'hide', op: 'eq', value: false });
}
promise = api.search_ae_obj_v3({
api_cfg,
obj_type: 'user',
search_query,
enabled,
hidden,
view,
order_by_li,
limit,
offset,
order_by_li,
log_lvl
});
} else {
@@ -143,21 +169,26 @@ export async function load_ae_obj_li__user({
// Updated 2026-01-06
export async function create_ae_obj__user({
api_cfg,
account_id,
data_kv,
params = {},
try_cache = true,
log_lvl = 0
}: {
api_cfg: any;
account_id?: string;
data_kv: key_val;
params?: key_val;
try_cache?: boolean;
log_lvl?: number;
}): Promise<ae_User | null> {
const fields: key_val = { ...data_kv };
if (account_id) fields.account_id_random = account_id;
const result = await api.create_ae_obj_v3({
api_cfg,
obj_type: 'user',
fields: data_kv,
fields,
params,
log_lvl
});

View File

@@ -14,6 +14,7 @@
loading = true;
user_li = await load_ae_obj_li__user({
api_cfg: $ae_api,
for_obj_id: $ae_loc.account_id,
qry_str: qry_str || null,
enabled: qry_enabled as any,
log_lvl: 1
@@ -36,6 +37,7 @@
await create_ae_obj__user({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: { username, email, enable: true },
log_lvl: 1
});