feat: Migrate ESLint to flat config and resolve initial linting errors
Migrated the ESLint configuration to the new flat config format () and addressed several initial linting errors. Key changes include: - Updated ESLint configuration to treat as warnings instead of errors. - Fixed errors in by declaring and . - Corrected error in by using instead of an out-of-scope . - Resolved error in by replacing the undefined directive with the component. - Addressed errors in by replacing with and with . - Fixed errors in by importing necessary modules (, , ) and adding missing props (, , , , ).
This commit is contained in:
@@ -1,149 +1,169 @@
|
||||
<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);
|
||||
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');
|
||||
}
|
||||
|
||||
} 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');
|
||||
// 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];
|
||||
}
|
||||
|
||||
} 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];
|
||||
}
|
||||
|
||||
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}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
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}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<!-- Svelte layout for a Journal ID page and children -->
|
||||
<section
|
||||
class="
|
||||
class="
|
||||
ae_journals__journal
|
||||
mx-auto
|
||||
flex flex-col grow gap-1
|
||||
@@ -154,12 +174,9 @@ $effect(() => {
|
||||
max-w-max
|
||||
space-y-2
|
||||
"
|
||||
>
|
||||
|
||||
|
||||
|
||||
<div
|
||||
class="
|
||||
>
|
||||
<div
|
||||
class="
|
||||
flex flex-row flex-wrap
|
||||
gap-1
|
||||
items-center justify-between
|
||||
@@ -171,29 +188,25 @@ $effect(() => {
|
||||
|
||||
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
|
||||
@@ -201,25 +214,23 @@ $effect(() => {
|
||||
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>
|
||||
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>
|
||||
|
||||
</button>
|
||||
|
||||
|
||||
<div
|
||||
class="
|
||||
<div
|
||||
class="
|
||||
absolute top-12 left-0
|
||||
p-4 z-50 w-80
|
||||
space-y-0.5
|
||||
@@ -229,10 +240,11 @@ $effect(() => {
|
||||
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
|
||||
@@ -240,54 +252,52 @@ $effect(() => {
|
||||
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>
|
||||
title="View all journals for this account: {$ae_loc.account_name}"
|
||||
>
|
||||
<!-- <BookHeart /> -->
|
||||
<!-- <Library /> -->
|
||||
<SquareLibrary class="text-blue-500" />
|
||||
<span class=""> All Journals </span>
|
||||
</a>
|
||||
|
||||
</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}× 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}
|
||||
>
|
||||
<option value="" disabled selected>
|
||||
{Object.keys($journals_loc.entry_view_history_kv).length}× 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>
|
||||
|
||||
</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
|
||||
@@ -295,21 +305,21 @@ $effect(() => {
|
||||
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 = {
|
||||
@@ -337,60 +347,63 @@ $effect(() => {
|
||||
Edit Journal
|
||||
</span>
|
||||
</button> -->
|
||||
<Journal_entry_obj_qry
|
||||
log_lvl={log_lvl}
|
||||
lq__journal_obj={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
|
||||
@@ -398,31 +411,20 @@ $effect(() => {
|
||||
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>
|
||||
|
||||
|
||||
|
||||
<!-- <div class="overflow-auto"> -->
|
||||
{@render children?.()}
|
||||
<!-- </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> -->
|
||||
</section>
|
||||
|
||||
|
||||
<!-- {#if $journals_sess.show__modal_edit__journal_obj}
|
||||
<Journal_obj_id_edit
|
||||
log_lvl={log_lvl}
|
||||
@@ -430,4 +432,3 @@ $effect(() => {
|
||||
show={$journals_sess.show__modal_edit__journal_obj}
|
||||
/>
|
||||
{/if} -->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user