Finally got things working. Store act odd when being set under layout.ts?

This commit is contained in:
Scott Idem
2024-02-26 21:04:17 -05:00
parent 060c0500d3
commit 9540aefd50
5 changed files with 231 additions and 103 deletions

View File

@@ -60,7 +60,10 @@ console.log($ae_loc, $ae_sess, $ae_api);
import Element_access_type from '$lib/element_access_type.svelte';
export let data;
console.log(`Svelte +Layout page data:`, data);
console.log(`ae_ Svelte +Layout page data:`, data);
// $ae_loc = data;
// const ae_loc_test_store: Writable<string> = localStorageStore('ae_loc_test', {'test': 'This is a test'});
// // Subscribe to the store
@@ -95,7 +98,7 @@ async function handle_get_data_store_obj_w_code({ code=null, data_type='text', t
// localStorage.getItem(code);
// if ($ae_loc_test_store) {
// $ae_loc.hub.ds[code] = $ae_loc_test_store;
// $ae_loc.ds[code] = $ae_loc_test_store;
// } else {
// console.log('Get local storage item miss.');
// }
@@ -111,14 +114,14 @@ async function handle_get_data_store_obj_w_code({ code=null, data_type='text', t
if (data_type == 'text') {
// console.log(get_data_store_result.text);
$ae_loc.hub.ds[code] = get_data_store_result.text;
$ae_loc.ds[code] = get_data_store_result.text;
} else if (data_type == 'json') {
// console.log(get_data_store_result.json);
$ae_loc.hub.ds[code] = get_data_store_result.json;
$ae_loc.ds[code] = get_data_store_result.json;
}
// console.log(`Code: ${$ae_loc.hub.ds[code]}`);
// console.log(`Code:`, $ae_loc.hub.ds[code]);
// console.log(`Code: ${$ae_loc.ds[code]}`);
// console.log(`Code:`, $ae_loc.ds[code]);
if (trigger) {
$slct_trigger = trigger;
@@ -131,11 +134,11 @@ async function handle_get_data_store_obj_w_code({ code=null, data_type='text', t
}
$slct_trigger = 'set_access_code_li';
$: if ($slct_trigger == 'set_access_code_li' && $ae_loc.hub.ds['hub__page__access_code_li_json']) {
console.log(`$ae_loc.hub.ds['hub__page__access_code_li_json'] = `, $ae_loc.hub.ds['hub__page__access_code_li_json']);
$: if ($slct_trigger == 'set_access_code_li' && $ae_loc.ds['hub__page__access_code_li_json']) {
console.log(`$ae_loc.ds['hub__page__access_code_li_json'] = `, $ae_loc.ds['hub__page__access_code_li_json']);
$slct_trigger = null; // Reset the trigger to prevent loops
$ae_loc.page_access_code_li = $ae_loc.hub.ds['hub__page__access_code_li_json'];
$ae_loc.page_access_code_li = $ae_loc.ds['hub__page__access_code_li_json'];
$ae_loc = $ae_loc; // Trigger Svelte just in case
console.log($ae_loc);
}
@@ -214,32 +217,47 @@ $: if ($slct_trigger == 'set_access_code_li' && $ae_loc.hub.ds['hub__page__acces
<!-- App Shell -->
<AppShell>
<AppShell
slotHeader={($ae_loc.iframe ? 'iframe' : '')}
slotFooter={($ae_loc.iframe ? 'iframe' : '')}
>
<svelte:fragment slot="header">
<!-- App Bar -->
<AppBar gridColumns="grid-cols-3" slotDefault="place-self-center" slotTrail="place-content-end">
<svelte:fragment slot="lead">
<a href="/">
&AElig; Home
</a>
{#if $ae_loc.ds['hub__page__appshell_header_lead']}
{@html $ae_loc.ds['hub__page__appshell_header_lead']}
{:else}
<a href="/" class="text-xl">
<span class="fas fa-home"></span> &AElig; Home
</a>
{/if}
</svelte:fragment>
<!-- OSIT's Aether App -->
{@html $ae_loc.hub.ds['hub_site_header']}
{@html $ae_loc.ds['hub__site__appshell_header']}
<svelte:fragment slot="trail">
<!-- <a
class="btn btn-sm variant-ghost-surface"
href="/testing">Testing Page</a> -->
{#if $ae_loc.ds['hub__page__appshell_header_trail']}
{@html $ae_loc.ds['hub__page__appshell_header_trail']}
{:else}
<a
class="btn btn-sm variant-ghost-surface"
href="/testing"
>
Testing X
</a>
<a
class="btn btn-sm variant-ghost-surface"
class:active={$page.url.pathname==='/sponsorships'}
href="/sponsorships">Sponsorships</a>
<a
class="btn btn-sm variant-ghost-surface"
class:active={$page.url.pathname==='/sponsorships'}
href="/sponsorships">Sponsorships</a>
<a
class="btn btn-sm variant-ghost-surface"
class:active={$page.url.pathname==='/events_speakers'}
href="/events_speakers">Speakers</a>
<a
class="btn btn-sm variant-ghost-surface"
class:active={$page.url.pathname==='/events_speakers'}
href="/events_speakers">Speakers</a>
{/if}
</svelte:fragment>
</AppBar>
@@ -284,7 +302,7 @@ $: if ($slct_trigger == 'set_access_code_li' && $ae_loc.hub.ds['hub__page__acces
<svelte:fragment slot="footer">
<div class="flex justify-between space-x-2">
{@html $ae_loc.hub.ds['hub_site_footer']}
{@html $ae_loc.ds['hub__site__appshell_footer']}
</div>
</svelte:fragment>