style(journals): apply expanded 80-width formatting and snake_case
- Batch formatted all Journals module files using Prettier with printWidth: 80. - Refactored preventDefault to prevent_default across all Svelte components. - Standardized line breaks for imports and long attribute lists for better readability. - Ensured consistent snake_case naming for internal identifiers.
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
let ae_acct = data[$slct.account_id];
|
||||
let show_export_modal = $state(false);
|
||||
let show_import_modal = $state(false);
|
||||
|
||||
|
||||
let search_id_li: Array<string> = $state([]);
|
||||
let search_debounce_timer: any = null;
|
||||
let last_search_id = 0;
|
||||
@@ -54,7 +54,8 @@
|
||||
|
||||
function handle_import_complete() {
|
||||
// Trigger a refresh of the journal entry list
|
||||
if ($journals_loc.entry.search_version === undefined) $journals_loc.entry.search_version = 0;
|
||||
if ($journals_loc.entry.search_version === undefined)
|
||||
$journals_loc.entry.search_version = 0;
|
||||
$journals_loc.entry.search_version++;
|
||||
}
|
||||
|
||||
@@ -63,12 +64,14 @@
|
||||
|
||||
let lq__journal_obj = $derived(
|
||||
liveQuery(async () => {
|
||||
return await db_journals.journal.get($journals_slct?.journal_id ?? '');
|
||||
return await db_journals.journal.get(
|
||||
$journals_slct?.journal_id ?? ''
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
// Stable LiveQuery Pattern (Aether UI V3)
|
||||
// Re-wrapped in $derived to ensure the observable instance remains stable
|
||||
// Re-wrapped in $derived to ensure the observable instance remains stable
|
||||
// unless the underlying dependencies (ids, search context) change.
|
||||
let lq__journal_entry_obj_li = $derived(
|
||||
liveQuery(async () => {
|
||||
@@ -79,14 +82,18 @@
|
||||
|
||||
// SCENARIO 1: Specific IDs provided (Search Results)
|
||||
if (Array.isArray(ids) && ids.length > 0) {
|
||||
if (log_lvl) console.log(`Journal Page LQ: bulkGet ${ids.length} IDs`);
|
||||
if (log_lvl)
|
||||
console.log(`Journal Page LQ: bulkGet ${ids.length} IDs`);
|
||||
const results = await db_journals.journal_entry.bulkGet(ids);
|
||||
return results.filter(item => item !== undefined);
|
||||
return results.filter((item) => item !== undefined);
|
||||
}
|
||||
|
||||
|
||||
// SCENARIO 2: Fallback to broad search (Default view)
|
||||
if (journal_id && !search_text && !cat_code) {
|
||||
if (log_lvl) console.log(`Journal Page LQ: Fallback search for journal: ${journal_id}`);
|
||||
if (log_lvl)
|
||||
console.log(
|
||||
`Journal Page LQ: Fallback search for journal: ${journal_id}`
|
||||
);
|
||||
return await db_journals.journal_entry
|
||||
.where('journal_id')
|
||||
.equals(journal_id)
|
||||
@@ -139,14 +146,17 @@
|
||||
const current_search_id = ++last_search_id;
|
||||
const journal_id = params.journal_id;
|
||||
const remote_first = params.remote_first;
|
||||
|
||||
if (log_lvl) console.log(`[Journal Search #${current_search_id}] Refreshing entries (remote=${remote_first}, journal=${journal_id})...`);
|
||||
|
||||
|
||||
if (log_lvl)
|
||||
console.log(
|
||||
`[Journal Search #${current_search_id}] Refreshing entries (remote=${remote_first}, journal=${journal_id})...`
|
||||
);
|
||||
|
||||
// 2. Setup State
|
||||
untrack(() => {
|
||||
$journals_sess.entry.qry__status = 'loading';
|
||||
});
|
||||
|
||||
|
||||
const qry_str = params.str;
|
||||
const cat_code = params.cat;
|
||||
|
||||
@@ -160,30 +170,46 @@
|
||||
let local_results = await db_journals.journal_entry
|
||||
.where('journal_id')
|
||||
.equals(journal_id)
|
||||
.filter(entry => {
|
||||
if (cat_code && entry.category_code !== cat_code) return false;
|
||||
.filter((entry) => {
|
||||
if (cat_code && entry.category_code !== cat_code)
|
||||
return false;
|
||||
if (qry_str) {
|
||||
const name = (entry.name ?? '').toLowerCase();
|
||||
const content = (entry.content ?? '').toLowerCase();
|
||||
return name.includes(qry_str) || content.includes(qry_str);
|
||||
const content = (
|
||||
entry.content ?? ''
|
||||
).toLowerCase();
|
||||
return (
|
||||
name.includes(qry_str) ||
|
||||
content.includes(qry_str)
|
||||
);
|
||||
}
|
||||
return true;
|
||||
})
|
||||
.toArray();
|
||||
|
||||
local_results.sort((a, b) => {
|
||||
const dateA = a.updated_on ? new Date(a.updated_on).getTime() : 0;
|
||||
const dateB = b.updated_on ? new Date(b.updated_on).getTime() : 0;
|
||||
const dateA = a.updated_on
|
||||
? new Date(a.updated_on).getTime()
|
||||
: 0;
|
||||
const dateB = b.updated_on
|
||||
? new Date(b.updated_on).getTime()
|
||||
: 0;
|
||||
return dateB - dateA;
|
||||
});
|
||||
|
||||
local_ids = local_results.map(e => e.id || e.journal_entry_id_random).filter(Boolean);
|
||||
local_ids = local_results
|
||||
.map((e) => e.id || e.journal_entry_id_random)
|
||||
.filter(Boolean);
|
||||
|
||||
if (current_search_id === last_search_id) {
|
||||
if (log_lvl) console.log(`[Journal Search #${current_search_id}] Fast Path found ${local_ids.length} items locally.`);
|
||||
if (log_lvl)
|
||||
console.log(
|
||||
`[Journal Search #${current_search_id}] Fast Path found ${local_ids.length} items locally.`
|
||||
);
|
||||
untrack(() => {
|
||||
search_id_li = local_ids;
|
||||
if (local_ids.length > 0) $journals_sess.entry.qry__status = 'done';
|
||||
if (local_ids.length > 0)
|
||||
$journals_sess.entry.qry__status = 'done';
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -208,10 +234,17 @@
|
||||
|
||||
if (current_search_id === last_search_id) {
|
||||
const api_results = results || [];
|
||||
const api_ids = api_results.map((e: any) => e.id || e.journal_entry_id_random).filter(Boolean);
|
||||
|
||||
const api_ids = api_results
|
||||
.map((e: any) => e.id || e.journal_entry_id_random)
|
||||
.filter(Boolean);
|
||||
|
||||
// Protect UI cache if API returns empty during revalidation
|
||||
if (api_ids.length === 0 && local_ids.length > 0 && !remote_first && !qry_str) {
|
||||
if (
|
||||
api_ids.length === 0 &&
|
||||
local_ids.length > 0 &&
|
||||
!remote_first &&
|
||||
!qry_str
|
||||
) {
|
||||
untrack(() => {
|
||||
$journals_sess.entry.qry__status = 'done';
|
||||
});
|
||||
@@ -223,7 +256,10 @@
|
||||
search_id_li = api_ids;
|
||||
$journals_sess.entry.qry__status = 'done';
|
||||
});
|
||||
if (log_lvl) console.log(`[Journal Search #${current_search_id}] Revalidation Complete. Found ${api_ids.length} items.`);
|
||||
if (log_lvl)
|
||||
console.log(
|
||||
`[Journal Search #${current_search_id}] Revalidation Complete. Found ${api_ids.length} items.`
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
if (current_search_id === last_search_id) {
|
||||
@@ -239,7 +275,10 @@
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
window.parent.postMessage({ journal_id: $journals_slct?.journal_id ?? null }, '*');
|
||||
window.parent.postMessage(
|
||||
{ journal_id: $journals_slct?.journal_id ?? null },
|
||||
'*'
|
||||
);
|
||||
}
|
||||
|
||||
import { LoaderCircle } from 'lucide-svelte';
|
||||
@@ -252,7 +291,9 @@
|
||||
</svelte:head>
|
||||
|
||||
{#if $lq__journal_obj === undefined}
|
||||
<div class="flex flex-col items-center justify-center p-20 opacity-50 text-center">
|
||||
<div
|
||||
class="flex flex-col items-center justify-center p-20 opacity-50 text-center"
|
||||
>
|
||||
<LoaderCircle size="3em" class="animate-spin mb-4 mx-auto" />
|
||||
<p class="text-xl">Loading Journal...</p>
|
||||
</div>
|
||||
@@ -260,15 +301,15 @@
|
||||
<AeCompJournalObjIdView
|
||||
{lq__journal_obj}
|
||||
{lq__journal_entry_obj_li}
|
||||
on_show_export={() => show_export_modal = true}
|
||||
on_show_import={() => show_import_modal = true}
|
||||
on_show_export={() => (show_export_modal = true)}
|
||||
on_show_import={() => (show_import_modal = true)}
|
||||
/>
|
||||
|
||||
<Journal_entry_obj_li_wrapper
|
||||
{lq__journal_obj}
|
||||
<Journal_entry_obj_li_wrapper
|
||||
{lq__journal_obj}
|
||||
{lq__journal_entry_obj_li}
|
||||
show_found_header={false}
|
||||
{log_lvl}
|
||||
{log_lvl}
|
||||
/>
|
||||
|
||||
<Journal_obj_id_edit
|
||||
@@ -286,11 +327,15 @@
|
||||
|
||||
<AeCompModalJournalImport
|
||||
bind:open={show_import_modal}
|
||||
on_close={() => show_import_modal = false}
|
||||
on_close={() => (show_import_modal = false)}
|
||||
on_import_complete={handle_import_complete}
|
||||
/>
|
||||
{: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
|
||||
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}
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user