Prettier for Journals
This commit is contained in:
@@ -1,83 +1,83 @@
|
||||
<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 type { ae_JournalEntry } from '$lib/types/ae_types';
|
||||
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 type { ae_JournalEntry } from '$lib/types/ae_types';
|
||||
|
||||
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';
|
||||
|
||||
// NOTE: Derived from data.account_id (prop) instead of $slct.account_id (store)
|
||||
// to prevent circular dependency loops during hydration.
|
||||
let ae_acct = $derived(data[data.account_id]);
|
||||
$effect(() => {
|
||||
if (log_lvl) {
|
||||
console.log(`ae_acct = `, ae_acct);
|
||||
}
|
||||
});
|
||||
// NOTE: Derived from data.account_id (prop) instead of $slct.account_id (store)
|
||||
// to prevent circular dependency loops during hydration.
|
||||
let ae_acct = $derived(data[data.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 };
|
||||
}
|
||||
}
|
||||
|
||||
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}`
|
||||
);
|
||||
}
|
||||
// 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;
|
||||
})
|
||||
);
|
||||
|
||||
$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}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Svelte layout for a Journal ID page and children -->
|
||||
@@ -85,29 +85,27 @@
|
||||
class="
|
||||
ae_journals__journal
|
||||
mx-auto
|
||||
flex flex-col grow gap-1
|
||||
items-center
|
||||
min-h-full
|
||||
max-h-max
|
||||
flex max-h-max min-h-full max-w-max
|
||||
min-w-full
|
||||
max-w-max
|
||||
grow
|
||||
flex-col
|
||||
items-center
|
||||
gap-1
|
||||
space-y-2
|
||||
"
|
||||
>
|
||||
">
|
||||
<div
|
||||
class="
|
||||
flex flex-row flex-wrap
|
||||
relative flex w-full
|
||||
flex-row
|
||||
flex-wrap items-center
|
||||
justify-between
|
||||
gap-1
|
||||
items-center justify-between
|
||||
border-gray-400
|
||||
border-b
|
||||
py-2
|
||||
w-full
|
||||
hover:bg-slate-100 hover:dark:bg-slate-700
|
||||
border-gray-400
|
||||
py-2 transition-all
|
||||
|
||||
relative transition-all
|
||||
"
|
||||
>
|
||||
hover:bg-slate-100 hover:dark:bg-slate-700
|
||||
">
|
||||
<!-- If middle click then open the all journals page in a new tab. Otherwise show/hide the menu. -->
|
||||
<button
|
||||
type="button"
|
||||
@@ -134,8 +132,7 @@
|
||||
transition-all
|
||||
"
|
||||
title={`View all journals menu: "${$ae_loc?.user?.name}"
|
||||
Middle-click to open in new tab`}
|
||||
>
|
||||
Middle-click to open in new tab`}>
|
||||
<!-- <BookHeart /> -->
|
||||
<!-- <Library /> -->
|
||||
{#if show_menu__all_journals}
|
||||
@@ -152,16 +149,15 @@ Middle-click to open in new tab`}
|
||||
<div
|
||||
class="
|
||||
absolute top-12 left-0
|
||||
p-4 z-50 w-80
|
||||
space-y-0.5
|
||||
bg-white dark:bg-gray-800
|
||||
border border-gray-500
|
||||
shadow-xl rounded-lg
|
||||
z-50 w-80 max-w-fit
|
||||
min-w-72
|
||||
max-w-fit
|
||||
space-y-0.5 rounded-lg
|
||||
border border-gray-500
|
||||
bg-white p-4
|
||||
shadow-xl
|
||||
dark:bg-gray-800
|
||||
"
|
||||
class:hidden={!show_menu__all_journals}
|
||||
>
|
||||
class:hidden={!show_menu__all_journals}>
|
||||
<a
|
||||
href="/journals"
|
||||
class="
|
||||
@@ -172,8 +168,7 @@ Middle-click to open in new tab`}
|
||||
hover:preset-filled-tertiary-300-700
|
||||
transition-all
|
||||
"
|
||||
title="View all journals for this account: {$ae_loc.account_name}"
|
||||
>
|
||||
title="View all journals for this account: {$ae_loc.account_name}">
|
||||
<!-- <BookHeart /> -->
|
||||
<!-- <Library /> -->
|
||||
<SquareLibrary class="text-blue-500" />
|
||||
@@ -195,12 +190,11 @@ Middle-click to open in new tab`}
|
||||
}}
|
||||
class="
|
||||
form-select
|
||||
border-neutral-400-600
|
||||
w-full
|
||||
border p-1
|
||||
text-sm
|
||||
border border-neutral-400-600
|
||||
p-1
|
||||
"
|
||||
>
|
||||
">
|
||||
<option value="" disabled selected>
|
||||
{Object.keys($journals_loc.entry_view_history_kv)
|
||||
.length}× Recent Entries...
|
||||
@@ -228,8 +222,7 @@ Middle-click to open in new tab`}
|
||||
hover:preset-filled-tertiary-300-700
|
||||
transition-all
|
||||
"
|
||||
title="View all journal entries for this journal: {$lq__journal_obj?.name}"
|
||||
>
|
||||
title="View all journal entries for this journal: {$lq__journal_obj?.name}">
|
||||
<Notebook />
|
||||
<!-- <Bookmark /> -->
|
||||
<!-- <BookHeart class="m-1" /> -->
|
||||
@@ -315,8 +308,7 @@ Middle-click to open in new tab`}
|
||||
hover:preset-filled-tertiary-300-700
|
||||
transition-all
|
||||
"
|
||||
title="Create a new journal entry for this journal: {$lq__journal_obj?.name}"
|
||||
>
|
||||
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>
|
||||
|
||||
Reference in New Issue
Block a user