Forgot to save my work earlier...?

This commit is contained in:
Scott Idem
2025-01-15 22:05:41 -05:00
parent 6f11820857
commit 8b309d7b04
4 changed files with 100 additions and 127 deletions

View File

@@ -14,7 +14,7 @@ let ae_promises: key_val = {}; // Promise<any>;
// Updated 2024-03-29
async function handle_load_ae_obj_id__sponsorship_cfg(
async function load_ae_obj_id__sponsorship_cfg(
{
api_cfg,
sponsorship_cfg_id,
@@ -28,7 +28,7 @@ async function handle_load_ae_obj_id__sponsorship_cfg(
}
) {
if (log_lvl) {
console.log(`*** handle_load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
console.log(`*** load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
}
let params = {};
@@ -51,9 +51,9 @@ async function handle_load_ae_obj_id__sponsorship_cfg(
}
if (try_cache) {
// This is expecting a list
db_save_ae_obj_li__sponsorship({
obj_type: 'sponsorship',
obj_li: [sponsorship_obj_get_result]
db_save_ae_obj_li__sponsorship_cfg({
obj_type: 'sponsorship_cfg',
obj_li: [sponsorship_cfg_obj_get_result]
});
}
return sponsorship_cfg_obj_get_result;
@@ -74,6 +74,66 @@ async function handle_load_ae_obj_id__sponsorship_cfg(
}
// Updated 2024-03-29
async function load_ae_obj_id__sponsorship(
{
api_cfg,
sponsorship_id,
try_cache = false,
log_lvl = 0
}: {
api_cfg: any,
sponsorship_id: string,
try_cache: boolean,
log_lvl: number
}
) {
if (log_lvl) {
console.log(`*** load_ae_obj_id__sponsorship() *** sponsorship_id=${sponsorship_id}`);
}
let params = {};
ae_promises.load__sponsorship_obj = api.get_ae_obj_id_crud({
api_cfg: api_cfg,
obj_type: 'sponsorship',
obj_id: sponsorship_id,
use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
params: params,
log_lvl: log_lvl
})
.then(function (sponsorship_obj_get_result) {
if (sponsorship_obj_get_result) {
if (log_lvl) {
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}`);
} else if (log_lvl > 1) {
console.log(`*spons_func* Got a result for sponsorship_id ${sponsorship_id}:`, sponsorship_obj_get_result);
}
if (try_cache) {
// This is expecting a list
db_save_ae_obj_li__sponsorship({
obj_type: 'sponsorship',
obj_li: [sponsorship_obj_get_result]
});
}
return sponsorship_obj_get_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.load__sponsorship_obj:', ae_promises.load__sponsorship_obj);
}
return ae_promises.load__sponsorship_obj;
}
// Updated 2025-01-15
async function load_ae_obj_li__sponsorship(
{
@@ -285,7 +345,8 @@ export function db_save_ae_obj_li__sponsorship(
let export_obj = {
handle_load_ae_obj_id__sponsorship_cfg: handle_load_ae_obj_id__sponsorship_cfg,
load_ae_obj_id__sponsorship_cfg: load_ae_obj_id__sponsorship_cfg,
load_ae_obj_id__sponsorship: load_ae_obj_id__sponsorship,
load_ae_obj_li__sponsorship: load_ae_obj_li__sponsorship,
handle_download_export__sponsorship: handle_download_export__sponsorship,
db_save_ae_obj_li__sponsorship: db_save_ae_obj_li__sponsorship

View File

@@ -5,7 +5,7 @@ import type { key_val } from '../ae_stores';
// li = list
// kv = key value list
// Updated 202-01-15
// Updated 2025-01-15
export interface Sponsorship {
id: string;
// id_random: string;
@@ -74,49 +74,43 @@ export interface Sponsorship {
}
// // Updated 2024-11-13
// export interface Sponsorship_Comment {
// id: string;
// // id_random: string;
// sponsorship_comment_id: string;
// // sponsorship_comment_id_random: string;
// Updated 2025-01-15
export interface Sponsorship_Cfg {
id: string;
// id_random: string;
sponsorship_cfg_id: string;
// sponsorship_cfg_id_random: string;
// sponsorship_id: string;
// // sponsorship_id_random: string;
account_id: string;
// account_id_random: string;
// external_person_id?: null|string; // For IDAA this is the Novi UUID
for_type?: null|string;
for_id?: null|number;
// name: null|string;
// title: null|string;
// // summary?: null|string;
// content?: null|string;
level_li_json?: null|string;
option_li_json?: null|string;
schedule_li_json?: null|string;
// anonymous?: null|boolean;
// full_name?: null|string;
// email?: null|string;
// notify?: null|boolean;
cfg_json?: null|key_val;
// linked_li_json?: null|string;
// cfg_json?: null|key_val;
enable: null|boolean;
hide?: null|boolean;
priority?: null|boolean
sort?: null|number;
group?: null|string;
notes?: null|string;
created_on: Date;
updated_on?: null|Date;
// enable: null|boolean;
// hide?: null|boolean;
// priority?: null|boolean
// sort?: null|number;
// group?: null|string;
// notes?: null|string;
// created_on: Date;
// updated_on?: null|Date;
// // Additional fields for convenience (database views)
// }
// Additional fields for convenience (database views)
}
// Updated 2024-09-25
export class MySubClassedDexie extends Dexie {
// We just tell the typing system this is the case
sponsorship!: Table<Sponsorship>;
// comment!: Table<Sponsorship_Comment>;
cfg!: Table<Sponsorship_Cfg>;
constructor() {
super('ae_sponsorships_db');
@@ -129,7 +123,12 @@ export class MySubClassedDexie extends Dexie {
level_num, level_str, amount,
agree,
enable, hide, priority, sort, group, notes, created_on, updated_on, [updated_on+created_on], [created_on+updated_on]`,
});
cfg: `
id, sponsorship_cfg_id,
account_id,
for_type, for_id`,
});
}
}

View File

@@ -29,7 +29,7 @@ export async function load({ parent }) {
}
// The await at this point seems to be important. If it is in the sponsor function then the data is not available to the layout. - 2024-04-01
let load_sponsorship_cfg_obj = await spons_func.handle_load_ae_obj_id__sponsorship_cfg({
let load_sponsorship_cfg_obj = await spons_func.load_ae_obj_id__sponsorship_cfg({
api_cfg: ae_acct.api,
sponsorship_cfg_id: sponsorship_cfg_id,
try_cache: false,

View File

@@ -243,93 +243,6 @@ async function handle_load_ae_obj_li__sponsorship({account_id, try_cache=true})
}
// Load the Sponsorship Cfg Obj with ID based on the URL param.
// if (data.url.searchParams.get('sponsorship_cfg_id')) {
// $slct.sponsorship_cfg_id = data.url.searchParams.get('sponsorship_cfg_id');
// $slct_trigger = 'load__sponsorship_cfg_obj';
// } else {
// $slct.sponsorship_cfg_id = $ae_loc.mod.sponsorships.cfg_id;
// }
// $slct_trigger = 'load__sponsorship_cfg_obj';
// $: if ($slct_trigger == 'load__sponsorship_cfg_obj' && $slct.sponsorship_cfg_id) {
// console.log('Selected Sponsorship Cfg ID:', $slct.sponsorship_cfg_id);
// $slct_trigger = null;
// $ae_loc.mod.sponsorships.cfg_id = $slct.sponsorship_cfg_id;
// handle_load_ae_obj_id__sponsorship_cfg({sponsorship_cfg_id: $slct.sponsorship_cfg_id, try_cache: false});
// }
// async function handle_load_ae_obj_id__sponsorship_cfg({sponsorship_cfg_id, try_cache=false}) {
// console.log(`*** handle_load_ae_obj_id__sponsorship_cfg() *** sponsorship_cfg_id=${sponsorship_cfg_id}`);
// let params = {};
// // $ae_loc.mod.sponsorships.qry_status = 'loading';
// ae_sponsorship_cfg_obj_get_promise = api.get_ae_obj_id_crud({
// api_cfg: $ae_api,
// obj_type: 'sponsorship_cfg',
// obj_id: sponsorship_cfg_id,
// use_alt_table: false, // NOTE: This will use the table_name_alt value instead of the table_name value in the API config.
// use_alt_base: false, // NOTE: This will use the base_name_alt value instead of the base_name value in the API config.
// params: params,
// log_lvl: 1
// })
// .then(function (sponsorship_cfg_obj_get_result) {
// if (sponsorship_cfg_obj_get_result) {
// $slct.sponsorship_cfg_obj = sponsorship_cfg_obj_get_result;
// console.log(`sponsorship_cfg object:`, $slct.sponsorship_cfg_obj);
// }
// // Auto show the selected sponsorship ID
// // Is this pushState needed here?
// // Set the URL param "sponsorship_cfg_id" to the current sponsorship ID.
// // const url = new URL(location);
// // url.searchParams.set('sponsorship_cfg_id', $slct.sponsorship_cfg_id);
// // history.pushState({}, '', url);
// // Is this postMessage needed here?
// // let message = {'sponsorship_cfg_id': $slct.sponsorship_cfg_id};
// // window.parent.postMessage(message, "*");
// // modalStore.trigger(modal_view__sponsorship_cfg_obj);
// })
// .catch(function (error) {
// console.log('No results returned or failed.', error);
// })
// .finally(function () {
// // For CHOW 2024 only
// $ae_loc.mod.sponsorships.level_guest_max_li = {
// 0: 0,
// 1: 4, // CHOW 2024 - Friend
// 2: 8, // CHOW 2024 - Supporter
// 3: 8, // CHOW 2024 - Advocate
// 4: 8, // CHOW 2024 - Champion
// 5: 8, // CHOW 2024 - Presenting Partner
// 6: 16, // CHOW 2024 - Signature Partner
// 7: 16, // CHOW 2024 - Premier Partner
// };
// // $ae_loc.mod.sponsorships.level_guest_max_li = {
// // '0': 0,
// // '1': 4,
// // '2': 8,
// // '3': 8,
// // '4': 8,
// // '5': 16, // This is a guess for CHOW 2024!!!
// // '6': 16, // This is a guess for CHOW 2024!!!
// // };
// // if ($slct.sponsorship_cfg_obj.info_about_levels) {
// // $slct.sponsorship_cfg_obj.info_about_levels = JSON.parse($slct.sponsorship_cfg_obj.info_about_levels);
// // }
// // $ae_loc.hub.sponsorship_cfg_id_qry_status = 'done';
// });
// return ae_sponsorship_cfg_obj_get_promise;
// }
// Load the Sponsorship Obj with ID based on the URL param.
$: if ($slct_trigger == 'load__sponsorship_obj' && $slct.sponsorship_id) {
console.log('Selected Sponsorship ID:', $slct.sponsorship_id);