diff --git a/src/lib/ae_journals/ae_journals__journal.ts b/src/lib/ae_journals/ae_journals__journal.ts index 251e568a..eb0b087e 100644 --- a/src/lib/ae_journals/ae_journals__journal.ts +++ b/src/lib/ae_journals/ae_journals__journal.ts @@ -14,12 +14,24 @@ export async function load_ae_obj_id__journal( api_cfg, journal_id, inc_entry_li = false, + enabled = 'enabled', + hidden = 'not_hidden', + limit = 99, + offset = 0, + order_by_li = {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, + params = {}, try_cache = true, log_lvl = 0 }: { api_cfg: any, journal_id: string, inc_entry_li?: boolean, + enabled?: string, // all, disabled, enabled + hidden?: string, // all, hidden, not_hidden + limit?: number, + offset?: number, + order_by_li?: key_val, // Order by fields for the journal entries + params?: key_val, try_cache?: boolean, log_lvl?: number } @@ -28,8 +40,6 @@ export async function load_ae_obj_id__journal( console.log(`*** load_ae_obj_id__journal() *** journal_id=${journal_id}`); } - let params = {}; - ae_promises.load__journal_obj = await api.get_ae_obj_id_crud({ api_cfg: api_cfg, obj_type: 'journal', @@ -72,7 +82,12 @@ export async function load_ae_obj_id__journal( api_cfg: api_cfg, for_obj_type: 'journal', for_obj_id: journal_id, - params: {qry__enabled: 'all', qry__limit: 99}, + enabled: enabled, // all, disabled, enabled + hidden: hidden, // all, hidden, not_hidden + limit: limit, // Limit for the entries + offset: offset, + order_by_li: order_by_li, + params: params, try_cache: try_cache, log_lvl: log_lvl }) @@ -180,6 +195,11 @@ export async function load_ae_obj_li__journal( api_cfg: api_cfg, for_obj_type: 'journal', for_obj_id: journal_id, + enabled: enabled, + hidden: hidden, + limit: limit, + offset: offset, + order_by_li: order_by_li, params: params, try_cache: try_cache, log_lvl: log_lvl @@ -532,6 +552,7 @@ export function db_save_ae_obj_li__journal( person_id: obj.person_id_random, name: obj.name, + short_name: obj.short_name, summary: obj.summary, outline: obj.outline, @@ -549,9 +570,9 @@ export function db_save_ae_obj_li__journal( sort_by: obj.sort_by, sort_by_desc: obj.sort_by_desc, - cfg_json: obj.cfg_json, + cfg_json: obj.cfg_json ?? {}, - data_json: obj.data_json, + data_json: obj.data_json ?? {}, // ux_mode: obj.ux_mode, diff --git a/src/lib/ae_journals/ae_journals__journal_entry.ts b/src/lib/ae_journals/ae_journals__journal_entry.ts index 2b45a831..afdfd52a 100644 --- a/src/lib/ae_journals/ae_journals__journal_entry.ts +++ b/src/lib/ae_journals/ae_journals__journal_entry.ts @@ -357,6 +357,8 @@ export async function db_save_ae_obj_li__journal_entry( person_id: obj.person_id_random, + template: obj.template ?? null, // Allow for a template to be used, otherwise null + activity_code: obj.activity_code, category_code: obj.category_code, type_code: obj.type_code, @@ -369,6 +371,7 @@ export async function db_save_ae_obj_li__journal_entry( professional: obj.professional, name: obj.name, + short_name: obj.short_name ?? null, summary: obj.summary, outline: obj.outline, // description: obj.description, @@ -403,8 +406,8 @@ export async function db_save_ae_obj_li__journal_entry( alert: obj.alert, alert_msg: obj.alert_msg, - // cfg_json: obj.cfg_json, - data_json: obj.data_json, + // cfg_json: obj.cfg_json ?? {}, + data_json: obj.data_json ?? {}, // This only allows for basic access to the data. // passcode_read: obj.passcode_read, // For LLM (AI) generated summary...??? diff --git a/src/lib/ae_journals/db_journals.ts b/src/lib/ae_journals/db_journals.ts index fff06330..84e89ae9 100644 --- a/src/lib/ae_journals/db_journals.ts +++ b/src/lib/ae_journals/db_journals.ts @@ -26,6 +26,8 @@ export interface Journal { for_type?: null|string; for_id?: null|string; + // template?: null|boolean; // Is this a template journal? If true, it can be used to create new journals. + type_code?: null|string; account_id?: null|string; // Owner account of the journal @@ -34,6 +36,7 @@ export interface Journal { // location_id?: null|string; // Assign to a location??? name: string; // or the title + short_name?: null|string; // Short name for the journal, if any. Used for display purposes. summary?: null|string; // LLM (AI) generated summary...??? outline?: null|string; // LLM (AI) generated outline...??? @@ -136,7 +139,7 @@ export interface Journal_Entry { id: string; // actually "id_random" journal_entry_id: string; - journal_id: string; // This is the parent journal ID. If deleted, then delete all children journal entries. + // journal_id: string; // This is the parent journal ID. If deleted, then delete all children journal entries. // Essentially this is a change log of journal entries snapshot_id?: string; // This is the original journal ID. If deleted, then delete all children journal entries. @@ -150,6 +153,8 @@ export interface Journal_Entry { for_type?: null|string; for_id?: null|string; + template?: null|boolean; // Is this a template journal entry? If true, it can be used to create new journal entries. + activity_code?: null|string; category_code?: null|string; topic_code?: null|string; @@ -169,6 +174,7 @@ export interface Journal_Entry { professional?: null|boolean; name: string; // or the title + short_name?: null|string; // Short name for the journal entry, if any. Used for display purposes. Most likely for the templates list. summary?: null|string; // LLM (AI) generated summary...??? outline?: null|string; // LLM (AI) generated outline...??? // description?: null|string; // This is the description of the journal entry @@ -294,6 +300,7 @@ export class MySubClassedDexie extends Dexie { journal_id, code, account_id, + template, name, start_datetime, end_datetime, timezone, diff --git a/src/routes/journals/+layout.ts b/src/routes/journals/+layout.ts index b912dc62..e5059ac9 100644 --- a/src/routes/journals/+layout.ts +++ b/src/routes/journals/+layout.ts @@ -23,48 +23,6 @@ export async function load({ params, parent }) { console.log(`ae_acct = `, ae_acct); } - // let note_id = ae_acct.slct.note_id; // From root +layout.ts - // if (!note_id) { - // console.log(`ERROR: journals +layout.ts: The note_id was not found in the parent_data!!!`); - // // return false; - // } - - // let ae_params = {}; - - // if (browser) { - // if (note_id) { - // let load_note_obj_li = journals_func.load_ae_obj_li__note({ - // api_cfg: ae_acct.api, - // for_obj_type: 'account', - // for_obj_id: account_id, - // enabled: 'enabled', - // hidden: 'not_hidden', - // limit: 20, - // // order_by_li: {}, - // params: ae_params, - // try_cache: true, - // log_lvl: log_lvl - // }); - // ae_acct.slct.note_obj_li = load_note_obj_li; - // } - // } - - // let load_note_obj = journals_func.load_ae_obj_id__note({ - // api_cfg: ae_acct.api, - // note_id: note_id, - // try_cache: false - // }); - - // ae_acct.slct.note_obj = load_note_obj; - - // if (browser) { - // console.log(`Browser: ${browser}`); - // journals_func.db_save_ae_obj_li__note({ - // obj_type: 'note', - // obj_li: [load_note_obj_li], - // }); - // } - // let submenu = { // main: {name: 'Main', href: '/journals', access: false}, // // manage: {name: 'Manage', href: '/journals/manage', access: 'administrator', disable: true, hide: true}, diff --git a/src/routes/journals/+page.ts b/src/routes/journals/+page.ts index acf7e782..49a48d34 100644 --- a/src/routes/journals/+page.ts +++ b/src/routes/journals/+page.ts @@ -28,6 +28,7 @@ export async function load({ parent }) { let load_journal_obj_li = journals_func.load_ae_obj_id__journal({ api_cfg: ae_acct.api, journal_id: journal_id, + hidden: 'all', // 'not_hidden' to load only visible entries // params: ae_params, try_cache: true, log_lvl: log_lvl @@ -40,7 +41,7 @@ export async function load({ parent }) { for_obj_type: 'account', for_obj_id: account_id, inc_entry_li: true, - hidden: 'not_hidden', + hidden: 'all', // 'not_hidden' enabled: 'enabled', // order_by_li: {'priority': 'DESC', 'sort': 'DESC', 'name': 'ASC', 'updated_on': 'DESC', 'created_on': 'DESC'}, limit: 25, diff --git a/src/routes/journals/[journal_id]/+layout.ts b/src/routes/journals/[journal_id]/+layout.ts index 296b4a63..a6e2d0f8 100644 --- a/src/routes/journals/[journal_id]/+layout.ts +++ b/src/routes/journals/[journal_id]/+layout.ts @@ -32,6 +32,9 @@ export async function load({ params, parent }) { api_cfg: ae_acct.api, journal_id: journal_id, inc_entry_li: true, + enabled: 'enabled', + hidden: 'all', // 'not_hidden' to load only visible entries + limit: 99, try_cache: true, log_lvl: log_lvl }); 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 a4edb964..0beb320e 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 @@ -65,104 +65,6 @@ let lq__journal_entry_obj = $derived(liveQuery(async () => { return results; })); -// let lq__journal_entry_obj_li = $derived(liveQuery(async () => { -// if (log_lvl) { -// console.log(`$lq__journal_entry_obj.cfg_json = `, $lq__journal_entry_obj?.cfg_json); -// } -// if ($lq__journal_entry_obj?.cfg_json?.entry_group_sort === 'DESC') { -// let results = await db_journals.journal_entry -// // .orderBy('updated_on') -// .where('journal_entry_id') -// .equals($journals_slct?.journal_entry_id ?? '') // null or undefined does not reset things like '' does -// .reverse() -// // .sortBy('tmp_sort_2'); -// .sortBy('updated_on'); -// // .sortBy('title'); - -// return results; -// } else { -// console.log(`lq__journal_entry_obj_li - default query using journal_entry_id: ${$journals_slct?.journal_entry_id}`); -// let results = await db_journals.journal_entry -// .where('journal_entry_id') -// .equals($journals_slct?.journal_entry_id ?? '') // null or undefined does not reset things like '' does -// // .reverse() -// .sortBy('updated_on'); - -// return results; -// } - -// })); - -// let lq__journal_entry_obj = $derived(liveQuery(async () => { -// if (log_lvl) { -// console.log(`lq__journal_entry_obj: journal_entry_id = ${$journals_slct?.journal_entry_id}`); -// } -// if ($journals_slct.journal_entry_id) { -// let results = await db_journals.journal_entry -// .get($journals_slct.journal_entry_id); // null or undefined does not reset things like '' does - -// return results; -// } -// // const results = await db_journals.journal_entry -// // .get($journals_slct.journal_entry_id); // null or undefined does not reset things like '' does - -// // return results; -// })); - - -$effect(() => { - // if ($journals_trig.journal_entry_li) { - // $journals_trig.journal_entry_li = false; - - // if (log_lvl) { - // console.log(`Triggered: $journals_trig.journal_entry_li`); - // } - - // if ($journals_loc.qry__enabled !== 'all' || $journals_loc.qry__hidden !== 'all') { - // console.log(`Deleting disabled or hidden journal entry.`); - // // let results = db_journals.journal_entry - // // .where('enable') - // // .notEqual(true) - // // .delete(); - // let results = db_journals.journal_entry - // .clear(); - // console.log(`Deleted ${results} disabled journal entry.`); - - // } - // if ($journals_loc.qry__hidden !== 'all') { - // console.log(`Deleting hidden journal entry.`); - // let results = db_journals.journal_entry - // .clear(); - // console.log(`Deleted ${results} hidden journal entry.`); - - // } - // let results = db_journals.journal_entry - // .where('enable') - // .equals('false') - // .delete(); - // console.log(`Deleted ${results} disabled journal entry.`); - - // $journals_prom.load__journal_entry_obj_li = journals_func.load_ae_obj_li__journal_entry({ - // api_cfg: $ae_api, - // for_obj_type: 'journal', - // for_obj_id: $journals_slct.journal_entry_id, - // enabled: $journals_loc.qry__enabled, - // hidden: $journals_loc.qry__hidden, - // limit: $journals_loc.qry__limit, - // order_by_li: $journals_loc.qry__order_by_li, - // try_cache: true, - // log_lvl: log_lvl, - // }); - // } - }); - -if (browser) { - // console.log('Browser environment detected.'); - - // let message = {'journal_entry_id': $journals_slct?.journal_entry_id ?? null}; - // window.parent.postMessage(message, "*"); -} - 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 979887c7..e6fb3e91 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 @@ -11,7 +11,7 @@ import { Flag, FlagOff, FileX, Fingerprint, Globe, Group, MessageSquareWarning, Minus, - NotebookPen, NotebookText, + NotebookPen, NotebookText, NotepadTextDashed, Pencil, Plus, RemoveFormatting, Search, @@ -563,6 +563,45 @@ $effect(() => { {/if} + + + +