style: Apply Prettier formatting with 4-space indentation

Applied consistent code formatting across the project using Prettier, now configured to use 4-space indentation instead of tabs.
This commit is contained in:
Scott Idem
2025-11-18 18:40:50 -05:00
parent 6d1f9989d0
commit 0987cd6ad9
346 changed files with 86645 additions and 84459 deletions

View File

@@ -1,169 +1,175 @@
<script lang="ts">
/** @type {import('./$types').LayoutProps} */
let log_lvl: number = $state(0);
/** @type {import('./$types').LayoutProps} */
let log_lvl: number = $state(0);
let { data, children } = $props();
let { data, children } = $props();
// *** Import Svelte specific
import { goto } from '$app/navigation';
// *** Import Svelte specific
import { goto } from '$app/navigation';
// *** Import other supporting libraries
import { FilePlus, Notebook, SquareLibrary, X } from '@lucide/svelte';
// *** Import other supporting libraries
import { FilePlus, Notebook, SquareLibrary, X } from '@lucide/svelte';
import { liveQuery } from 'dexie';
import { liveQuery } from 'dexie';
import { db_journals } from '$lib/ae_journals/db_journals';
import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores';
import { journals_loc, journals_sess, journals_slct } from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import { db_journals } from '$lib/ae_journals/db_journals';
import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores';
import {
journals_loc,
journals_sess,
journals_slct
} from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import Journal_entry_obj_qry from './../ae_comp__journal_entry_obj_qry.svelte';
import Journal_entry_obj_qry from './../ae_comp__journal_entry_obj_qry.svelte';
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl) {
console.log(`ae_acct = `, ae_acct);
}
});
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl) {
console.log(`ae_acct = `, ae_acct);
}
});
let show_menu__all_journals: boolean = $state(false);
let show_menu__all_journals: boolean = $state(false);
let lq__journal_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
let lq__journal_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
}
}
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
}
}
return results;
})
);
return results;
})
);
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (
JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)
) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
let lq__journal_entry_obj_li = $derived(
liveQuery(async () => {
let results;
let lq__journal_entry_obj_li = $derived(
liveQuery(async () => {
let results;
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
// $journals_sess.entry_li_trigger = false;
let journal_entry_id_random_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
// $journals_sess.entry_li_trigger = false;
let journal_entry_id_random_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
for (let i = 0; i < $journals_sess?.entry_li.length; i++) {
let journal_entry_obj = $journals_sess?.entry_li[i];
let journal_entry_id_random = journal_entry_obj.journal_entry_id_random;
journal_entry_id_random_li.push(journal_entry_id_random);
}
// let journal_entry_id_random_li = tmp_li;
for (let i = 0; i < $journals_sess?.entry_li.length; i++) {
let journal_entry_obj = $journals_sess?.entry_li[i];
let journal_entry_id_random = journal_entry_obj.journal_entry_id_random;
journal_entry_id_random_li.push(journal_entry_id_random);
}
// let journal_entry_id_random_li = tmp_li;
results = await db_journals.journal_entry.bulkGet(journal_entry_id_random_li);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
results = await db_journals.journal_entry
// .orderBy('updated_on')
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
// .sortBy('tmp_sort_2');
.sortBy('updated_on');
// .sortBy('title');
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.and((entry) => entry.category_code === $journals_loc.filter__category_code)
.reverse()
.sortBy('tmp_sort_1');
} else {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
}
results = await db_journals.journal_entry.bulkGet(journal_entry_id_random_li);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
results = await db_journals.journal_entry
// .orderBy('updated_on')
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
// .sortBy('tmp_sort_2');
.sortBy('updated_on');
// .sortBy('title');
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.and((entry) => entry.category_code === $journals_loc.filter__category_code)
.reverse()
.sortBy('tmp_sort_1');
} else {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
}
// Check if results are different than the current session version stored under $journals_slct
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(results)
) {
$journals_slct.journal_entry_obj_li = [...results];
}
// Check if results are different than the current session version stored under $journals_slct
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(results)
) {
$journals_slct.journal_entry_obj_li = [...results];
}
return results;
})
);
return results;
})
);
$effect(() => {
if (log_lvl) {
console.log(`LQ - $lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(
`LQ - $journals_loc.filter__category_code = `,
$journals_loc.filter__category_code
);
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
console.log(`LQ - Using $journals_sess.entry_li to get journal entries.`);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
console.log(
`LQ - Using DESC sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
console.log(`LQ - Using category filter: ${$journals_loc.filter__category_code}`);
} else {
console.log(
`LQ - Using default sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
}
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !==
JSON.stringify(lq__journal_entry_obj_li)
) {
console.log(
`Session slct li stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_entry_obj_li
);
} else {
if (log_lvl > 1) {
console.log(
`Session slct li stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
$effect(() => {
if (log_lvl) {
console.log(`LQ - $lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(
`LQ - $journals_loc.filter__category_code = `,
$journals_loc.filter__category_code
);
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
console.log(`LQ - Using $journals_sess.entry_li to get journal entries.`);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
console.log(
`LQ - Using DESC sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
console.log(`LQ - Using category filter: ${$journals_loc.filter__category_code}`);
} else {
console.log(
`LQ - Using default sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
}
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !==
JSON.stringify(lq__journal_entry_obj_li)
) {
console.log(
`Session slct li stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_entry_obj_li
);
} else {
if (log_lvl > 1) {
console.log(
`Session slct li stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
</script>
<!-- Svelte layout for a Journal ID page and children -->
<section
class="
class="
ae_journals__journal
mx-auto
flex flex-col grow gap-1
@@ -175,8 +181,8 @@
space-y-2
"
>
<div
class="
<div
class="
flex flex-row flex-wrap
gap-1
items-center justify-between
@@ -188,25 +194,25 @@
relative transition-all
"
>
<!-- If middle click then open the all journals page in a new tab. Otherwise show/hide the menu. -->
<button
type="button"
onmousedown={(event) => {
if (event.button === 1) {
// Middle click - open in new tab
// window.open('/journals', '_blank');
window.open('/journals');
// } else {
// // Left click - toggle menu
// event.preventDefault(); // Prevent default middle-click behavior
// show_menu__all_journals = !show_menu__all_journals;
}
}}
onclick={() => {
show_menu__all_journals = !show_menu__all_journals;
}}
class="
>
<!-- If middle click then open the all journals page in a new tab. Otherwise show/hide the menu. -->
<button
type="button"
onmousedown={(event) => {
if (event.button === 1) {
// Middle click - open in new tab
// window.open('/journals', '_blank');
window.open('/journals');
// } else {
// // Left click - toggle menu
// event.preventDefault(); // Prevent default middle-click behavior
// show_menu__all_journals = !show_menu__all_journals;
}
}}
onclick={() => {
show_menu__all_journals = !show_menu__all_journals;
}}
class="
btn btn-sm
preset-tonal-tertiary
preset-outlined-tertiary-600-400
@@ -214,23 +220,23 @@
hover:preset-filled-tertiary-300-700
transition-all
"
title={`View all journals menu: "${$ae_loc?.user?.name}"\nMiddle-click to open in new tab`}
>
<!-- <BookHeart /> -->
<!-- <Library /> -->
{#if show_menu__all_journals}
<X class="text-orange-500" />
{:else}
<SquareLibrary class="text-gray-500" />
{/if}
<span class="hidden md:inline">
Journals
<!-- for {$ae_loc?.user?.name} -->
</span>
</button>
title={`View all journals menu: "${$ae_loc?.user?.name}"\nMiddle-click to open in new tab`}
>
<!-- <BookHeart /> -->
<!-- <Library /> -->
{#if show_menu__all_journals}
<X class="text-orange-500" />
{:else}
<SquareLibrary class="text-gray-500" />
{/if}
<span class="hidden md:inline">
Journals
<!-- for {$ae_loc?.user?.name} -->
</span>
</button>
<div
class="
<div
class="
absolute top-12 left-0
p-4 z-50 w-80
space-y-0.5
@@ -240,11 +246,11 @@
min-w-72
max-w-fit
"
class:hidden={!show_menu__all_journals}
>
<a
href="/journals"
class="
class:hidden={!show_menu__all_journals}
>
<a
href="/journals"
class="
btn btn-sm
preset-tonal-tertiary
preset-outlined-tertiary-600-400
@@ -252,52 +258,53 @@
hover:preset-filled-tertiary-300-700
transition-all
"
title="View all journals for this account: {$ae_loc.account_name}"
>
<!-- <BookHeart /> -->
<!-- <Library /> -->
<SquareLibrary class="text-blue-500" />
<span class=""> All Journals </span>
</a>
title="View all journals for this account: {$ae_loc.account_name}"
>
<!-- <BookHeart /> -->
<!-- <Library /> -->
<SquareLibrary class="text-blue-500" />
<span class=""> All Journals </span>
</a>
<!-- $journals_slct?.journal_id && -->
<!-- List of recent entries here... -->
<!-- $journals_loc.entry_view_history_li -->
{#if $journals_loc.entry_view_history_kv && Object.keys($journals_loc.entry_view_history_kv).length > 0}
<select
bind:value={$journals_slct.journal_entry_id}
onchange={() => {
if ($journals_slct.journal_entry_id) {
goto(
`/journals/${$journals_slct?.journal_id}/entry/${$journals_slct.journal_entry_id}`
);
}
}}
class="
<!-- $journals_slct?.journal_id && -->
<!-- List of recent entries here... -->
<!-- $journals_loc.entry_view_history_li -->
{#if $journals_loc.entry_view_history_kv && Object.keys($journals_loc.entry_view_history_kv).length > 0}
<select
bind:value={$journals_slct.journal_entry_id}
onchange={() => {
if ($journals_slct.journal_entry_id) {
goto(
`/journals/${$journals_slct?.journal_id}/entry/${$journals_slct.journal_entry_id}`
);
}
}}
class="
form-select
w-full
text-sm
border border-neutral-400-600
p-1
"
>
<option value="" disabled selected>
{Object.keys($journals_loc.entry_view_history_kv).length}&times; Recent Entries...
</option>
<!-- loop through each key value -->
{#each Object.entries($journals_loc.entry_view_history_kv).reverse() as [journal_entry_id, journal_entry_obj]}
<option value={journal_entry_obj.id}>
{(journal_entry_obj?.name || journal_entry_obj?.id) ?? 'NONE'}
</option>
{/each}
</select>
{/if}
</div>
>
<option value="" disabled selected>
{Object.keys($journals_loc.entry_view_history_kv).length}&times; Recent
Entries...
</option>
<!-- loop through each key value -->
{#each Object.entries($journals_loc.entry_view_history_kv).reverse() as [journal_entry_id, journal_entry_obj]}
<option value={journal_entry_obj.id}>
{(journal_entry_obj?.name || journal_entry_obj?.id) ?? 'NONE'}
</option>
{/each}
</select>
{/if}
</div>
{#if $journals_slct?.journal_entry_id}
<a
href="/journals/{$journals_slct?.journal_id}"
class="
{#if $journals_slct?.journal_entry_id}
<a
href="/journals/{$journals_slct?.journal_id}"
class="
btn btn-sm
preset-tonal-tertiary
preset-outlined-tertiary-600-400
@@ -305,21 +312,21 @@
hover:preset-filled-tertiary-300-700
transition-all
"
title="View all journal entries for this journal: {$lq__journal_obj?.name}"
>
<Notebook />
<!-- <Bookmark /> -->
<!-- <BookHeart class="m-1" /> -->
<!-- <BookImage class="m-1" /> -->
<!-- <BookOpenText class="m-1" /> -->
<span class="hidden lg:inline">Back:</span>
<span class="font-bold">
{$lq__journal_obj?.name || 'Journal'}
</span>
</a>
{:else}
<!-- Edit Journal button. Creates a modal to edit the journal. -->
<!-- <button
title="View all journal entries for this journal: {$lq__journal_obj?.name}"
>
<Notebook />
<!-- <Bookmark /> -->
<!-- <BookHeart class="m-1" /> -->
<!-- <BookImage class="m-1" /> -->
<!-- <BookOpenText class="m-1" /> -->
<span class="hidden lg:inline">Back:</span>
<span class="font-bold">
{$lq__journal_obj?.name || 'Journal'}
</span>
</a>
{:else}
<!-- Edit Journal button. Creates a modal to edit the journal. -->
<!-- <button
type="button"
onclick={() => {
tmp_journal_obj = {
@@ -347,63 +354,64 @@
Edit Journal
</span>
</button> -->
<Journal_entry_obj_qry {log_lvl} {lq__journal_obj} />
{/if}
<Journal_entry_obj_qry {log_lvl} {lq__journal_obj} />
{/if}
<!-- Add default journal entry -->
<span class="flex flex-row flex-wrap items-center justify-center gap-2">
<!-- <span class="text-sm text-gray-500 hidden md:inline">
<!-- Add default journal entry -->
<span class="flex flex-row flex-wrap items-center justify-center gap-2">
<!-- <span class="text-sm text-gray-500 hidden md:inline">
New entry:
</span> -->
<button
type="button"
onclick={() => {
// $journals_sess.show__modal_new__journal_entry_obj = true;
<button
type="button"
onclick={() => {
// $journals_sess.show__modal_new__journal_entry_obj = true;
let data_kv = {
category_code: null
};
if ($journals_loc.qry__category_code) {
data_kv.category_code = $journals_loc.qry__category_code;
}
$effect(() => {
if (log_lvl) {
console.log('Creating new journal entry with data_kv:', data_kv);
}
});
journals_func
.create_ae_obj__journal_entry({
api_cfg: $ae_api,
journal_id: $lq__journal_obj.journal_id,
data_kv: data_kv,
log_lvl: log_lvl
})
.then((results) => {
$effect(() => {
if (log_lvl) {
console.log('New journal entry created:', results);
}
});
$journals_slct.journal_entry_id = results?.journal_entry_id_random;
// $journals_loc.entry.edit = true;
$journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] = 'current';
// alert(`Journal entry created successfully! ${$journals_slct.journal_entry_id}`);
})
.catch((error) => {
console.error('Error updating journal entry:', error);
alert('Failed to update journal entry.');
})
.finally(() => {
if ($journals_slct.journal_entry_id) {
goto(
`/journals/${$lq__journal_obj?.journal_id}/entry/${$journals_slct.journal_entry_id}`
);
} else {
alert('Failed to create new journal entry.');
}
});
}}
class="
let data_kv = {
category_code: null
};
if ($journals_loc.qry__category_code) {
data_kv.category_code = $journals_loc.qry__category_code;
}
$effect(() => {
if (log_lvl) {
console.log('Creating new journal entry with data_kv:', data_kv);
}
});
journals_func
.create_ae_obj__journal_entry({
api_cfg: $ae_api,
journal_id: $lq__journal_obj.journal_id,
data_kv: data_kv,
log_lvl: log_lvl
})
.then((results) => {
$effect(() => {
if (log_lvl) {
console.log('New journal entry created:', results);
}
});
$journals_slct.journal_entry_id = results?.journal_entry_id_random;
// $journals_loc.entry.edit = true;
$journals_loc.entry.edit_kv[$journals_slct.journal_entry_id] =
'current';
// alert(`Journal entry created successfully! ${$journals_slct.journal_entry_id}`);
})
.catch((error) => {
console.error('Error updating journal entry:', error);
alert('Failed to update journal entry.');
})
.finally(() => {
if ($journals_slct.journal_entry_id) {
goto(
`/journals/${$lq__journal_obj?.journal_id}/entry/${$journals_slct.journal_entry_id}`
);
} else {
alert('Failed to create new journal entry.');
}
});
}}
class="
btn btn-sm
preset-tonal-tertiary
preset-outlined-tertiary-600-400
@@ -411,18 +419,18 @@
hover:preset-filled-tertiary-300-700
transition-all
"
title="Create a new journal entry for this journal: {$lq__journal_obj?.name}"
>
<FilePlus />
<!-- <span class="fas fa-plus m-1"></span> -->
<span class="hidden sm:inline"> New Entry </span>
</button>
</span>
</div>
title="Create a new journal entry for this journal: {$lq__journal_obj?.name}"
>
<FilePlus />
<!-- <span class="fas fa-plus m-1"></span> -->
<span class="hidden sm:inline"> New Entry </span>
</button>
</span>
</div>
<!-- <div class="overflow-auto"> -->
{@render children?.()}
<!-- </div> -->
<!-- <div class="overflow-auto"> -->
{@render children?.()}
<!-- </div> -->
</section>
<!-- {#if $journals_sess.show__modal_edit__journal_obj}

View File

@@ -8,80 +8,80 @@ import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// import { load_ae_obj_id } from '$lib/ae_core/core__crud_generic';
export async function load({ params, parent }) {
const log_lvl: number = 0;
const log_lvl: number = 0;
const data = await parent();
data.log_lvl = log_lvl;
const data = await parent();
data.log_lvl = log_lvl;
const account_id = data.account_id;
const ae_acct = data[account_id];
const account_id = data.account_id;
const ae_acct = data[account_id];
const journal_id = params.journal_id;
if (!journal_id) {
console.log(
`ae_journals journals [journal_id] +page.ts: The journal_id was not found in the params!!!`
);
error(404, {
message: 'Journals - Journal ID not found'
});
}
ae_acct.slct.journal_id = journal_id;
if (log_lvl) {
console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, journal_id);
}
const journal_id = params.journal_id;
if (!journal_id) {
console.log(
`ae_journals journals [journal_id] +page.ts: The journal_id was not found in the params!!!`
);
error(404, {
message: 'Journals - Journal ID not found'
});
}
ae_acct.slct.journal_id = journal_id;
if (log_lvl) {
console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, journal_id);
}
if (browser) {
if (log_lvl) {
console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, journal_id);
}
// Load journal object
// let load_journal_obj = load_ae_obj_id({
// api_cfg: ae_acct.api,
// obj_type: 'journal',
// obj_id: journal_id,
// db_instance: db_journals,
// db_field_li: journal_field_li,
// inc_obj_type_li: ['journal_entry'],
// log_lvl: 2
// });
if (browser) {
if (log_lvl) {
console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, journal_id);
}
// Load journal object
// let load_journal_obj = load_ae_obj_id({
// api_cfg: ae_acct.api,
// obj_type: 'journal',
// obj_id: journal_id,
// db_instance: db_journals,
// db_field_li: journal_field_li,
// inc_obj_type_li: ['journal_entry'],
// log_lvl: 2
// });
const load_journal_obj = await journals_func.load_ae_obj_id__journal({
api_cfg: ae_acct.api,
journal_id: journal_id,
inc_entry_li: true,
enabled: 'enabled',
hidden: 'all', // 'not_hidden' to load only visible entries
limit: 99,
try_cache: true,
log_lvl: log_lvl
});
// .then((results) => {
// if (!results) {
// error(404, {
// message: 'Journals - Journal not found'
// });
// } else {
// // ae_acct.slct.journal_obj = results;
// }
// })
// .catch((err) => {
// console.error(`Error loading journal object:`, err);
// error(500, {
// message: 'Journals - Error loading journal object'
// });
// });
const load_journal_obj = await journals_func.load_ae_obj_id__journal({
api_cfg: ae_acct.api,
journal_id: journal_id,
inc_entry_li: true,
enabled: 'enabled',
hidden: 'all', // 'not_hidden' to load only visible entries
limit: 99,
try_cache: true,
log_lvl: log_lvl
});
// .then((results) => {
// if (!results) {
// error(404, {
// message: 'Journals - Journal not found'
// });
// } else {
// // ae_acct.slct.journal_obj = results;
// }
// })
// .catch((err) => {
// console.error(`Error loading journal object:`, err);
// error(500, {
// message: 'Journals - Error loading journal object'
// });
// });
if (!load_journal_obj) {
error(404, {
message: 'Journals - Journal Entry not found'
});
} else {
ae_acct.slct.load_journal_obj = load_journal_obj;
}
}
if (!load_journal_obj) {
error(404, {
message: 'Journals - Journal Entry not found'
});
} else {
ae_acct.slct.load_journal_obj = load_journal_obj;
}
}
// WARNING: Precaution against shared data between sites.
data[account_id] = ae_acct;
// WARNING: Precaution against shared data between sites.
data[account_id] = ae_acct;
return data;
return data;
}

View File

@@ -1,315 +1,319 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
let log_lvl: number = $state(1);
/** @type {import('./$types').PageData} */
let log_lvl: number = $state(1);
interface Props {
data: any;
}
interface Props {
data: any;
}
let { data }: Props = $props();
let { data }: Props = $props();
// *** Import Svelte specific
import { browser } from '$app/environment';
// import { goto } from '$app/navigation';
// *** Import Svelte specific
import { browser } from '$app/environment';
// import { goto } from '$app/navigation';
// *** Import other supporting libraries
// import {
// ArrowDown01, ArrowDown10, ArrowDownUp,
// BetweenVerticalEnd, BetweenVerticalStart,
// BookHeart, BookImage, Bookmark, BookOpenText, BriefcaseBusiness,
// Check, Copy,
// Expand, Eye, EyeOff,
// Flag, FlagOff, FilePlus, Fingerprint,
// Globe,
// Library,
// MessageSquareWarning, Minus,
// Notebook,
// Pencil, Plus,
// RemoveFormatting,
// SquareLibrary,
// Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
// Tags, Target, ToggleLeft, ToggleRight, Trash2, TypeOutline,
// X
// } from '@lucide/svelte';
// import * as icons from '@lucide/svelte';
// import { Modal } from 'flowbite-svelte';
import { liveQuery } from 'dexie';
// *** Import other supporting libraries
// import {
// ArrowDown01, ArrowDown10, ArrowDownUp,
// BetweenVerticalEnd, BetweenVerticalStart,
// BookHeart, BookImage, Bookmark, BookOpenText, BriefcaseBusiness,
// Check, Copy,
// Expand, Eye, EyeOff,
// Flag, FlagOff, FilePlus, Fingerprint,
// Globe,
// Library,
// MessageSquareWarning, Minus,
// Notebook,
// Pencil, Plus,
// RemoveFormatting,
// SquareLibrary,
// Shapes, Share2, ShieldCheck, ShieldMinus, Siren, Skull,
// Tags, Target, ToggleLeft, ToggleRight, Trash2, TypeOutline,
// X
// } from '@lucide/svelte';
// import * as icons from '@lucide/svelte';
// import { Modal } from 'flowbite-svelte';
import { liveQuery } from 'dexie';
// *** Import Aether specific variables and functions
// import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
// import { core_func } from '$lib/ae_core/ae_core_functions';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { db_journals } from '$lib/ae_journals/db_journals';
import {
journals_loc,
journals_sess,
journals_slct,
journals_prom,
journals_trig
} from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// *** Import Aether specific variables and functions
// import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
// import { core_func } from '$lib/ae_core/ae_core_functions';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import { db_journals } from '$lib/ae_journals/db_journals';
import {
journals_loc,
journals_sess,
journals_slct,
journals_prom,
journals_trig
} from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// import Journal_obj_id_edit from './ae_journals_comp__journal_obj_id_edit.svelte';
import Journal_view from './../ae_comp__journal_obj_id_view.svelte';
// import Journal_page_menu from './session_page_menu.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
// import Journal_obj_id_edit from './ae_journals_comp__journal_obj_id_edit.svelte';
import Journal_view from './../ae_comp__journal_obj_id_view.svelte';
// import Journal_page_menu from './session_page_menu.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
import Journal_entry_obj_li from './../ae_comp__journal_entry_obj_li.svelte';
// import Journal_entry_obj_qry from './../ae_comp__journal_entry_obj_qry.svelte';
import Journal_obj_id_edit from '../ae_comp__journal_obj_id_edit.svelte';
import Journal_entry_obj_li from './../ae_comp__journal_entry_obj_li.svelte';
// import Journal_entry_obj_qry from './../ae_comp__journal_entry_obj_qry.svelte';
import Journal_obj_id_edit from '../ae_comp__journal_obj_id_edit.svelte';
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
// let ae_triggers: key_val = {};
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
// let ae_triggers: key_val = {};
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl > 1) {
console.log(`ae_acct = `, ae_acct);
}
});
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl > 1) {
console.log(`ae_acct = `, ae_acct);
}
});
$inspect(log_lvl, `log_lvl = ${log_lvl}`);
$inspect($journals_slct.journal_id, `$journals_slct.journal_id = ${$journals_slct.journal_id}`);
$inspect(
$journals_slct.journal_entry_id,
`$journals_slct.journal_entry_id = ${$journals_slct.journal_entry_id}`
);
$inspect(log_lvl, `log_lvl = ${log_lvl}`);
$inspect($journals_slct.journal_id, `$journals_slct.journal_id = ${$journals_slct.journal_id}`);
$inspect(
$journals_slct.journal_entry_id,
`$journals_slct.journal_entry_id = ${$journals_slct.journal_entry_id}`
);
// $inspect($journals_slct.journal_entry_id).with((type, val) => {
// if (type === 'update') {
// // debugger; // or `console.trace`, or whatever you want
// console.log('$journals_slct.journal_entry_id updated:', val);
// }
// });
// $inspect($journals_slct.journal_entry_id).with((type, val) => {
// if (type === 'update') {
// // debugger; // or `console.trace`, or whatever you want
// console.log('$journals_slct.journal_entry_id updated:', val);
// }
// });
// For some reason data.params.journal_id (or whatever param) is not being passed to this page when loaded by a link from another page. This seems to be a bug with Svelte or SvelteKit. Hopefully fixed in a future version 5? 2024-11-06
// $journals_slct.journal_id = ae_acct.slct.journal_id;
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
// For some reason data.params.journal_id (or whatever param) is not being passed to this page when loaded by a link from another page. This seems to be a bug with Svelte or SvelteKit. Hopefully fixed in a future version 5? 2024-11-06
// $journals_slct.journal_id = ae_acct.slct.journal_id;
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
$journals_slct.journal_id = ae_acct.slct.journal_id;
$journals_slct.journal_id = ae_acct.slct.journal_id;
$journals_sess.entry_li = [];
$journals_slct.journal_entry_id = null;
$journals_sess.entry_li = [];
$journals_slct.journal_entry_id = null;
let lq__journal_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
let lq__journal_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
}
}
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
}
}
return results;
})
);
return results;
})
);
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (
JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)
) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
let lq__journal_entry_obj_li = $derived(
liveQuery(async () => {
let results;
let lq__journal_entry_obj_li = $derived(
liveQuery(async () => {
let results;
if ($journals_sess.entry_li_trigger && !$journals_sess?.entry_li) {
$journals_sess.entry_li = null;
$journals_sess.entry_li_trigger = false;
}
if ($journals_sess.entry_li_trigger && !$journals_sess?.entry_li) {
$journals_sess.entry_li = null;
$journals_sess.entry_li_trigger = false;
}
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
let journal_entry_id_random_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
let journal_entry_id_random_li = []; // This is to prevent the array from constantly updating and triggering the liveQuery.
for (let i = 0; i < $journals_sess?.entry_li.length; i++) {
let journal_entry_obj = $journals_sess?.entry_li[i];
let journal_entry_id_random = journal_entry_obj.journal_entry_id_random;
journal_entry_id_random_li.push(journal_entry_id_random);
}
// let journal_entry_id_random_li = tmp_li;
for (let i = 0; i < $journals_sess?.entry_li.length; i++) {
let journal_entry_obj = $journals_sess?.entry_li[i];
let journal_entry_id_random = journal_entry_obj.journal_entry_id_random;
journal_entry_id_random_li.push(journal_entry_id_random);
}
// let journal_entry_id_random_li = tmp_li;
results = await db_journals.journal_entry.bulkGet(journal_entry_id_random_li);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
results = await db_journals.journal_entry
// .orderBy('updated_on')
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
// .sortBy('tmp_sort_2');
.sortBy('updated_on');
// .sortBy('title');
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.and((entry) => entry.category_code === $journals_loc.filter__category_code)
.reverse()
.sortBy('tmp_sort_1');
} else {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
}
results = await db_journals.journal_entry.bulkGet(journal_entry_id_random_li);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
results = await db_journals.journal_entry
// .orderBy('updated_on')
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
// .sortBy('tmp_sort_2');
.sortBy('updated_on');
// .sortBy('title');
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.and((entry) => entry.category_code === $journals_loc.filter__category_code)
.reverse()
.sortBy('tmp_sort_1');
} else {
results = await db_journals.journal_entry
.where('journal_id')
.equals($journals_slct?.journal_id ?? '') // null or undefined does not reset things like '' does
.reverse()
.sortBy('tmp_sort_1');
// .sortBy('updated_on');
}
// Check if results are different than the current session version stored under $journals_slct
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(results)
) {
$journals_slct.journal_entry_obj_li = [...results];
}
// Check if results are different than the current session version stored under $journals_slct
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !== JSON.stringify(results)
) {
$journals_slct.journal_entry_obj_li = [...results];
}
return results;
})
);
return results;
})
);
$effect(() => {
if (log_lvl) {
console.log(`LQ - $lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(
`LQ - $journals_loc.filter__category_code = `,
$journals_loc.filter__category_code
);
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
console.log(`LQ - Using $journals_sess.entry_li to get journal entries.`);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
console.log(
`LQ - Using DESC sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
console.log(`LQ - Using category filter: ${$journals_loc.filter__category_code}`);
} else {
console.log(
`LQ - Using default sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
}
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !==
JSON.stringify(lq__journal_entry_obj_li)
) {
console.log(
`Session slct li stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_entry_obj_li
);
} else {
if (log_lvl > 1) {
console.log(
`Session slct li stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
$effect(() => {
if (log_lvl) {
console.log(`LQ - $lq__journal_obj.cfg_json = `, $lq__journal_obj?.cfg_json);
console.log(
`LQ - $journals_loc.filter__category_code = `,
$journals_loc.filter__category_code
);
if ($journals_sess?.entry_li && $journals_sess?.entry_li?.length) {
console.log(`LQ - Using $journals_sess.entry_li to get journal entries.`);
} else if ($lq__journal_obj?.cfg_json?.entry_group_sort === 'DESC') {
console.log(
`LQ - Using DESC sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
} else if (
$journals_loc.filter__category_code &&
$journals_loc.filter__category_code.length > 0
) {
console.log(`LQ - Using category filter: ${$journals_loc.filter__category_code}`);
} else {
console.log(
`LQ - Using default sort for Journal Entry list journal_id: ${$journals_slct?.journal_id}`
);
}
if (
$journals_slct.journal_entry_obj_li &&
JSON.stringify($journals_slct.journal_entry_obj_li) !==
JSON.stringify(lq__journal_entry_obj_li)
) {
console.log(
`Session slct li stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_entry_obj_li
);
} else {
if (log_lvl > 1) {
console.log(
`Session slct li stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
// Trigger doing a basic load of journal entries
// NOTE: Categories are (currently) filtered at the CSS style level.
$effect(() => {
if ($journals_trig.journal_entry_li) {
$journals_trig.journal_entry_li = false;
// Trigger doing a basic load of journal entries
// NOTE: Categories are (currently) filtered at the CSS style level.
$effect(() => {
if ($journals_trig.journal_entry_li) {
$journals_trig.journal_entry_li = false;
// if ($journals_trig?.journal_entry_li.length > 0) {
// $journals_sess.entry_li = $journals_trig.journal_entry_li;
// console.log('TEST TEST TEST');
// return ;
// }
// if ($journals_trig?.journal_entry_li.length > 0) {
// $journals_sess.entry_li = $journals_trig.journal_entry_li;
// console.log('TEST TEST TEST');
// return ;
// }
if (log_lvl) {
console.log(`Triggered: $journals_trig.journal_entry_li`);
}
if (log_lvl) {
console.log(`Triggered: $journals_trig.journal_entry_li`);
}
if ($journals_loc.qry__enabled !== 'all' || $journals_loc.qry__hidden !== 'all') {
if (log_lvl) {
console.log(
`Not set to all for enabled or hidden. Clearing all journal entries to be safe.`
);
console.log(`$journals_loc.qry__enabled = ${$journals_loc.qry__enabled}`);
console.log(`$journals_loc.qry__hidden = ${$journals_loc.qry__hidden}`);
}
let results = db_journals.journal_entry.clear();
if (log_lvl) {
console.log(`Cleared all journal entries in the database.`, results);
}
}
if ($journals_loc.qry__enabled !== 'all' || $journals_loc.qry__hidden !== 'all') {
if (log_lvl) {
console.log(
`Not set to all for enabled or hidden. Clearing all journal entries to be safe.`
);
console.log(`$journals_loc.qry__enabled = ${$journals_loc.qry__enabled}`);
console.log(`$journals_loc.qry__hidden = ${$journals_loc.qry__hidden}`);
}
let results = db_journals.journal_entry.clear();
if (log_lvl) {
console.log(`Cleared all journal entries in the database.`, results);
}
}
$journals_prom.load__journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
api_cfg: $ae_api,
for_obj_type: 'journal',
for_obj_id: $journals_slct.journal_id,
enabled: $journals_loc.qry__enabled,
hidden: $journals_loc.qry__hidden,
limit: $journals_loc.qry__limit,
order_by_li: $journals_loc.qry__order_by_li,
try_cache: true,
log_lvl: log_lvl
});
$journals_prom.load__journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry(
{
api_cfg: $ae_api,
for_obj_type: 'journal',
for_obj_id: $journals_slct.journal_id,
enabled: $journals_loc.qry__enabled,
hidden: $journals_loc.qry__hidden,
limit: $journals_loc.qry__limit,
order_by_li: $journals_loc.qry__order_by_li,
try_cache: true,
log_lvl: log_lvl
}
);
// Should we reset the entry list???
// $journals_sess.entry_li = null;
}
});
// Should we reset the entry list???
// $journals_sess.entry_li = null;
}
});
if (browser) {
let message = { journal_id: $journals_slct?.journal_id ?? null };
window.parent.postMessage(message, '*');
}
if (browser) {
let message = { journal_id: $journals_slct?.journal_id ?? null };
window.parent.postMessage(message, '*');
}
</script>
<svelte:head>
<title>
Æ Journals:
{$lq__journal_obj?.name
? ae_util.shorten_string({
string: $lq__journal_obj?.name,
max_length: 20,
begin_length: 10,
end_length: 4
})
: ''}
- {$ae_loc?.title}
</title>
<title>
Æ Journals:
{$lq__journal_obj?.name
? ae_util.shorten_string({
string: $lq__journal_obj?.name,
max_length: 20,
begin_length: 10,
end_length: 4
})
: ''}
- {$ae_loc?.title}
</title>
</svelte:head>
{#if $ae_loc.person_id == $lq__journal_obj?.person_id}
<!-- Svelte Page for a Journal ID page -->
<!-- <section
<!-- Svelte Page for a Journal ID page -->
<!-- <section
class="
ae_journals__journal
container h-full mx-auto
@@ -321,27 +325,27 @@
"
> -->
<Journal_view {lq__journal_obj} {lq__journal_entry_obj_li} />
<Journal_view {lq__journal_obj} {lq__journal_entry_obj_li} />
{#if $lq__journal_entry_obj_li && $lq__journal_entry_obj_li?.length}
<Journal_entry_obj_li {lq__journal_obj} {lq__journal_entry_obj_li} />
{:else}
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center">
<p>No journal entry available to show.</p>
</section>
{/if}
{#if $lq__journal_entry_obj_li && $lq__journal_entry_obj_li?.length}
<Journal_entry_obj_li {lq__journal_obj} {lq__journal_entry_obj_li} />
{:else}
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center">
<p>No journal entry available to show.</p>
</section>
{/if}
<!-- </section> -->
<!-- </section> -->
<!-- Modal: Journal edit ID -->
<!-- tmp__journal_obj={$journals_slct.journal_obj} -->
<Journal_obj_id_edit
{log_lvl}
{lq__journal_obj}
show={$journals_sess.show__modal_edit__journal_obj}
/>
<!-- Modal: Journal edit ID -->
<!-- tmp__journal_obj={$journals_slct.journal_obj} -->
<Journal_obj_id_edit
{log_lvl}
{lq__journal_obj}
show={$journals_sess.show__modal_edit__journal_obj}
/>
{:else}
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center">
<p class="text-center">You must be logged in as the owner to view this Journal.</p>
</section>
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center">
<p class="text-center">You must be logged in as the owner to view this Journal.</p>
</section>
{/if}

View File

@@ -6,69 +6,69 @@ import { browser } from '$app/environment';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
export async function load({ params, parent }) {
// route
// let log_lvl: number = 1;
// let data = await parent();
// data.log_lvl = log_lvl;
// let account_id = data.account_id;
// let ae_acct = data[account_id];
// let journal_id = params.journal_id;
// if (!journal_id) {
// console.log(`ae_journals journals [journal_id] +page.ts: The journal_id was not found in the params!!!`);
// error(404, {
// message: 'Journals - Journal ID not found'
// });
// }
// ae_acct.slct.journal_id = journal_id;
// console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, ae_acct.slct.journal_id);
// if (browser) {
// if (log_lvl) {
// console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, journal_id);
// }
// // Load event journal object
// let load_journal_obj = journals_func.load_ae_obj_id__journal({
// api_cfg: ae_acct.api,
// journal_id: journal_id,
// inc_entry_li: true,
// try_cache: true,
// log_lvl: log_lvl
// });
// ae_acct.slct.journal_obj = load_journal_obj;
// Load journal entries for the journal
// let load_journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
// api_cfg: ae_acct.api,
// for_obj_type: 'journal',
// for_obj_id: journal_id,
// params: {qry__enabled: 'all', qry__limit: 99},
// try_cache: true
// })
// .then((journal_entry_obj_li) => {
// if (log_lvl) {
// console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
// }
// for (let index = 0; index < journal_entry_obj_li.length; index++) {
// let journal_entry_obj = journal_entry_obj_li[index];
// let journal_entry_id = journal_entry_obj.journal_entry_id_random;
// let load_journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
// api_cfg: ae_acct.api,
// for_obj_type: 'journal_entry',
// for_obj_id: journal_entry_id,
// params: {qry__enabled: 'all', qry__limit: 15},
// try_cache: true
// });
// if (log_lvl) {
// console.log(`load_journal_entry_obj_li = `, load_journal_entry_obj_li);
// }
// journal_entry_obj_li[index].journal_entry_li = load_journal_entry_obj_li;
// }
// return journal_entry_obj_li;
// });
// if (log_lvl) {
// console.log(`load_journal_entry_obj_li = `, load_journal_entry_obj_li);
// }
// ae_acct.slct.journal_entry_obj_li = load_journal_entry_obj_li;
// }
// WARNING: Precaution against shared data between sites.
// data[account_id] = ae_acct;
// return data;
// route
// let log_lvl: number = 1;
// let data = await parent();
// data.log_lvl = log_lvl;
// let account_id = data.account_id;
// let ae_acct = data[account_id];
// let journal_id = params.journal_id;
// if (!journal_id) {
// console.log(`ae_journals journals [journal_id] +page.ts: The journal_id was not found in the params!!!`);
// error(404, {
// message: 'Journals - Journal ID not found'
// });
// }
// ae_acct.slct.journal_id = journal_id;
// console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, ae_acct.slct.journal_id);
// if (browser) {
// if (log_lvl) {
// console.log(`ae_journals journals [journal_id] +page.ts: journal_id = `, journal_id);
// }
// // Load event journal object
// let load_journal_obj = journals_func.load_ae_obj_id__journal({
// api_cfg: ae_acct.api,
// journal_id: journal_id,
// inc_entry_li: true,
// try_cache: true,
// log_lvl: log_lvl
// });
// ae_acct.slct.journal_obj = load_journal_obj;
// Load journal entries for the journal
// let load_journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
// api_cfg: ae_acct.api,
// for_obj_type: 'journal',
// for_obj_id: journal_id,
// params: {qry__enabled: 'all', qry__limit: 99},
// try_cache: true
// })
// .then((journal_entry_obj_li) => {
// if (log_lvl) {
// console.log(`journal_entry_obj_li = `, journal_entry_obj_li);
// }
// for (let index = 0; index < journal_entry_obj_li.length; index++) {
// let journal_entry_obj = journal_entry_obj_li[index];
// let journal_entry_id = journal_entry_obj.journal_entry_id_random;
// let load_journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({
// api_cfg: ae_acct.api,
// for_obj_type: 'journal_entry',
// for_obj_id: journal_entry_id,
// params: {qry__enabled: 'all', qry__limit: 15},
// try_cache: true
// });
// if (log_lvl) {
// console.log(`load_journal_entry_obj_li = `, load_journal_entry_obj_li);
// }
// journal_entry_obj_li[index].journal_entry_li = load_journal_entry_obj_li;
// }
// return journal_entry_obj_li;
// });
// if (log_lvl) {
// console.log(`load_journal_entry_obj_li = `, load_journal_entry_obj_li);
// }
// ae_acct.slct.journal_entry_obj_li = load_journal_entry_obj_li;
// }
// WARNING: Precaution against shared data between sites.
// data[account_id] = ae_acct;
// return data;
}

View File

@@ -1,283 +1,295 @@
<script lang="ts">
/** @type {import('./$types').PageData} */
let log_lvl: number = $state(1);
/** @type {import('./$types').PageData} */
let log_lvl: number = $state(1);
// *** Import Svelte specific
import { browser } from '$app/environment';
// *** Import Svelte specific
import { browser } from '$app/environment';
// *** Import other supporting libraries
// import { Modal } from 'flowbite-svelte';
import { liveQuery } from 'dexie';
// *** Import other supporting libraries
// import { Modal } from 'flowbite-svelte';
import { liveQuery } from 'dexie';
// *** Import Aether specific variables and functions
// import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
// import { core_func } from '$lib/ae_core/ae_core_functions';
import { db_journals } from '$lib/ae_journals/db_journals';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import {
journals_loc,
journals_sess,
journals_slct,
journals_prom,
journals_trig
} from '$lib/ae_journals/ae_journals_stores';
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// *** Import Aether specific variables and functions
// import type { key_val } from '$lib/ae_stores';
import { ae_util } from '$lib/ae_utils/ae_utils';
// import { core_func } from '$lib/ae_core/ae_core_functions';
import { db_journals } from '$lib/ae_journals/db_journals';
import {
ae_snip,
ae_loc,
ae_sess,
ae_api,
ae_trig,
slct,
slct_trigger
} from '$lib/stores/ae_stores';
import {
journals_loc,
journals_sess,
journals_slct,
journals_prom,
journals_trig
} from '$lib/ae_journals/ae_journals_stores';
// import { journals_func } from '$lib/ae_journals/ae_journals_functions';
// import Journal_entry_obj_id_edit from './ae_journals_comp__journal_entry_obj_id_edit.svelte';
import Journal_entry_view from './../../../ae_comp__journal_entry_obj_id_view.svelte';
// import Journal_page_menu from './session_page_menu.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
// import Journal_entry_obj_id_edit from './ae_journals_comp__journal_entry_obj_id_edit.svelte';
import Journal_entry_view from './../../../ae_comp__journal_entry_obj_id_view.svelte';
// import Journal_page_menu from './session_page_menu.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
interface Props {
data: any;
}
interface Props {
data: any;
}
let { data }: Props = $props();
let { data }: Props = $props();
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
// let ae_triggers: key_val = {};
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
// let ae_triggers: key_val = {};
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl) {
console.log(`ae_acct = `, ae_acct);
}
});
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
$effect(() => {
if (log_lvl) {
console.log(`ae_acct = `, ae_acct);
}
});
$journals_slct.journal_id = ae_acct.slct.journal_id;
let lq__journal_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
$journals_slct.journal_id = ae_acct.slct.journal_id;
let lq__journal_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal.get($journals_slct?.journal_id ?? ''); // null or undefined does not reset things like '' does
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
}
}
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_obj && results) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(results)) {
$journals_slct.journal_obj = { ...results };
}
}
return results;
})
);
return results;
})
);
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`);
console.log(`lq__journal_obj: results = `, lq__journal_obj);
if ($journals_slct.journal_obj && lq__journal_obj) {
if (
JSON.stringify($journals_slct.journal_obj) !== JSON.stringify(lq__journal_obj)
) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_id}`,
$journals_slct.journal_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_id}`
);
}
}
}
});
let lq__journal_obj_li = $derived(
liveQuery(async () => {
let results = await db_journals.journal
.where('person_id')
.equals($ae_loc.person_id)
.reverse()
.sortBy('tmp_sort_2');
let lq__journal_obj_li = $derived(
liveQuery(async () => {
let results = await db_journals.journal
.where('person_id')
.equals($ae_loc.person_id)
.reverse()
.sortBy('tmp_sort_2');
// Check if results are different than the current session version stored under $journals_slct
if (
$journals_slct.journal_obj_li &&
JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(results)
) {
$journals_slct.journal_obj_li = [...results];
}
// Check if results are different than the current session version stored under $journals_slct
if (
$journals_slct.journal_obj_li &&
JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(results)
) {
$journals_slct.journal_obj_li = [...results];
}
return results;
})
);
return results;
})
);
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj_li: person_id = ${$ae_loc.person_id}`);
console.log(`lq__journal_obj_li: results = `, lq__journal_obj_li);
if (
$journals_slct.journal_obj_li &&
JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(lq__journal_obj_li)
) {
console.log(
`Session slct li stored version has changed for ID = ${$ae_loc.person_id}`,
$journals_slct.journal_obj_li
);
} else {
if (log_lvl > 1) {
console.log(
`Session slct li stored version has not changed for ID = ${$ae_loc.person_id}`
);
}
}
}
});
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_obj_li: person_id = ${$ae_loc.person_id}`);
console.log(`lq__journal_obj_li: results = `, lq__journal_obj_li);
if (
$journals_slct.journal_obj_li &&
JSON.stringify($journals_slct.journal_obj_li) !== JSON.stringify(lq__journal_obj_li)
) {
console.log(
`Session slct li stored version has changed for ID = ${$ae_loc.person_id}`,
$journals_slct.journal_obj_li
);
} else {
if (log_lvl > 1) {
console.log(
`Session slct li stored version has not changed for ID = ${$ae_loc.person_id}`
);
}
}
}
});
// For some reason data.params.journal_entry_id (or whatever param) is not being passed to this page when loaded by a link from another page. This seems to be a bug with Svelte or SvelteKit. Hopefully fixed in a future version 5? 2024-11-06
$journals_slct.journal_entry_id = ae_acct.slct.journal_entry_id;
// $journals_slct.journal_entry_obj = ae_acct.slct.journal_entry_obj;
// For some reason data.params.journal_entry_id (or whatever param) is not being passed to this page when loaded by a link from another page. This seems to be a bug with Svelte or SvelteKit. Hopefully fixed in a future version 5? 2024-11-06
$journals_slct.journal_entry_id = ae_acct.slct.journal_entry_id;
// $journals_slct.journal_entry_obj = ae_acct.slct.journal_entry_obj;
let lq__journal_entry_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal_entry.get($journals_slct.journal_entry_id ?? ''); // null or undefined does not reset things like '' does
let lq__journal_entry_obj = $derived(
liveQuery(async () => {
let results = await db_journals.journal_entry.get(
$journals_slct.journal_entry_id ?? ''
); // null or undefined does not reset things like '' does
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_entry_obj && results) {
if (JSON.stringify($journals_slct.journal_entry_obj) !== JSON.stringify(results)) {
$journals_slct.journal_entry_obj = { ...results };
}
}
// Check if results are different than the current session version stored under $journals_slct
if ($journals_slct.journal_entry_obj && results) {
if (JSON.stringify($journals_slct.journal_entry_obj) !== JSON.stringify(results)) {
$journals_slct.journal_entry_obj = { ...results };
}
}
return results;
})
);
return results;
})
);
$effect(() => {
if (log_lvl) {
console.log(`lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}`);
console.log(`lq__journal_entry_obj: results = `, lq__journal_entry_obj);
if ($journals_slct.journal_entry_obj && lq__journal_entry_obj) {
if (
JSON.stringify($journals_slct.journal_entry_obj) !== JSON.stringify(lq__journal_entry_obj)
) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_entry_id}`,
$journals_slct.journal_entry_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_entry_id}`
);
}
}
}
});
$effect(() => {
if (log_lvl) {
console.log(
`lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}`
);
console.log(`lq__journal_entry_obj: results = `, lq__journal_entry_obj);
if ($journals_slct.journal_entry_obj && lq__journal_entry_obj) {
if (
JSON.stringify($journals_slct.journal_entry_obj) !==
JSON.stringify(lq__journal_entry_obj)
) {
console.log(
`Session slct stored version has changed for ID = ${$journals_slct.journal_entry_id}`,
$journals_slct.journal_entry_obj
);
} else {
console.log(
`Session slct stored version has not changed for ID = ${$journals_slct.journal_entry_id}`
);
}
}
}
});
// $effect(() => {
// if (browser && $lq__journal_entry_obj?.journal_entry_id) {
// $effect(() => {
// if (browser && $lq__journal_entry_obj?.journal_entry_id) {
// // $journals_loc.entry_view_history_li = [...new Set($journals_loc.entry_view_history_li)]
// // $journals_loc.entry_view_history_li = [...new Set($journals_loc.entry_view_history_li)]
// let tmp_history_li = [
// ...new Set($journals_loc?.entry_view_history_li ?? [])
// ];
// let tmp_history_li = [
// ...new Set($journals_loc?.entry_view_history_li ?? [])
// ];
// // Limit to last 15 entries
// if (tmp_history_li.length > 15) {
// tmp_history_li = tmp_history_li.slice(tmp_history_li.length - 15);
// }
// // Limit to last 15 entries
// if (tmp_history_li.length > 15) {
// tmp_history_li = tmp_history_li.slice(tmp_history_li.length - 15);
// }
// // let chk_history_li = tmp_history_li?.filter(item => item.id === $lq__journal_entry_obj?.journal_entry_id);
// // let chk_history_li = tmp_history_li?.filter(item => item.id === $lq__journal_entry_obj?.journal_entry_id);
// // if (chk_history_li?.length) {
// // // Already in history, do not add again
// // console.log(`Entry ID = ${$lq__journal_entry_obj?.journal_entry_id} already in history, not adding again.`, tmp_history_li);
// // if (chk_history_li?.length) {
// // // Already in history, do not add again
// // console.log(`Entry ID = ${$lq__journal_entry_obj?.journal_entry_id} already in history, not adding again.`, tmp_history_li);
// // // if (tmp_history_li !== $journals_loc.entry_view_history_li) {
// // if (JSON.stringify(tmp_history_li) !== JSON.stringify($journals_loc.entry_view_history_li)) {
// // $journals_loc.entry_view_history_li = tmp_history_li;
// // // if (tmp_history_li !== $journals_loc.entry_view_history_li) {
// // if (JSON.stringify(tmp_history_li) !== JSON.stringify($journals_loc.entry_view_history_li)) {
// // $journals_loc.entry_view_history_li = tmp_history_li;
// // console.log(`$journals_loc.entry_view_history_li = `, $journals_loc.entry_view_history_li);
// // }
// // console.log(`$journals_loc.entry_view_history_li = `, $journals_loc.entry_view_history_li);
// // }
// // return;
// // }
// // return;
// // }
// tmp_history_li.push({
// id: $lq__journal_entry_obj?.journal_entry_id ?? 'NONE',
// name: $lq__journal_entry_obj?.name ?? ae_util.iso_datetime_formatter($lq__journal_entry_obj?.created_on, 'datetime_iso_12_no_seconds'),
// url: `/journals/${$lq__journal_entry_obj?.journal_id ?? 'NONE'}/entry/${$lq__journal_entry_obj?.journal_entry_id ?? 'NONE'}`,
// });
// tmp_history_li.push({
// id: $lq__journal_entry_obj?.journal_entry_id ?? 'NONE',
// name: $lq__journal_entry_obj?.name ?? ae_util.iso_datetime_formatter($lq__journal_entry_obj?.created_on, 'datetime_iso_12_no_seconds'),
// url: `/journals/${$lq__journal_entry_obj?.journal_id ?? 'NONE'}/entry/${$lq__journal_entry_obj?.journal_entry_id ?? 'NONE'}`,
// });
// // Remove duplicates and keep most recent
// tmp_history_li = [...new Set(tmp_history_li.map(item => JSON.stringify(item)))].map(item => JSON.parse(item));
// // Remove duplicates and keep most recent
// tmp_history_li = [...new Set(tmp_history_li.map(item => JSON.stringify(item)))].map(item => JSON.parse(item));
// // Limit to last 15 entries
// if (tmp_history_li.length > 15) {
// tmp_history_li = tmp_history_li.slice(tmp_history_li.length - 15);
// }
// // Limit to last 15 entries
// if (tmp_history_li.length > 15) {
// tmp_history_li = tmp_history_li.slice(tmp_history_li.length - 15);
// }
// if (JSON.stringify(tmp_history_li) !== JSON.stringify($journals_loc?.entry_view_history_li)) {
// $journals_loc.entry_view_history_li = tmp_history_li;
// if (JSON.stringify(tmp_history_li) !== JSON.stringify($journals_loc?.entry_view_history_li)) {
// $journals_loc.entry_view_history_li = tmp_history_li;
// console.log(`$journals_loc.entry_view_history_li = `, $journals_loc?.entry_view_history_li);
// }
// console.log(`$journals_loc.entry_view_history_li = `, $journals_loc?.entry_view_history_li);
// }
// console.log(`$journals_loc.entry_view_history_li = `, $journals_loc?.entry_view_history_li);
// }
// });
// console.log(`$journals_loc.entry_view_history_li = `, $journals_loc?.entry_view_history_li);
// }
// });
$effect(() => {
if (browser && $lq__journal_entry_obj?.journal_entry_id) {
// log_lvl = 2;
// Start with the current KV or convert the LI to a KV if needed
let history_kv = { ...($journals_loc?.entry_view_history_kv ?? {}) };
$effect(() => {
if (browser && $lq__journal_entry_obj?.journal_entry_id) {
// log_lvl = 2;
// Start with the current KV or convert the LI to a KV if needed
let history_kv = { ...($journals_loc?.entry_view_history_kv ?? {}) };
// Add or update the current entry
const entry_id = $lq__journal_entry_obj?.journal_entry_id ?? 'NONE';
history_kv[entry_id] = {
id: entry_id,
name:
$lq__journal_entry_obj?.name ??
ae_util.iso_datetime_formatter(
$lq__journal_entry_obj?.created_on,
'datetime_iso_12_no_seconds'
),
url: `/journals/${$lq__journal_entry_obj?.journal_id ?? 'NONE'}/entry/${entry_id}`
};
// Add or update the current entry
const entry_id = $lq__journal_entry_obj?.journal_entry_id ?? 'NONE';
history_kv[entry_id] = {
id: entry_id,
name:
$lq__journal_entry_obj?.name ??
ae_util.iso_datetime_formatter(
$lq__journal_entry_obj?.created_on,
'datetime_iso_12_no_seconds'
),
url: `/journals/${$lq__journal_entry_obj?.journal_id ?? 'NONE'}/entry/${entry_id}`
};
console.log(`history_kv (before limiting) = `, history_kv);
console.log(`history_kv (before limiting) = `, history_kv);
// // Convert KV to array, sort by most recent (last updated), and limit to 15
// let history_li = Object.values(history_kv);
// // Convert KV to array, sort by most recent (last updated), and limit to 15
// let history_li = Object.values(history_kv);
// console.log(`history_li (before limiting) = `, history_li);
// console.log(`history_li (before limiting) = `, history_li);
// // If you want to keep the most recent 15, you can use the order of insertion.
// // To do this, remove the oldest if over 15.
// if (history_li.length > 15) {
// // Remove the oldest entries (by insertion order)
// // Get the keys in insertion order
// const keys = Object.keys(history_kv);
// const keys_to_remove = keys.slice(0, history_li.length - 15);
// for (const key of keys_to_remove) {
// delete history_kv[key];
// }
// }
// // If you want to keep the most recent 15, you can use the order of insertion.
// // To do this, remove the oldest if over 15.
// if (history_li.length > 15) {
// // Remove the oldest entries (by insertion order)
// // Get the keys in insertion order
// const keys = Object.keys(history_kv);
// const keys_to_remove = keys.slice(0, history_li.length - 15);
// for (const key of keys_to_remove) {
// delete history_kv[key];
// }
// }
// Only update if changed
if (JSON.stringify(history_kv) !== JSON.stringify($journals_loc?.entry_view_history_kv)) {
$journals_loc.entry_view_history_kv = history_kv;
console.log(`$journals_loc.entry_view_history_kv = `, $journals_loc.entry_view_history_kv);
} else {
if (log_lvl > 1) {
console.log(`$journals_loc.entry_view_history_kv has not changed.`);
}
}
// Only update if changed
if (
JSON.stringify(history_kv) !== JSON.stringify($journals_loc?.entry_view_history_kv)
) {
$journals_loc.entry_view_history_kv = history_kv;
console.log(
`$journals_loc.entry_view_history_kv = `,
$journals_loc.entry_view_history_kv
);
} else {
if (log_lvl > 1) {
console.log(`$journals_loc.entry_view_history_kv has not changed.`);
}
}
// log_lvl = 1;
}
});
// log_lvl = 1;
}
});
</script>
<!-- <svelte:head>
@@ -289,8 +301,8 @@
</svelte:head> -->
{#if $ae_loc.person_id == $lq__journal_obj?.person_id || $lq__journal_entry_obj?.public}
<section
class="
<section
class="
ae_journals__journal_entry
mx-auto
flex flex-col grow gap-1
@@ -301,13 +313,13 @@
max-w-max
space-y-2
"
>
<!-- {#if $lq__journal_entry_obj} -->
<Journal_entry_view {lq__journal_obj} {lq__journal_obj_li} {lq__journal_entry_obj} />
<!-- {/if} -->
</section>
>
<!-- {#if $lq__journal_entry_obj} -->
<Journal_entry_view {lq__journal_obj} {lq__journal_obj_li} {lq__journal_entry_obj} />
<!-- {/if} -->
</section>
{:else}
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center">
<p class="text-center">You must be logged in as the owner to view this Journal Entry.</p>
</section>
<section class="main_content grow px-1 md:px-2 pb-28 flex flex-col gap-1 items-center">
<p class="text-center">You must be logged in as the owner to view this Journal Entry.</p>
</section>
{/if}

View File

@@ -8,70 +8,70 @@ import { db_journals, journal_entry_field_li } from '$lib/ae_journals/db_journal
import { load_ae_obj_id } from '$lib/ae_core/core__crud_generic';
export async function load({ params, parent }) {
// route
const log_lvl: number = 0;
// route
const log_lvl: number = 0;
const data = await parent();
data.log_lvl = log_lvl;
const data = await parent();
data.log_lvl = log_lvl;
const account_id = data.account_id;
const ae_acct = data[account_id];
const account_id = data.account_id;
const ae_acct = data[account_id];
const journal_id = params.journal_id;
ae_acct.slct.journal_id = journal_id;
const journal_id = params.journal_id;
ae_acct.slct.journal_id = journal_id;
const journal_entry_id = params.journal_entry_id;
if (!journal_entry_id) {
console.log(
`ae_journals journals [journal_entry_id] +page.ts: The journal_entry_id was not found in the params!!!`
);
error(404, {
message: 'Journals - Journal Entry ID not found'
});
}
ae_acct.slct.journal_entry_id = journal_entry_id;
if (log_lvl) {
console.log(
`ae_journals journals [journal_entry_id] +page.ts: journal_entry_id = `,
journal_entry_id
);
}
const journal_entry_id = params.journal_entry_id;
if (!journal_entry_id) {
console.log(
`ae_journals journals [journal_entry_id] +page.ts: The journal_entry_id was not found in the params!!!`
);
error(404, {
message: 'Journals - Journal Entry ID not found'
});
}
ae_acct.slct.journal_entry_id = journal_entry_id;
if (log_lvl) {
console.log(
`ae_journals journals [journal_entry_id] +page.ts: journal_entry_id = `,
journal_entry_id
);
}
if (browser) {
if (log_lvl) {
console.log(
`ae_journals journals [journal_entry_id] +page.ts: journal_entry_id = `,
journal_entry_id
);
}
// Load event journal entry object
// let load_journal_entry_obj = journals_func.load_ae_obj_id__journal_entry({
// api_cfg: ae_acct.api,
// journal_entry_id: journal_entry_id,
// try_cache: true,
// log_lvl: log_lvl
// });
if (browser) {
if (log_lvl) {
console.log(
`ae_journals journals [journal_entry_id] +page.ts: journal_entry_id = `,
journal_entry_id
);
}
// Load event journal entry object
// let load_journal_entry_obj = journals_func.load_ae_obj_id__journal_entry({
// api_cfg: ae_acct.api,
// journal_entry_id: journal_entry_id,
// try_cache: true,
// log_lvl: log_lvl
// });
const load_journal_entry_obj = load_ae_obj_id({
api_cfg: ae_acct.api,
obj_type: 'journal_entry',
obj_id: journal_entry_id,
db_instance: db_journals,
db_field_li: journal_entry_field_li,
log_lvl: 2
});
const load_journal_entry_obj = load_ae_obj_id({
api_cfg: ae_acct.api,
obj_type: 'journal_entry',
obj_id: journal_entry_id,
db_instance: db_journals,
db_field_li: journal_entry_field_li,
log_lvl: 2
});
if (!load_journal_entry_obj) {
error(404, {
message: 'Journals - Journal Entry not found'
});
} else {
ae_acct.slct.load_journal_entry_obj = load_journal_entry_obj;
}
}
if (!load_journal_entry_obj) {
error(404, {
message: 'Journals - Journal Entry not found'
});
} else {
ae_acct.slct.load_journal_entry_obj = load_journal_entry_obj;
}
}
// WARNING: Precaution against shared data between sites.
data[account_id] = ae_acct;
// WARNING: Precaution against shared data between sites.
data[account_id] = ae_acct;
return data;
return data;
}