Wrapping up for the night at 4 AM. Made lots of progress with the Journals module. Should have saved more often.
This commit is contained in:
155
src/routes/journals/+layout.svelte
Normal file
155
src/routes/journals/+layout.svelte
Normal file
@@ -0,0 +1,155 @@
|
||||
<script lang="ts">
|
||||
/** @type {import('./$types').LayoutProps} */
|
||||
let { data, children } = $props();
|
||||
|
||||
// Imports
|
||||
import { browser } from '$app/environment';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import type { key_val } from '$lib/ae_stores';
|
||||
// import { ae_util } from '$lib/ae_utils/ae_utils';
|
||||
// import { api } from '$lib/api';
|
||||
import { ae_loc, ae_sess, ae_api, slct } from '$lib/ae_stores';
|
||||
import { journals_loc, journals_slct, journals_trig } from '$lib/ae_journals/ae_journals_stores';
|
||||
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
|
||||
|
||||
// import Element_data_store from '$lib/element_data_store_v2.svelte';
|
||||
|
||||
$journals_loc.qry__enabled = 'enabled';
|
||||
$journals_loc.qry__hidden = 'not_hidden';
|
||||
$journals_loc.qry__limit = 15;
|
||||
$journals_loc.qry__offset = 0;
|
||||
|
||||
// Quickly save the data passed from the parent(s) to the Svelte stores, localStorage, and other.
|
||||
$slct.account_id = data.account_id;
|
||||
console.log(`$slct.account_id = `, $slct.account_id);
|
||||
let ae_acct = data[$slct.account_id];
|
||||
// console.log(`ae_acct = `, ae_acct);
|
||||
|
||||
// if (browser) {
|
||||
// console.log(`Browser: ${browser}`);
|
||||
// journals_func.handle_db_save_ae_obj_li__journal({
|
||||
// obj_type: 'journal',
|
||||
// obj_li: [ae_acct.slct.journal_obj_li],
|
||||
// });
|
||||
// }
|
||||
|
||||
$journals_slct.journal_id = ae_acct.slct.journal_id;
|
||||
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
|
||||
$journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li;
|
||||
|
||||
let ae_promises: key_val = {};
|
||||
|
||||
|
||||
if (browser) {
|
||||
console.log('AE Journals: +layout.svelte');
|
||||
console.log($journals_slct.journal_obj_li);
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<svelte:head>
|
||||
<title>Journals - {$journals_loc.title ?? 'Æ loading...'}</title>
|
||||
</svelte:head>
|
||||
|
||||
|
||||
<!-- These are needed: h-full overflow-auto -->
|
||||
<div class="ae_journals h-full w-full overflow-auto p-1">
|
||||
|
||||
<nav class="submenu flex flex-row items-centr justify-center gap-1">
|
||||
<a href="/" class="btn btn-sm variant-ghost-success hover:variant-filled-success">Home</a>
|
||||
<!-- <a href="/about" class="btn btn-sm">About</a> -->
|
||||
<!-- <a href="/settings" class="btn btn-sm">Settings</a> -->
|
||||
<button
|
||||
|
||||
onclick={() => {
|
||||
|
||||
// Clear the local and session storage. Clearing the localStorage will force it to be re-created.
|
||||
localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
|
||||
// Clear Indexed DB as well
|
||||
indexedDB.deleteDatabase('ae_core_db');
|
||||
indexedDB.deleteDatabase('ae_journals_db');
|
||||
|
||||
// This does not seem to work fast enough or something?
|
||||
goto('/', {invalidateAll: true});
|
||||
|
||||
// The page does usually seem to reload correctly?
|
||||
window.location.reload(true); // true only works with Firefox
|
||||
// alert('Local and Session Storage cleared and Indexed DBs deleted. You will probably want to refresh the page.');
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-success hover:variant-filled-success"
|
||||
title="Clear App Data & Settings - Reload: Clear the browser storage for this site"
|
||||
>
|
||||
<!-- <span class="fas fa-eraser mx-1"></span> -->
|
||||
<span class="fas fa-sync mx-1"></span>
|
||||
Clear & Reload
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
|
||||
{#if $ae_loc.administrator_access && 1==2}
|
||||
<nav
|
||||
class="submenu flex flex-row justify-center"
|
||||
class:hidden={$ae_loc.iframe}
|
||||
>
|
||||
|
||||
<span class="btn-group variant-soft-secondary px-4 py-2">
|
||||
{#each Object.entries(data.submenu) as [key, item]}
|
||||
<!-- <a href="/settings/{item.slug}">{item.title}</a> -->
|
||||
<!-- class:hidden={!$ae_loc.trusted_access && item.access} -->
|
||||
{#if item.disable}
|
||||
<button
|
||||
title={item.title}
|
||||
class="hover:variant-ghost-secondary"
|
||||
class:hidden={(!$ae_loc.trusted_access && item.access === 'trusted') || (!$ae_loc.administrator_access && item.access === 'administrator' || item.hide)}
|
||||
disabled={item.disable}
|
||||
|
||||
onclick={() => {
|
||||
// window.location(item.href);
|
||||
// href={item.href}
|
||||
// invalidateAll
|
||||
goto(item.href, { });
|
||||
}}
|
||||
>
|
||||
{item.name}
|
||||
</button>
|
||||
{:else}
|
||||
<a
|
||||
href={item.href}
|
||||
title={item.title}
|
||||
class="hover:variant-ghost-secondary"
|
||||
class:hidden={(!$ae_loc.trusted_access && item.access === 'trusted') || (!$ae_loc.administrator_access && item.access === 'administrator' || item.hide)}
|
||||
class:disabled={item.disable}
|
||||
>
|
||||
{item.name}
|
||||
</a>
|
||||
{/if}
|
||||
{/each}
|
||||
</span>
|
||||
|
||||
</nav>
|
||||
{/if}
|
||||
|
||||
|
||||
<section class="status flex flex-col justify-center items-center gap-1">
|
||||
{#if $ae_loc.administrator_access}
|
||||
<h3 class="h4">Administrator Access - Technical Support</h3>
|
||||
<p>You are accessing the journals module with "administrator" level permissions.</p>
|
||||
{:else if $ae_loc.trusted_access}
|
||||
<h3 class="h4">Trusted Access - Staff</h3>
|
||||
<p>You are accessing the journals module with "trusted" level permissions.</p>
|
||||
{:else if !$ae_loc.trusted_access}
|
||||
<h3 class="h4">Restricted Access</h3>
|
||||
<p>You are accessing to the journals module is limited</p>
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
|
||||
<section class="main_content container">
|
||||
{@render children()}
|
||||
</section>
|
||||
|
||||
</div>
|
||||
Reference in New Issue
Block a user