General code clean up related to the person functions. Less direct use of params and params_json
This commit is contained in:
@@ -100,7 +100,7 @@ export async function load_ae_obj_li__person(
|
||||
limit = 99,
|
||||
offset = 0,
|
||||
order_by_li = {'family_name': 'ASC', 'given_name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'},
|
||||
params_json = {},
|
||||
// params_json = {},
|
||||
params = {},
|
||||
try_cache = true,
|
||||
log_lvl = 0
|
||||
@@ -115,7 +115,7 @@ export async function load_ae_obj_li__person(
|
||||
limit?: number,
|
||||
offset?: number,
|
||||
order_by_li?: key_val,
|
||||
params_json?: null|key_val,
|
||||
// params_json?: null|key_val,
|
||||
params?: key_val,
|
||||
try_cache?: boolean,
|
||||
log_lvl?: number
|
||||
@@ -125,17 +125,21 @@ export async function load_ae_obj_li__person(
|
||||
console.log(`*** load_ae_obj_li__person() *** for_obj_type=${for_obj_type} for_obj_id=${for_obj_id} enabled=${enabled} hidden=${hidden} limit=${limit} offset=${offset}`);
|
||||
}
|
||||
|
||||
let params_json: key_val = {};
|
||||
|
||||
// console.log('params_json:', params_json);
|
||||
if (qry_user_id) {
|
||||
// params_json['and_qry'] = {};
|
||||
// params_json['and_qry']['user_id_random'] = qry_user_id;
|
||||
|
||||
params_json['qry'] = []
|
||||
|
||||
let qry_param =
|
||||
{
|
||||
type: "AND",
|
||||
field: "person_id_random",
|
||||
field: "user_id_random",
|
||||
operator: "=",
|
||||
value: qry_person_id
|
||||
value: qry_user_id
|
||||
};
|
||||
params_json['qry'].push(qry_param);
|
||||
}
|
||||
|
||||
@@ -506,25 +506,26 @@ async function handle_change_password() {
|
||||
|
||||
// Next we need to get the person's information. This is odd because we need to look it up based on the account_id and user_id. There should only be one account person record per user. 99% of the time the user's account ID will be the same as the person's account ID. The exception is for AE Global users (Super or Manager) who can have multiple accounts but only one person record per account.
|
||||
|
||||
let params = {
|
||||
user_id_random: user_id, // The user_id_random from the above authentication
|
||||
}
|
||||
// let params = {
|
||||
// user_id_random: user_id, // The user_id_random from the above authentication
|
||||
// }
|
||||
|
||||
let params_json: key_val = {};
|
||||
// let params_json: key_val = {};
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
// params_json['and_qry'] = {};
|
||||
|
||||
if (user_id) {
|
||||
params_json['and_qry']['user_id_random'] = user_id;
|
||||
}
|
||||
// if (user_id) {
|
||||
// params_json['and_qry']['user_id_random'] = user_id;
|
||||
// }
|
||||
|
||||
// WARNING: This function returns a list. We only want the first one. There should be no more than 1 record returned.
|
||||
ae_promises['person'] = core_func.load_ae_obj_li__person({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $ae_loc.account_id,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
qry_user_id: user_id, // The user_id_random from the above authentication
|
||||
// params_json: params_json,
|
||||
// params: params,
|
||||
log_lvl: 1,
|
||||
}).then((person_response) => {
|
||||
if (person_response[0].person_id_random) {
|
||||
@@ -587,25 +588,26 @@ async function handle_change_password() {
|
||||
|
||||
// Next we need to get the person's information. This is odd because we need to look it up based on the account_id and user_id. There should only be one account person record per user. 99% of the time the user's account ID will be the same as the person's account ID. The exception is for AE Global users (Super or Manager) who can have multiple accounts but only one person record per account.
|
||||
|
||||
let params = {
|
||||
user_id_random: user_id, // The user_id_random from the above authentication
|
||||
}
|
||||
// let params = {
|
||||
// user_id_random: user_id, // The user_id_random from the above authentication
|
||||
// }
|
||||
|
||||
let params_json: key_val = {};
|
||||
// let params_json: key_val = {};
|
||||
|
||||
params_json['and_qry'] = {};
|
||||
// params_json['and_qry'] = {};
|
||||
|
||||
if (user_id) {
|
||||
params_json['and_qry']['user_id_random'] = user_id;
|
||||
}
|
||||
// if (user_id) {
|
||||
// params_json['and_qry']['user_id_random'] = user_id;
|
||||
// }
|
||||
|
||||
// WARNING: This function returns a list. We only want the first one. There should be no more than 1 record returned.
|
||||
ae_promises['person'] = core_func.load_ae_obj_li__person({
|
||||
api_cfg: $ae_api,
|
||||
for_obj_type: 'account',
|
||||
for_obj_id: $ae_loc.account_id,
|
||||
params_json: params_json,
|
||||
params: params,
|
||||
qry_user_id: user_id, // The user_id_random from the above authentication
|
||||
// params_json: params_json,
|
||||
// params: params,
|
||||
log_lvl: 1,
|
||||
}).then((person_response) => {
|
||||
if (person_response[0].person_id_random) {
|
||||
|
||||
Reference in New Issue
Block a user