Trying to make things work better...

This commit is contained in:
Scott Idem
2024-03-26 14:24:35 -04:00
parent 040e1e71e3
commit 4d486a580c
22 changed files with 508 additions and 410 deletions

View File

@@ -1,6 +1,42 @@
<script lang="ts">
/** @type {import('./$types').LayoutData} */
export let data;
export let data: any;
import { onMount } from 'svelte';
import { localStorageStore } from '@skeletonlabs/skeleton';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
// Quickly save the data passed from the parent to the Svelte stores.
$ae_loc = data.ae_loc;
$ae_loc.mod.sponsorships.cfg_id = data.ae_slct.sponsorship_cfg_id;
$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
};
$slct.sponsorship_cfg_id = data.ae_slct.sponsorship_cfg_id;
$slct.sponsorship_cfg_obj = data.ae_slct.sponsorship_cfg_obj;
// We want to loop through all of the data store (ds) key value pairs and set them to localStorage
if (data.ae_ds) {
for (let [key, value] of Object.entries(data.ae_ds)) {
console.log(`ae_ds__ key: ${key}, value:`, value);
localStorageStore(`ae_ds__${key}`, value);
}
}
onMount(() => {
if (data.url.searchParams.get('sponsorship_cfg_id')) {
$ae_loc.mod.sponsorships.cfg_id = data.url.searchParams.get('sponsorship_cfg_id');
$slct.sponsorship_cfg_id = data.url.searchParams.get('sponsorship_cfg_id');
}
});
</script>

View File

@@ -1,23 +1,41 @@
/** @type {import('./$types').LayoutLoad} */
console.log(`ae_sponsorships +layout.ts start`);
import { get } from 'svelte/store';
import { api } from '$lib/api';
import { ae_loc, ae_sess, ae_api, slct, slct_trigger } from '$lib/ae_stores';
import type { key_val } from '$lib/ae_stores';
import { spons_func } from '$lib/ae_sponsorships_functions';
export async function load({ params, parent, url }) { // route
// console.log(`Svelte Sponsorships +layout.ts data.params:`, params);
// console.log(`Svelte Sponsorships +layout.ts data.route:`, route);
// console.log(`Svelte Sponsorships +layout.ts data.url:`, url);
// const { ae_init, root_layout_ts } = await parent();
let data = await parent();
// console.log(`ae_events_badges +layout.ts data:`, data);
data.ae_sponsorships_layout_ts = true;
if (data.ae_loc.account_id) {
} else {
console.log(`The account_id was not found in the data.ae_loc!!!`);
return false;
}
let sponsorship_cfg_id = null;
if (data.ae_loc.site_cfg_json.slct__sponsorship_cfg_id) {
sponsorship_cfg_id = data.ae_loc.site_cfg_json.slct__sponsorship_cfg_id;
// } else if (data.ae_loc.default__sponsorship_cfg_id) {
// sponsorship_cfg_id = data.ae_loc.default__sponsorship_cfg_id;
} else {
console.log(`The sponsorship_cfg_id was not found in the data.ae_loc.site_cfg_json!!!`);
return false;
}
let load_sponsorship_cfg_obj = spons_func.handle_load_ae_obj_id__sponsorship_cfg({api_cfg: data.ae_api, sponsorship_cfg_id: sponsorship_cfg_id, try_cache: false});
data.ae_slct.sponsorship_cfg_id = sponsorship_cfg_id;
data.ae_slct.sponsorship_cfg_obj = await load_sponsorship_cfg_obj;
let ds_code_li = {}; //: key_val; // = ae_loc_tmp.ds;
@@ -45,7 +63,7 @@ export async function load({ params, parent, url }) { // route
ds_type = 'text';
ds_code_li[ds_code] = await api.get_data_store_obj_w_code({
api_cfg: get(ae_api),
api_cfg: data.ae_api,
data_store_code: ds_code,
data_type: ds_type,
log_lvl: 2
@@ -88,7 +106,7 @@ export async function load({ params, parent, url }) { // route
ds_type = 'text';
ds_code_li[ds_code] = await api.get_data_store_obj_w_code({
api_cfg: get(ae_api),
api_cfg: data.ae_api,
data_store_code: ds_code,
data_type: ds_type,
log_lvl: 2
@@ -128,23 +146,31 @@ export async function load({ params, parent, url }) { // route
});
console.log(`ae_ ds_code_li = `, ds_code_li);
let ae_loc_tmp = get(ae_loc);
console.log(`ae_loc = `, ae_loc_tmp);
// let ae_loc_tmp = get(ae_loc);
// console.log(`ae_loc = `, ae_loc_tmp);
let ae_ds_tmp = ae_loc_tmp.ds;
// Merge the new data into the existing data
ae_ds_tmp = {
...ae_ds_tmp,
...ds_code_li,
}
// let ae_ds_tmp = ae_loc_tmp.ds;
// // Merge the new data into the existing data
// // ae_ds_tmp = {
// // ...ae_ds_tmp,
// // ...ds_code_li,
// // }
ae_loc_tmp = {
...ae_loc_tmp,
'ds': ae_ds_tmp,
}
console.log(`ae_loc = `, ae_loc_tmp);
ae_loc.set(ae_loc_tmp);
// // ae_loc_tmp = {
// // ...ae_loc_tmp,
// // 'ds': ae_ds_tmp,
// // }
// // console.log(`ae_loc = `, ae_loc_tmp);
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc_tmp = `, ae_loc_tmp);
// data['ae_loc'] = ae_loc_tmp;
data['ae_ds'] = ds_code_li;
// return data_struct;
return data;
}
// export const prerender = false;
export const prerender = true;

View File

@@ -223,90 +223,90 @@ 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 (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);
// $: if ($slct_trigger == 'load__sponsorship_cfg_obj' && $slct.sponsorship_cfg_id) {
// console.log('Selected Sponsorship Cfg ID:', $slct.sponsorship_cfg_id);
$slct_trigger = null;
// $slct_trigger = null;
$ae_loc.mod.sponsorships.cfg_id = $slct.sponsorship_cfg_id;
// $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});
}
// 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}`);
// 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 = {};
// 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);
}
// // $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);
// // 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, "*");
// // 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';
});
// // 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;
}
// return ae_sponsorship_cfg_obj_get_promise;
// }
// Load the Sponsorship Obj with ID based on the URL param.

View File

@@ -1,10 +1,8 @@
/** @type {import('./$types').PageLoad} */
console.log(`ae_sponsorships +page.ts start`);
export function load() {
return {
ae_sponsorships_page_ts: true,
};
}
// export const prerender = true
// export const prerender = false;
// export const trailingSlash = 'always'; // 'never' | 'always' | 'ignore'

View File

@@ -12,38 +12,67 @@ export async function load({ params, url }) { // route
// console.log(`Svelte Sponsorships layout.ts data = route:`, route);
// console.log(`Svelte Sponsorships layout.ts data = url:`, url);
let ae_loc_tmp = get(ae_loc);
console.log(`ae_loc = `, ae_loc_tmp);
// let ae_loc_tmp = get(ae_loc);
// console.log(`ae_loc = `, ae_loc_tmp);
let ds_code_li: null|key_val = ae_loc_tmp.ds;
console.log(`ae_ ds_code_li = `, ds_code_li);
let ds_code: null|string = null;
let ds_type: null|string = null;
// let ds_code_li: null|key_val = ae_loc_tmp.ds;
// console.log(`ae_ ds_code_li = `, ds_code_li);
// let ds_code: null|string = null;
// let ds_type: null|string = null;
let data_struct = {
ae_init: ae_loc_tmp,
params: params,
sections: [
{ slug: 'new', title: 'New Sponsorship' },
{ slug: 'manage', title: 'Manage' },
{ slug: 'test', title: 'Test' },
],
url: url,
// let data_struct = {
// ae_init: ae_loc_tmp,
// params: params,
// sections: [
// { slug: 'new', title: 'New Sponsorship' },
// { slug: 'manage', title: 'Manage' },
// { slug: 'test', title: 'Test' },
// ],
// url: url,
};
// };
let loading_results = null;
// let loading_results = null;
ds_code = 'hub__page__sponsorships__create_info';
ds_type = 'text';
// loading_results = await handle_get_data_store_obj_w_code({ code: ds_code })
// .then( function (ds_hub_page_sponsorships_create_info_results) {
// if (ds_hub_page_sponsorships_create_info_results) {
// console.log(`ae_ hub__page__sponsorships__create_info = `, ds_hub_page_sponsorships_create_info_results);
// ds_code = 'hub__page__sponsorships__create_info';
// ds_type = 'text';
// // loading_results = await handle_get_data_store_obj_w_code({ code: ds_code })
// // .then( function (ds_hub_page_sponsorships_create_info_results) {
// // if (ds_hub_page_sponsorships_create_info_results) {
// // console.log(`ae_ hub__page__sponsorships__create_info = `, ds_hub_page_sponsorships_create_info_results);
// // // let ae_loc_tmp = get(ae_loc);
// // ds_code_li[ds_code] = ds_hub_page_sponsorships_create_info_results;
// // // ae_loc.set(ae_loc_tmp);
// // // console.log(`ae_loc = `, get(ae_loc));
// // }
// // })
// // .finally(function () {
// // console.log(`ae_ ds_code_li = `, ds_code_li);
// // ae_loc_tmp = {
// // ...ae_loc_tmp,
// // 'ds': ds_code_li,
// // }
// // console.log(`ae_loc_tmp = `, ae_loc_tmp);
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc = `, get(ae_loc));
// // });
// loading_results = await api.get_data_store_obj_w_code({
// api_cfg: get(ae_api),
// data_store_code: ds_code,
// data_type: ds_type,
// log_lvl: 0
// })
// .then( function (ds_results) {
// if (ds_results) {
// console.log(`ae_ Data Store ${ds_code} = `, ds_results);
// // let ae_loc_tmp = get(ae_loc);
// ds_code_li[ds_code] = ds_hub_page_sponsorships_create_info_results;
// ds_code_li[ds_code] = ds_results.text;
// // ae_loc.set(ae_loc_tmp);
// // console.log(`ae_loc = `, get(ae_loc));
@@ -61,77 +90,5 @@ export async function load({ params, url }) { // route
// console.log(`ae_loc = `, get(ae_loc));
// });
loading_results = await api.get_data_store_obj_w_code({
api_cfg: get(ae_api),
data_store_code: ds_code,
data_type: ds_type,
log_lvl: 0
})
.then( function (ds_results) {
if (ds_results) {
console.log(`ae_ Data Store ${ds_code} = `, ds_results);
// let ae_loc_tmp = get(ae_loc);
ds_code_li[ds_code] = ds_results.text;
// ae_loc.set(ae_loc_tmp);
// console.log(`ae_loc = `, get(ae_loc));
}
})
.finally(function () {
console.log(`ae_ ds_code_li = `, ds_code_li);
ae_loc_tmp = {
...ae_loc_tmp,
'ds': ds_code_li,
}
console.log(`ae_loc_tmp = `, ae_loc_tmp);
ae_loc.set(ae_loc_tmp);
console.log(`ae_loc = `, get(ae_loc));
});
return data_struct;
// return data_struct;
}
// async function handle_get_data_store_obj_w_code({ code=null, data_type='text' }) {
// console.log(`*** handle_get_data_store_obj_w_code() *** code=${code}`);
// if (!code) {
// console.log('No code provided.');
// return;
// }
// let data_store_obj_get_promise = api.get_data_store_obj_w_code({
// api_cfg: get(ae_api),
// data_store_code: code,
// data_type: data_type,
// log_lvl: 0
// })
// .then(function (get_data_store_result) {
// let return_this = null;
// if (get_data_store_result) {
// if (data_type == 'text') {
// // console.log(get_data_store_result.text);
// return_this = get_data_store_result.text;
// } else if (data_type == 'json') {
// // console.log(get_data_store_result.json);
// return_this = get_data_store_result.json;
// }
// } else {
// console.log('No results returned.');
// return_this = null;
// }
// return return_this;
// })
// .catch(function (error) {
// console.log('No results returned or failed.', error);
// });
// return data_store_obj_get_promise;
// }