From c10abd596e3df818594e36fcdb30f7d1f8d3c2b1 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 10 Jun 2025 14:32:00 -0400 Subject: [PATCH] General code clean up related to the person functions. Less direct use of params and params_json --- src/lib/ae_core/core__person.ts | 12 ++++-- src/lib/e_app_sign_in_out.svelte | 42 ++++++++++--------- src/routes/core/+page.svelte | 20 +++++---- .../[presenter_id]/presenter_view.svelte | 20 +++++---- .../session/[session_id]/session_view.svelte | 14 +++++-- .../ae_comp__event_session_obj_li.svelte | 14 +++++-- 6 files changed, 75 insertions(+), 47 deletions(-) diff --git a/src/lib/ae_core/core__person.ts b/src/lib/ae_core/core__person.ts index a8dd7ee3..b88848f4 100644 --- a/src/lib/ae_core/core__person.ts +++ b/src/lib/ae_core/core__person.ts @@ -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); } diff --git a/src/lib/e_app_sign_in_out.svelte b/src/lib/e_app_sign_in_out.svelte index 85aca3c5..d0ff0474 100644 --- a/src/lib/e_app_sign_in_out.svelte +++ b/src/lib/e_app_sign_in_out.svelte @@ -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) { diff --git a/src/routes/core/+page.svelte b/src/routes/core/+page.svelte index 244e5594..524bb590 100644 --- a/src/routes/core/+page.svelte +++ b/src/routes/core/+page.svelte @@ -47,9 +47,9 @@ let person_id_random_li: string[] = []; on:click={() => { console.log('Edit the POC person for the session.'); - let params = { - qry__limit: $ae_sess.person.qry_limit__people, - } + // let params = { + // qry__limit: $ae_sess.person.qry_limit__people, + // } // $slct.person_obj_li = await core_func.load_ae_obj_li__person({api_cfg: $ae_api, account_id: $slct.account_id, params: params}); @@ -57,7 +57,8 @@ let person_id_random_li: string[] = []; api_cfg: $ae_api, for_obj_type: 'account', for_obj_id: $slct.account_id, - params: params, + limit: $ae_sess.person.qry_limit__people, + // params: params, log_lvl: 1 }) .then(function (load_results) { @@ -172,10 +173,13 @@ let person_id_random_li: string[] = []; api_cfg: $ae_api, for_obj_type: 'account', for_obj_id: $slct.account_id, - params: { - 'qry__enabled': 'enabled', - 'qry__hidden': 'not_hidden', - 'qry__limit': $ae_sess.person.qry_limit__people,}, + enabled: 'enabled', + hidden: 'not_hidden', + limit: $ae_sess.person.qry_limit__people, + // params: { + // 'qry__enabled': 'enabled', + // 'qry__hidden': 'not_hidden', + // 'qry__limit': $ae_sess.person.qry_limit__people,}, log_lvl: 1, }) .then(function (load_results) { diff --git a/src/routes/events/[event_id]/presenter/[presenter_id]/presenter_view.svelte b/src/routes/events/[event_id]/presenter/[presenter_id]/presenter_view.svelte index 8d1d6a4e..035f5210 100644 --- a/src/routes/events/[event_id]/presenter/[presenter_id]/presenter_view.svelte +++ b/src/routes/events/[event_id]/presenter/[presenter_id]/presenter_view.svelte @@ -1195,15 +1195,21 @@ $: if ($lq__event_presenter_obj) { {:else}