diff --git a/src/lib/ae_journals/ae_journals_stores.ts b/src/lib/ae_journals/ae_journals_stores.ts index d201347c..b56829bb 100644 --- a/src/lib/ae_journals/ae_journals_stores.ts +++ b/src/lib/ae_journals/ae_journals_stores.ts @@ -28,6 +28,9 @@ let journals_local_data_struct: key_val = { qry__offset: 0, qry__journal_id: null, + journal_view_history_li: [], // Appended each time the journal is loaded. + entry_view_history_li: [], // Appended each time the entry is loaded. + journal: { edit: false, edit_kv: {}, diff --git a/src/routes/journals/[journal_id]/+layout.svelte b/src/routes/journals/[journal_id]/+layout.svelte index da09ec6b..8fed163b 100644 --- a/src/routes/journals/[journal_id]/+layout.svelte +++ b/src/routes/journals/[journal_id]/+layout.svelte @@ -57,6 +57,8 @@ if (log_lvl) { // $journals_sess.entry_li = []; // $journals_slct.journal_id = ae_acct.slct.journal_id; +let show_menu__all_journals: boolean = $state(false); + let lq__journal_obj = $derived(liveQuery(async () => { if (log_lvl) { console.log(`lq__journal_obj: journal_id = ${$journals_slct?.journal_id}`); @@ -176,27 +178,103 @@ let lq__journal_obj = $derived(liveQuery(async () => { py-2 w-full hover:bg-slate-100 hover:dark:bg-slate-700 + + relative transition-all " > - { + show_menu__all_journals = !show_menu__all_journals; + }} class=" btn btn-sm preset-tonal-tertiary preset-outlined-tertiary-600-400 hover:preset-outlined-tertiary-700-300 - hover:preset-filled-tertiary-100-900 + hover:preset-filled-tertiary-300-700 transition-all " - title="View all journals for this account: {$ae_loc.account_name}" + title="View all journals menu: {$ae_loc.account_name}" > - + {#if show_menu__all_journals} + + {:else} + + {/if} - + + + +
+ + + + + + All Journals + + + + + + + {#if $journals_loc?.entry_view_history_li?.length > 0} + + {/if} + +
{#if $journals_slct?.journal_entry_id} { btn btn-sm preset-tonal-tertiary preset-outlined-tertiary-600-400 - hover:preset-filled-tertiary-100-900 + hover:preset-outlined-tertiary-700-300 + hover:preset-filled-tertiary-300-700 transition-all " title="View all journal entries for this journal: {$lq__journal_obj?.name}" @@ -303,7 +382,8 @@ let lq__journal_obj = $derived(liveQuery(async () => { btn btn-sm preset-tonal-tertiary preset-outlined-tertiary-600-400 - hover:preset-filled-tertiary-100-900 + hover:preset-outlined-tertiary-700-300 + hover:preset-filled-tertiary-300-700 transition-all " title="Create a new journal entry for this journal: {$lq__journal_obj?.name}" diff --git a/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte b/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte index ec727637..d2c001ee 100644 --- a/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte +++ b/src/routes/journals/[journal_id]/entry/[journal_entry_id]/+page.svelte @@ -3,7 +3,7 @@ let log_lvl: number = $state(1); // *** Import Svelte specific -// import { browser } from '$app/environment'; +import { browser } from '$app/environment'; // *** Import other supporting libraries // import { Modal } from 'flowbite-svelte'; @@ -11,7 +11,7 @@ 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 { 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/ae_stores'; @@ -129,6 +129,59 @@ let lq__journal_entry_obj = $derived(liveQuery(async () => { return results; })); +$effect(() => { + if (browser && $lq__journal_entry_obj?.journal_entry_id) { + + // $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) + ]; + + // 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); + + // 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; + + // console.log(`$journals_loc.entry_view_history_li = `, $journals_loc.entry_view_history_li); + // } + + // 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'}`, + }); + + // 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); + } + + 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); + } +}); diff --git a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte index a278ec1f..c7cfe017 100644 --- a/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte +++ b/src/routes/journals/ae_comp__journal_entry_obj_id_view.svelte @@ -1314,7 +1314,7 @@ $effect(() => { min-w-72 max-w-fit " - class:hidden={show_menu} + class:hidden={!show_menu} > diff --git a/src/routes/journals/ae_comp__journal_obj_id_view.svelte b/src/routes/journals/ae_comp__journal_obj_id_view.svelte index b7548fa1..7d490f00 100644 --- a/src/routes/journals/ae_comp__journal_obj_id_view.svelte +++ b/src/routes/journals/ae_comp__journal_obj_id_view.svelte @@ -122,7 +122,12 @@ function verify_journal_passcode() {