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:
@@ -63,6 +63,8 @@ export async function load_ae_obj_id__user({
|
|||||||
// Updated 2026-01-06
|
// Updated 2026-01-06
|
||||||
export async function load_ae_obj_li__user({
|
export async function load_ae_obj_li__user({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
|
for_obj_type = 'account',
|
||||||
|
for_obj_id = null,
|
||||||
qry_str = null,
|
qry_str = null,
|
||||||
enabled = 'enabled',
|
enabled = 'enabled',
|
||||||
hidden = 'not_hidden',
|
hidden = 'not_hidden',
|
||||||
@@ -75,6 +77,8 @@ export async function load_ae_obj_li__user({
|
|||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any;
|
api_cfg: any;
|
||||||
|
for_obj_type?: string;
|
||||||
|
for_obj_id?: string | null;
|
||||||
qry_str?: string | null;
|
qry_str?: string | null;
|
||||||
enabled?: 'enabled' | 'all' | 'not_enabled';
|
enabled?: 'enabled' | 'all' | 'not_enabled';
|
||||||
hidden?: 'hidden' | 'all' | 'not_hidden';
|
hidden?: 'hidden' | 'all' | 'not_hidden';
|
||||||
@@ -88,18 +92,40 @@ export async function load_ae_obj_li__user({
|
|||||||
}): Promise<ae_User[]> {
|
}): Promise<ae_User[]> {
|
||||||
let promise;
|
let promise;
|
||||||
|
|
||||||
if (qry_str) {
|
if (qry_str || for_obj_id) {
|
||||||
const search_query: any = { q: qry_str };
|
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({
|
promise = api.search_ae_obj_v3({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type: 'user',
|
obj_type: 'user',
|
||||||
search_query,
|
search_query,
|
||||||
enabled,
|
order_by_li,
|
||||||
hidden,
|
|
||||||
view,
|
|
||||||
limit,
|
limit,
|
||||||
offset,
|
offset,
|
||||||
order_by_li,
|
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -143,21 +169,26 @@ export async function load_ae_obj_li__user({
|
|||||||
// Updated 2026-01-06
|
// Updated 2026-01-06
|
||||||
export async function create_ae_obj__user({
|
export async function create_ae_obj__user({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
|
account_id,
|
||||||
data_kv,
|
data_kv,
|
||||||
params = {},
|
params = {},
|
||||||
try_cache = true,
|
try_cache = true,
|
||||||
log_lvl = 0
|
log_lvl = 0
|
||||||
}: {
|
}: {
|
||||||
api_cfg: any;
|
api_cfg: any;
|
||||||
|
account_id?: string;
|
||||||
data_kv: key_val;
|
data_kv: key_val;
|
||||||
params?: key_val;
|
params?: key_val;
|
||||||
try_cache?: boolean;
|
try_cache?: boolean;
|
||||||
log_lvl?: number;
|
log_lvl?: number;
|
||||||
}): Promise<ae_User | null> {
|
}): 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({
|
const result = await api.create_ae_obj_v3({
|
||||||
api_cfg,
|
api_cfg,
|
||||||
obj_type: 'user',
|
obj_type: 'user',
|
||||||
fields: data_kv,
|
fields,
|
||||||
params,
|
params,
|
||||||
log_lvl
|
log_lvl
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
loading = true;
|
loading = true;
|
||||||
user_li = await load_ae_obj_li__user({
|
user_li = await load_ae_obj_li__user({
|
||||||
api_cfg: $ae_api,
|
api_cfg: $ae_api,
|
||||||
|
for_obj_id: $ae_loc.account_id,
|
||||||
qry_str: qry_str || null,
|
qry_str: qry_str || null,
|
||||||
enabled: qry_enabled as any,
|
enabled: qry_enabled as any,
|
||||||
log_lvl: 1
|
log_lvl: 1
|
||||||
@@ -36,6 +37,7 @@
|
|||||||
|
|
||||||
await create_ae_obj__user({
|
await create_ae_obj__user({
|
||||||
api_cfg: $ae_api,
|
api_cfg: $ae_api,
|
||||||
|
account_id: $ae_loc.account_id,
|
||||||
data_kv: { username, email, enable: true },
|
data_kv: { username, email, enable: true },
|
||||||
log_lvl: 1
|
log_lvl: 1
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user