Improved the way saving and updating of Journal Entry records work.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
// *** Import Svelte specific
|
||||
import { goto } from '$app/navigation';
|
||||
import { clipboard } from '@skeletonlabs/skeleton';
|
||||
// import { clipboard } from '@skeletonlabs/skeleton';
|
||||
|
||||
import {
|
||||
ArrowDown01, ArrowDown10, ArrowDownUp,
|
||||
@@ -43,8 +43,11 @@ let ae_promises: key_val = $state({});
|
||||
// let ae_trigger: any = null;
|
||||
// let ae_triggers: key_val = {};
|
||||
|
||||
// let orig_entry_obj: key_val = $state({});
|
||||
let orig_entry_obj: key_val|null = null;
|
||||
let tmp_entry_obj_changed: boolean = $state(false);
|
||||
let tmp_entry_obj: key_val = $state({});
|
||||
// let tmp_entry_obj: key_val = { ...$lq__journal_entry_obj };
|
||||
|
||||
// let tmp_entry_obj = $derived(async () => {
|
||||
// [$lq__journal_entry_obj],
|
||||
@@ -56,18 +59,25 @@ let tmp_entry_obj: key_val = $state({});
|
||||
|
||||
|
||||
$effect(() => {
|
||||
if ($lq__journal_entry_obj) {
|
||||
if ($lq__journal_entry_obj && !orig_entry_obj) {
|
||||
// console.log('TEST: orig_entry_obj?', orig_entry_obj);
|
||||
// console.log('TEST: Journal entry object available');
|
||||
orig_entry_obj = { ...$lq__journal_entry_obj };
|
||||
tmp_entry_obj = { ...$lq__journal_entry_obj };
|
||||
tmp_entry_obj_changed = false;
|
||||
} else {
|
||||
console.log('TEST: No journal entry object available');
|
||||
// console.log('TEST: No journal entry object available');
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (tmp_entry_obj) {
|
||||
// console.log('TEST: tmp_entry_obj available; marking tmp_entry_obj as changed');
|
||||
tmp_entry_obj_changed = JSON.stringify(tmp_entry_obj) != JSON.stringify($lq__journal_entry_obj);
|
||||
// tmp_entry_obj_changed = JSON.stringify(tmp_entry_obj) != JSON.stringify(orig_entry_obj);
|
||||
} else {
|
||||
console.log('TEST: No tmp_entry_obj available');
|
||||
// console.log('TEST: No tmp_entry_obj available');
|
||||
tmp_entry_obj_changed = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -107,6 +117,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -364,6 +375,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -436,6 +448,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -474,6 +487,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -514,6 +528,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -552,6 +567,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -590,6 +606,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -628,6 +645,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -667,6 +685,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -698,6 +717,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -819,6 +839,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -873,6 +894,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -915,6 +937,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -954,6 +977,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -974,7 +998,12 @@ $effect(() => {
|
||||
placeholder="Group"
|
||||
onchange={() => {
|
||||
let data_kv = {
|
||||
group: tmp_entry_obj.group
|
||||
alert_msg: tmp_entry_obj?.alert_msg,
|
||||
category_code: tmp_entry_obj?.category_code,
|
||||
content: tmp_entry_obj?.content,
|
||||
group: tmp_entry_obj?.group,
|
||||
name: tmp_entry_obj?.name,
|
||||
tags: tmp_entry_obj?.tags,
|
||||
};
|
||||
journals_func.update_ae_obj__journal_entry({
|
||||
api_cfg: $ae_api,
|
||||
@@ -984,6 +1013,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -1016,6 +1046,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
@@ -1055,6 +1086,7 @@ $effect(() => {
|
||||
}).then(() => {
|
||||
// Optionally, you can provide feedback to the user
|
||||
// alert('Journal entry updated successfully!');
|
||||
orig_entry_obj = null;
|
||||
}).catch((error) => {
|
||||
console.error('Error updating journal entry:', error);
|
||||
alert('Failed to update journal entry.');
|
||||
|
||||
Reference in New Issue
Block a user