This is the first commit of the day. It is probably the last. Lots of general prep for a demo.

This commit is contained in:
Scott Idem
2024-02-19 18:28:55 -05:00
parent 6f0680f282
commit 3403210efd
10 changed files with 851 additions and 100 deletions

View File

@@ -1,6 +1,6 @@
<script lang="ts">
export let data;
console.log(`page data:`, data);
console.log(`Svelte page data:`, data);
import { onMount } from 'svelte';
@@ -45,29 +45,83 @@ onMount(() => {
// console.log(`$ae_loc.href_url = `, $ae_loc.href_url);
// $ae_loc.mod.sponsorships.show_edit__sponsorship_obj = true;
// Load the Sponsorship Cfg Obj with ID based on the URL param.
$slct.sponsorship_cfg_id = data.url.searchParams.get('sponsorship_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;
handle_load_ae_obj_id__sponsorship_cfg({sponsorship_cfg_id: $slct.sponsorship_cfg_id, try_cache: false});
}
let ae_sponsorship_cfg_obj_get_promise;
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.hub.sponsorship_cfg_id_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: 0
})
.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 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);
});
return ae_sponsorship_cfg_obj_get_promise;
}
// Load the Sponsorship Obj with ID based on the URL param.
$slct.sponsorship_id = data.url.searchParams.get('ae_id');
console.log(data.url.searchParams.get('ae_id'));
console.log(`Selected Sponsorship ID:`, $slct.sponsorship_id);
$slct_trigger = 'load__sponsorship_obj';
$: if ($slct_trigger == 'load__sponsorship_obj' && $slct.sponsorship_id) {
console.log('Selected Sponsorship ID:', $slct.sponsorship_id);
console.log('Selected Sponsorship Object:', $slct.sponsorship_obj);
$slct_trigger = null;
handle_load_ae_sponsorship_id_obj({sponsorship_id: $slct.sponsorship_id, try_cache: false});
handle_load_ae_obj_id__sponsorship({sponsorship_id: $slct.sponsorship_id, try_cache: false});
modalStore.trigger(modal_edit__sponsorship_obj);
}
let ae_sponsorship_obj_get_promise;
async function handle_load_ae_sponsorship_id_obj({sponsorship_id, try_cache=false}) {
console.log('*** handle_load_sponsorship_id_obj() ***');
async function handle_load_ae_obj_id__sponsorship({sponsorship_id, try_cache=false}) {
console.log(`*** handle_load_ae_obj_id__sponsorship() *** sponsorship_id=${sponsorship_id}`);
let params = {};
@@ -79,7 +133,7 @@ async function handle_load_ae_sponsorship_id_obj({sponsorship_id, try_cache=fals
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: 2
log_lvl: 1
})
.then(function (sponsorship_obj_get_result) {
if (sponsorship_obj_get_result) {
@@ -106,7 +160,6 @@ async function handle_load_ae_sponsorship_id_obj({sponsorship_id, try_cache=fals
}
</script>