From 35354a9d0fbb1d1bb6ccebbc77389d68e8639de8 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Fri, 21 Mar 2025 11:03:38 -0400 Subject: [PATCH] Work on the new Journals. Just saving things while they are working well. --- package-lock.json | 21 +- package.json | 2 +- .../ae_journals/ae_journals__journal_entry.ts | 12 +- src/lib/ae_journals/ae_journals_stores.ts | 23 +- src/lib/ae_journals/db_journals.ts | 21 +- src/routes/journals/+layout.svelte | 4 +- src/routes/journals/[journal_id]/+page.svelte | 261 ++++++++++---- .../ae_comp__journal_entry_obj_id_view.svelte | 327 +++++++++++++++++- .../ae_comp__journal_entry_obj_li.svelte | 76 +++- .../journals/ae_comp__journal_obj_li.svelte | 1 + 10 files changed, 630 insertions(+), 118 deletions(-) diff --git a/package-lock.json b/package-lock.json index 399bad68..06489c9a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.2.4", "dependencies": { "@floating-ui/dom": "^1.6.0", + "@lucide/svelte": "^0.483.0", "@popperjs/core": "^2.11.0", "@tiptap/extension-bullet-list": "^2.10.2", "@tiptap/extension-document": "^2.10.2", @@ -67,7 +68,6 @@ "flowbite": "^3.0.0", "highlight.js": "^11.10.0", "lowlight": "^3.2.0", - "lucide-svelte": "^0", "mode-watcher": "^0.5.0", "postcss": "^8.4.41", "prettier": "^3.1.1", @@ -889,6 +889,15 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@lucide/svelte": { + "version": "0.483.0", + "resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-0.483.0.tgz", + "integrity": "sha512-b3SbhMIgVJAj/rPa3go6uplTzaFkJzz91TSPO8I8gc2evtHOA2OgSmPYz0S+yEKFIWqLUZ4gika19ljV+tnmyQ==", + "license": "ISC", + "peerDependencies": { + "svelte": "^5" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -4668,16 +4677,6 @@ "dev": true, "license": "ISC" }, - "node_modules/lucide-svelte": { - "version": "0.477.0", - "resolved": "https://registry.npmjs.org/lucide-svelte/-/lucide-svelte-0.477.0.tgz", - "integrity": "sha512-w/zj6/CXTtTizIeo8SuWGYu0u45CJ7cD2AtNzIObVHZrWXNgaIIX/2cI25wybjSmYHIi4pub2TLv/kNPKiB3ww==", - "dev": true, - "license": "ISC", - "peerDependencies": { - "svelte": "^3 || ^4 || ^5.0.0-next.42" - } - }, "node_modules/magic-string": { "version": "0.30.17", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", diff --git a/package.json b/package.json index c3457617..14b08aa5 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,6 @@ "flowbite": "^3.0.0", "highlight.js": "^11.10.0", "lowlight": "^3.2.0", - "lucide-svelte": "^0", "mode-watcher": "^0.5.0", "postcss": "^8.4.41", "prettier": "^3.1.1", @@ -88,6 +87,7 @@ "type": "module", "dependencies": { "@floating-ui/dom": "^1.6.0", + "@lucide/svelte": "^0.483.0", "@popperjs/core": "^2.11.0", "@tiptap/extension-bullet-list": "^2.10.2", "@tiptap/extension-document": "^2.10.2", diff --git a/src/lib/ae_journals/ae_journals__journal_entry.ts b/src/lib/ae_journals/ae_journals__journal_entry.ts index 62f920d0..3352f5cf 100644 --- a/src/lib/ae_journals/ae_journals__journal_entry.ts +++ b/src/lib/ae_journals/ae_journals__journal_entry.ts @@ -165,6 +165,11 @@ export async function create_ae_obj__journal_entry( console.log(`*** create_ae_obj__journal_entry() *** journal_id=${journal_id}`); } + if (!journal_id) { + console.log(`ERROR: Journals - Entry - journal_id required to create`); + return false; + } + ae_promises.create__journal_entry = await api.create_ae_obj_crud({ api_cfg: api_cfg, obj_type: 'journal_entry', @@ -348,9 +353,10 @@ export async function db_save_ae_obj_li__journal_entry( person_id: obj.person_id_random, - activity: obj.activity, - category: obj.category, - topic: obj.topic, + activity_code: obj.activity_code, + category_code: obj.category_code, + type_code: obj.type_code, + topic_code: obj.topic_code, public: obj.public, private: obj.private, diff --git a/src/lib/ae_journals/ae_journals_stores.ts b/src/lib/ae_journals/ae_journals_stores.ts index fd6dbbb1..244841ba 100644 --- a/src/lib/ae_journals/ae_journals_stores.ts +++ b/src/lib/ae_journals/ae_journals_stores.ts @@ -7,7 +7,7 @@ import type { key_val } from '$lib/ae_stores'; /* *** BEGIN *** Initialize journals_local_data_struct */ // This is for longer term or sticky app data. This should be stored to *local* storage. -// Updated 2024-08-20 +// Updated 2025-03-20 let journals_local_data_struct: key_val = { ver: '2024-08-20_19', // Shared @@ -27,6 +27,15 @@ let journals_local_data_struct: key_val = { qry__offset: 0, qry__journal_id: null, + journal: { + edit: false, + edit_kv: {}, + }, + entry: { + edit: false, + edit_kv: {}, + }, + }; // console.log(`AE Stores - App Journals Local Storage Data:`, journals_local_data_struct); @@ -35,10 +44,9 @@ export let journals_loc: Writable = localStorageStore('ae_journals_loc' // console.log(`AE Stores - App Local Storage Data:`, get(ae_loc)); - /* *** BEGIN *** Initialize journals_session_data_struct */ // Temporary app data. This is lost if the page is refreshed or using different tabs/windows. This should be stored to *session* storage. -// Updated 2024-08-20 +// Updated 2025-03-20 let journals_session_data_struct: key_val = { ver: '2024-08-20_19', log_lvl: 1, @@ -53,6 +61,15 @@ let journals_session_data_struct: key_val = { show_list__journal_entry_li_group: true, show__modal_view__journal_entry_id: null, show__modal_edit__journal_entry_id: null, + + journal: { + edit: false, + edit_kv: {}, + }, + entry: { + edit: false, + edit_kv: {}, + }, }; // console.log(`AE Stores - App Journals Session Storage Data:`, journals_session_data_struct); export let journals_sess = writable(journals_session_data_struct); diff --git a/src/lib/ae_journals/db_journals.ts b/src/lib/ae_journals/db_journals.ts index d71eb650..5ffafdc1 100644 --- a/src/lib/ae_journals/db_journals.ts +++ b/src/lib/ae_journals/db_journals.ts @@ -147,7 +147,11 @@ export interface Journal_Entry { for_type?: null|string; for_id?: null|string; + activity_code?: null|string; + category_code?: null|string; + topic_code?: null|string; type_code?: null|string; + journal_entry_type?: null|string; // This is the type of journal entry account_id?: null|string; // Owner account of the journal @@ -155,10 +159,6 @@ export interface Journal_Entry { // event_id?: null|string; // Assign to an event??? // location_id?: null|string; // Assign to a location??? - activity?: null|string; - category?: null|string; - topic?: null|string; - public?: null|boolean; private?: null|boolean; personal?: null|boolean; @@ -176,10 +176,23 @@ export interface Journal_Entry { start_datetime?: null|Date; end_datetime?: null|Date; timezone?: null|string; + seconds?: null|number; // Duration in seconds + + location?: null|string; // Location of the journal entry + latitude?: null|number; // Latitude of the journal entry + longitude?: null|number; // Longitude of the journal entry + + billable?: null|boolean; // Is this billable? + bill_to?: null|string; // Who to bill for this journal entry + bill_rate?: null|number; // Rate to bill for this journal entry + billable_minutes?: null|number; // Billable minutes for this journal entry alert?: null|boolean; // LLM (AI) generated summary...??? alert_msg?: null|string; // LLM (AI) generated summary...??? + parent_id?: null|string; // This is the parent journal entry ID. If deleted, then delete all children journal entries. + related_entry_id_li?: null|key_val; // List of related journal entry IDs + // cfg_json?: null|key_val; // This is the configuration JSON for the journal entry data_json?: null|string; // We always need to store something extra... diff --git a/src/routes/journals/+layout.svelte b/src/routes/journals/+layout.svelte index d5647511..00c2899d 100644 --- a/src/routes/journals/+layout.svelte +++ b/src/routes/journals/+layout.svelte @@ -134,7 +134,7 @@ if (browser) { {/if} -
+
diff --git a/src/routes/journals/[journal_id]/+page.svelte b/src/routes/journals/[journal_id]/+page.svelte index b9d8e6b5..e057077b 100644 --- a/src/routes/journals/[journal_id]/+page.svelte +++ b/src/routes/journals/[journal_id]/+page.svelte @@ -1,6 +1,6 @@ @@ -183,16 +246,76 @@ if (browser) { - - - - View Other Journals - +
+ {$journals_loc.filter__category_code} + + + + View Other Journals + + + + + + + + + +
--> - {/if} - + class="novi_btn btn btn-sm variant-ghost-warning hover:variant-filled-warning transition" + title={`Cancel new journal entry`} + > + Cancel + + New Journal Entry - Edit Journal Content: + {$lq__journal_obj?.name} - {$lq__journal_entry_obj?.name ?? 'New Journal Content'} - {/snippet} - --> + + 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 3696f129..6a5ead4c 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 @@ -1,11 +1,16 @@ -
+
-
+{#if $lq__journal_entry_obj} +

{@html $lq__journal_entry_obj?.name ?? 'Loading...'} {#await $journals_prom.load__journal_entry_obj_li} @@ -35,16 +59,299 @@ let { log_lvl = 0, lq__journal_entry_obj }: Props = $props(); {/await}

- {$lq__journal_entry_obj?.private} - {$lq__journal_entry_obj?.public} - {$lq__journal_entry_obj?.personal} - {$lq__journal_entry_obj?.professional} +
+ + + + + + + + + + + + + + + + + +
+
-
+
 {
+    if ($ae_loc.trusted_access) {
+        // Toggle edit mode
+        $journals_loc.entry.edit = !$journals_loc.entry.edit;
+        $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = $journals_loc.entry.edit;
+    }
+    }}
+    class:hidden={!$ae_loc.trusted_access || $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id]}
+    >
 {$lq__journal_entry_obj?.content}
 
+
+ + + + + +
+ +
{$lq__journal_entry_obj?.keywords} {#if $ae_loc.trusted_access && $ae_loc.edit_mode} @@ -52,4 +359,6 @@ let { log_lvl = 0, lq__journal_entry_obj }: Props = $props(); {/if}
+{/if} +
\ No newline at end of file diff --git a/src/routes/journals/ae_comp__journal_entry_obj_li.svelte b/src/routes/journals/ae_comp__journal_entry_obj_li.svelte index 394adce6..b2d909dc 100644 --- a/src/routes/journals/ae_comp__journal_entry_obj_li.svelte +++ b/src/routes/journals/ae_comp__journal_entry_obj_li.svelte @@ -1,13 +1,18 @@