feat(journals): expose export functionality in UI

- Added 'Export Entries' button to Journal Index and Journal Detail views
- Wired buttons to trigger the new export modal
This commit is contained in:
Scott Idem
2026-01-13 23:43:50 -05:00
parent b3ac910832
commit b1e9902285
2 changed files with 37 additions and 1 deletions

View File

@@ -8,7 +8,7 @@
import { goto } from '$app/navigation';
// *** Import other supporting libraries
import { BookPlus, FolderPlus, Library, Loader, SquareLibrary, Wrench, FileUp } from '@lucide/svelte';
import { BookPlus, FolderPlus, Library, Loader, SquareLibrary, Wrench, FileUp, FileDown } from '@lucide/svelte';
import { liveQuery } from 'dexie';
import { Modal } from 'flowbite-svelte';
@@ -34,11 +34,13 @@
import Journal_obj_li from './ae_comp__journal_obj_li.svelte';
import AeCompJournalEntryQuickAdd from './ae_comp__journal_entry_quick_add.svelte';
import AeCompModalJournalImport from './ae_comp__modal_journal_import.svelte';
import AeCompModalJournalExport from './ae_comp__modal_journal_export.svelte';
// import Element_data_store from '$lib/element_data_store_v2.svelte';
let ae_acct = data[$slct.account_id];
let show_import_modal = $state(false);
let show_export_modal = $state(false);
function handle_import_complete() {
// Trigger a refresh of the journal list?
@@ -47,6 +49,20 @@
// $journals_trig.journal_entry_li = true;
}
// $journals_slct.journal_obj = ae_acct.slct.journal_obj;
// We need to access the currently filtered/displayed list of entries for export.
// The list is actually managed inside 'Journal_obj_li' (the list component) or via a store.
// However, looking at Journal_obj_li, it takes 'lq__journal_entry_obj_li' as a prop.
// BUT wait, this page (+page.svelte) seems to be the Journal INDEX (list of journals),
// NOT the list of entries within a journal.
// Ah, checking the code...
// The main page lists *Journals* (lq__journal_obj_li).
// The entries are listed in [journal_id]/+page.svelte.
// Correction: Bulk Export should probably be on the [journal_id] page, OR here if we want to export ALL journals?
// The user request was "export Journal Entries". Usually implies from a specific journal or context.
// Let's check [journal_id]/+page.svelte.
// $journals_slct.journal_obj_li = ae_acct.slct.journal_obj_li;
let lq__journal_obj_li = $derived(

View File

@@ -66,6 +66,8 @@
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 AeCompModalJournalExport from '../ae_comp__modal_journal_export.svelte';
import { FileDown } from '@lucide/svelte';
// let ae_promises: key_val = {};
// let ae_tmp: key_val = {};
@@ -74,6 +76,8 @@
// Variables
// *** Quickly pull out data from parent(s)
let ae_acct = data[$slct.account_id];
let show_export_modal = $state(false);
$effect(() => {
if (log_lvl > 1) {
console.log(`ae_acct = `, ae_acct);
@@ -327,6 +331,15 @@
<Journal_view {lq__journal_obj} {lq__journal_entry_obj_li} />
<!-- Export Toolbar -->
{#if $lq__journal_entry_obj_li && $lq__journal_entry_obj_li.length > 0}
<div class="flex justify-end w-full max-w-(--breakpoint-lg) px-2 pb-2">
<button class="btn btn-sm variant-soft-secondary hover:variant-filled-secondary" onclick={() => show_export_modal = true}>
<FileDown class="mr-2" size="1em" /> Export Entries
</button>
</div>
{/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}
@@ -344,6 +357,13 @@
{lq__journal_obj}
show={$journals_sess.show__modal_edit__journal_obj}
/>
<!-- Modal: Bulk Export -->
<AeCompModalJournalExport
bind:open={show_export_modal}
entries={$lq__journal_entry_obj_li ?? []}
onClose={() => show_export_modal = false}
/>
{: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>