Finally work on the Journals to fix some bugs. Now with much better append and prepend to Journal Entry.
This commit is contained in:
@@ -39,6 +39,7 @@ let ae_promises: key_val = $state({});
|
||||
|
||||
let tmp_entry_obj: key_val = $state({});
|
||||
let tmp_entry_obj_add_timestamp_header: boolean = $state(true);
|
||||
let tmp_entry_obj_add_timestamp_header_w_day_of_week: boolean = $state(true);
|
||||
let tmp_entry_obj_add_text_header: string = $state('');
|
||||
let tmp_entry_obj_add_text: string = $state('');
|
||||
let tmp_entry_obj_changed: boolean = $state(false);
|
||||
@@ -432,6 +433,7 @@ $effect(() => {
|
||||
tmp_entry_obj = journals_journal_entry_obj;
|
||||
}}
|
||||
class="btn btn-icon btn-sm preset-tonal-surface border border-surface-500 hover:preset-filled-secondary-500 transition"
|
||||
title="{$lq__journal_obj?.cfg_json?.entry_add_text == 'append' ? 'Append to Journal Entry' : 'Prepend to Journal Entry'}"
|
||||
>
|
||||
<ListPlus />
|
||||
<!-- Append -->
|
||||
@@ -624,17 +626,23 @@ $effect(() => {
|
||||
<!-- This should only have a textarea, Save button, and Cancel button. -->
|
||||
{#if $journals_sess.show__modal_append__journal_entry_id}
|
||||
<Modal
|
||||
title="Append to Journal Entry: {tmp_entry_obj?.name ?? tmp_entry_obj?.created_on} ({tmp_entry_obj?.journal_entry_id})"
|
||||
title="{$lq__journal_obj?.cfg_json?.entry_add_text == 'append' ? 'Append to Journal Entry' : 'Prepend to Journal Entry'}: {tmp_entry_obj?.name ?? tmp_entry_obj?.created_on} ({tmp_entry_obj?.journal_entry_id})"
|
||||
bind:open={$journals_sess.show__modal_append__journal_entry_id}
|
||||
autoclose={false}
|
||||
placement="top-center"
|
||||
size="xl"
|
||||
class="top-center bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200 rounded-lg border-gray-200 dark:border-gray-700 divide-gray-200 dark:divide-gray-700 shadow-md relative flex flex-col mx-auto w-full divide-y"
|
||||
class="
|
||||
top-center
|
||||
bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200
|
||||
rounded-lg border-gray-200 dark:border-gray-700
|
||||
divide-gray-200 dark:divide-gray-700
|
||||
shadow-md relative
|
||||
flex flex-col gap-1 mx-auto w-full"
|
||||
>
|
||||
<div class="modal">
|
||||
<div class="modal-box">
|
||||
<!-- <h3 class="font-bold text-lg">Edit Journal</h3> -->
|
||||
<div class="py-4">
|
||||
<div class="flex flex-col gap-1">
|
||||
|
||||
<!-- Checkbox for using the timestamp as the Markdown header. This will be pre-pended to any text header given, if any. -->
|
||||
<div>
|
||||
@@ -671,6 +679,40 @@ $effect(() => {
|
||||
>
|
||||
Use timestamp as Markdown header
|
||||
</label>
|
||||
|
||||
<input
|
||||
type="checkbox"
|
||||
id="append_timestamp_header_w_day_of_week"
|
||||
bind:checked={tmp_entry_obj_add_timestamp_header_w_day_of_week}
|
||||
class:border-orange-200={$ae_loc.edit_mode}
|
||||
class:hover:border-orange-500={$ae_loc.edit_mode}
|
||||
class="
|
||||
p-2
|
||||
bg-slate-100 text-gray-900
|
||||
dark:bg-slate-900 dark:text-gray-100
|
||||
shadow-lg rounded-lg
|
||||
border border-gray-200 dark:border-gray-700
|
||||
hover:border-gray-500 dark:hover:border-gray-500
|
||||
inline-block
|
||||
"
|
||||
/>
|
||||
<label
|
||||
for="append_timestamp_header_w_day_of_week"
|
||||
class:border-orange-200={$ae_loc.edit_mode}
|
||||
class:hover:border-orange-500={$ae_loc.edit_mode}
|
||||
class="
|
||||
p-2
|
||||
bg-slate-100 text-gray-900
|
||||
dark:bg-slate-900 dark:text-gray-100
|
||||
shadow-lg rounded-lg
|
||||
border border-gray-200 dark:border-gray-700
|
||||
hover:border-gray-500 dark:hover:border-gray-500
|
||||
|
||||
inline-block
|
||||
"
|
||||
>
|
||||
Include day of week
|
||||
</label>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -732,11 +774,20 @@ $effect(() => {
|
||||
|
||||
// if ($lq__journal_obj?.cfg_json?.entry_add_text == 'prepend') {
|
||||
if (tmp_entry_obj_add_timestamp_header && tmp_entry_obj_add_text_header) {
|
||||
add_content = '## ' + ae_util.iso_datetime_formatter(new Date(), 'datetime_iso_12_no_seconds') + ' - ' + tmp_entry_obj_add_text_header.trim() + '\n' + tmp_entry_obj_add_text.trim() + '\n\n';
|
||||
add_content = '## ' + ae_util.iso_datetime_formatter(new Date(), 'datetime_iso_12_no_seconds')
|
||||
+ (tmp_entry_obj_add_timestamp_header_w_day_of_week ? ' ('+ae_util.iso_datetime_formatter(new Date(), 'week_long')+')' : '')
|
||||
+ ' - ' + tmp_entry_obj_add_text_header.trim() + '\n' + tmp_entry_obj_add_text.trim() + '\n\n';
|
||||
} else if (tmp_entry_obj_add_timestamp_header) {
|
||||
add_content = '## ' + ae_util.iso_datetime_formatter(new Date(), 'datetime_iso_12_no_seconds') + '\n' + tmp_entry_obj_add_text.trim() + '\n\n';
|
||||
add_content = '## ' + ae_util.iso_datetime_formatter(new Date(), 'datetime_iso_12_no_seconds')
|
||||
+
|
||||
(tmp_entry_obj_add_timestamp_header_w_day_of_week ? ' ('+ae_util.iso_datetime_formatter(new Date(), 'week_long')+')' : '')
|
||||
+ '\n'
|
||||
+ tmp_entry_obj_add_text.trim() + '\n\n';
|
||||
} else if (tmp_entry_obj_add_text_header) {
|
||||
add_content = '## ' + tmp_entry_obj_add_text_header.trim() + '\n' + tmp_entry_obj_add_text.trim() + '\n\n';
|
||||
add_content = '## ' + tmp_entry_obj_add_text_header.trim()
|
||||
+
|
||||
(tmp_entry_obj_add_timestamp_header_w_day_of_week ? ' ('+ae_util.iso_datetime_formatter(new Date(), 'week_long')+')' : '')
|
||||
+ '\n' + tmp_entry_obj_add_text.trim() + '\n\n';
|
||||
}
|
||||
// } else {
|
||||
// if (tmp_entry_obj_add_timestamp_header && tmp_entry_obj_add_text_header) {
|
||||
@@ -755,9 +806,12 @@ $effect(() => {
|
||||
// }
|
||||
// if (tmp_entry_obj_add_text) {
|
||||
if ($lq__journal_obj?.cfg_json?.entry_add_text == 'prepend') {
|
||||
// Handle prepending content
|
||||
new_content = add_content + new_content;
|
||||
} else {
|
||||
new_content = new_content + add_content;
|
||||
// Handle appending content
|
||||
// Add one more line break before the content to be appended
|
||||
new_content = new_content + '\n' + add_content;
|
||||
}
|
||||
// new_content = new_content + tmp_entry_obj_add_text.trim();
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user