refactor(journals): standardize high-performance reactive search and stabilize results stream

- Implemented the loop-proof search pattern in 'src/routes/journals/[journal_id]/+page.svelte' using versioned triggers and untracked dependency isolation.
- Stabilized data loading by introducing 'ae_comp__journal_entry_obj_li_wrapper.svelte', ensuring smooth SWR transitions between local and API results.
- Synchronized result counts with the rendered list in 'ae_comp__journal_entry_obj_li.svelte' and implemented permissive visibility defaults.
- Added 'Remote First' toggle support (Edit Mode only) and laid groundwork for Global Search in 'ae_comp__journal_entry_obj_qry.svelte'.
- Updated Dexie schema and API helpers to support future person-level cross-journal searching.
This commit is contained in:
Scott Idem
2026-01-27 15:20:17 -05:00
parent 07e13ea5f2
commit 6055fc3408
7 changed files with 367 additions and 477 deletions

View File

@@ -297,10 +297,11 @@ export async function delete_ae_obj_id__journal_entry({
}
// This new function is using CRUD V3 Search.
// Updated 2026-01-02
// Updated 2026-01-27
export async function qry__journal_entry({
api_cfg,
journal_id,
person_id = null,
qry_str = null, // Example: 'name:contains:"test"'
qry_category_code = null,
qry_created_on = null, // Example greater than: '2024-10-24'
@@ -325,6 +326,7 @@ export async function qry__journal_entry({
}: {
api_cfg: any;
journal_id: any;
person_id?: string | null;
qry_str?: null | string;
qry_category_code?: null | string;
qry_created_on?: null | string;
@@ -339,15 +341,13 @@ export async function qry__journal_entry({
try_cache?: boolean;
log_lvl?: number;
}) {
// log_lvl = 1;
if (log_lvl) {
console.log(`*** qry__journal_entry() *** journal_id=${journal_id}`);
console.log(`*** qry__journal_entry() *** journal_id=${journal_id} person_id=${person_id}`);
}
const search_query: any = { and: [] };
if (qry_str) {
console.log('qry_str:', qry_str);
// Using 'like' with wildcards to ensure compatibility
search_query.and.push({ field: 'default_qry_str', op: 'like', value: `%${qry_str.trim()}%` });
params['lk_qry'] = { 'default_qry_str': qry_str.trim() };
@@ -362,13 +362,16 @@ export async function qry__journal_entry({
}
if (qry_priority) {
console.log('qry_priority:', qry_priority);
search_query.and.push({ field: 'priority', op: 'eq', value: qry_priority });
}
// Add context
// Context scoping: Prefer journal_id if provided, otherwise fallback to person_id (global search)
if (journal_id) {
search_query.and.push({ field: 'journal_id_random', op: 'eq', value: journal_id });
} else if (person_id) {
search_query.and.push({ field: 'person_id_random', op: 'eq', value: person_id });
} else {
console.warn('qry__journal_entry: No journal_id or person_id provided. Search might be too broad.');
}
// Add enabled/hidden filters

View File

@@ -79,6 +79,9 @@ const journals_local_data_struct: key_val = {
edit_kv: {},
// Query / Search Settings
search_version: 0,
qry__remote_first: false,
qry__global_person_search: false,
qry__search_text: '',
qry__category_code: '', // For filtering
qry__enabled: 'enabled', // all, disabled, enabled

View File

@@ -117,6 +117,7 @@ export class MySubClassedDexie extends Dexie {
journal_entry: `
id, journal_entry_id, journal_entry_id_random,
journal_id, journal_id_random,
person_id, person_id_random,
code,
template,
name,