Things look cleaner now
This commit is contained in:
@@ -868,16 +868,16 @@ function handle_marked(text_string: string) {
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<h2 class="journal_entry__name h4 md:h3">
|
||||
<h2 class="journal_entry__name h4 md:h3 grow">
|
||||
|
||||
<!-- <span class="fas fa-spinner fa-spin"></span> -->
|
||||
<span class="journal_entry__name inline-block">
|
||||
<!-- <span class="journal_entry__name inline-block"> -->
|
||||
<!-- Allow for toggle between view and edit of journal entry. -->
|
||||
{#if $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'}
|
||||
<input
|
||||
type="text"
|
||||
bind:value={tmp_entry_obj.name}
|
||||
class="input input-bordered w-96"
|
||||
class="input input-bordered min-w-60 w-full"
|
||||
placeholder="Journal Entry Name"
|
||||
title="Edit the name of this journal entry"
|
||||
/>
|
||||
@@ -890,7 +890,7 @@ function handle_marked(text_string: string) {
|
||||
{ae_util.iso_datetime_formatter($lq__journal_entry_obj?.created_on, 'datetime_iso_12_no_seconds')}
|
||||
{/if}
|
||||
{/if}
|
||||
</span>
|
||||
<!-- </span> -->
|
||||
|
||||
</h2>
|
||||
</div>
|
||||
@@ -953,6 +953,221 @@ function handle_marked(text_string: string) {
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<span
|
||||
class="
|
||||
flex flex-row flex-wrap gap-1 items-center justify-center
|
||||
"
|
||||
>
|
||||
<!-- Entry alert status -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_alert}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.alert = !$lq__journal_entry_obj?.alert;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle alert status of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.alert}
|
||||
<Siren strokeWidth="2.5" color="red" />
|
||||
{:else}
|
||||
<MessageSquareWarning strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<!-- Entry alert message -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// tmp_entry_obj.alert_msg = !$lq__journal_entry_obj?.alert_msg;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class:hidden={!$lq__journal_entry_obj?.alert}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle alert message of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.alert_msg}
|
||||
<Skull strokeWidth="2.5" color="red" />
|
||||
{:else}
|
||||
<MessageSquareWarning strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<span class="flex flex-row flex-wrap gap-0.5 items-center justify-center">
|
||||
<!-- Only show this private toggle if not private or in edit mode. -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={($lq__journal_obj.cfg_json?.hide_btn_private) || (tmp_entry_obj?.private && !$ae_loc.edit_mode)}
|
||||
onclick={() => {
|
||||
// Allow for toggle between private (encrypted) and not,
|
||||
// and if private, allow for decryption.
|
||||
if (!$lq__journal_entry_obj?.private && tmp_entry_obj?.content) {
|
||||
// Handle converting to private (encrypted) content
|
||||
if (confirm('Are you sure you want to encrypt and resave this journal entry?')) {
|
||||
// Setting private to true will cause the update_journal_entry() function to encrypt the content.
|
||||
tmp_entry_obj.private = true;
|
||||
update_journal_entry();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ($lq__journal_entry_obj?.private && tmp_entry_obj?.content_encrypted) {
|
||||
// Handle converting to not private (decrypted) content
|
||||
if (confirm('Are you sure you want to decrypt and resave this journal entry unencrypted?')) {
|
||||
// tmp_entry_obj.private = !$lq__journal_entry_obj?.private;
|
||||
// update_journal_entry();
|
||||
|
||||
// Setting private to false will cause the update_journal_entry() function to decrypt the content. This will also copy it to tmp_entry_obj.content.
|
||||
tmp_entry_obj.private = false;
|
||||
// tmp_entry_obj.
|
||||
// handle_decrypt_content();
|
||||
update_journal_entry();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle private visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.private}
|
||||
<Fingerprint strokeWidth="2.5" color="green" />
|
||||
<!-- Private (Encrypted) -->
|
||||
{:else}
|
||||
<Fingerprint strokeWidth="1" color="gray" />
|
||||
<!-- Not Private -->
|
||||
{/if}
|
||||
|
||||
</button>
|
||||
|
||||
<!-- Only show this encryption toggle if entry is private. -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
if (tmp_entry_obj?.private && decrypted_content) {
|
||||
decrypted_content = '';
|
||||
// tmp_entry_obj.content = null;
|
||||
} else if (tmp_entry_obj?.private && tmp_entry_obj?.content_encrypted) {
|
||||
if (!$journals_loc?.entry?.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id]) {
|
||||
if (confirm('Are you sure you want to decrypt the content to view/edit?')) {
|
||||
$journals_loc.entry.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id] = true;
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = 'current';
|
||||
|
||||
if (!tmp_entry_obj?.content && tmp_entry_obj?.content_encrypted) {
|
||||
console.log('TEST: Decrypting the content...');
|
||||
tmp_entry_obj.content = await ae_util.decrypt_wrapper(tmp_entry_obj?.content_encrypted, journal_key);
|
||||
tmp_entry_obj.content_md_html = handle_marked(tmp_entry_obj?.content);
|
||||
}
|
||||
if (!tmp_entry_obj?.history && tmp_entry_obj?.history_encrypted) {
|
||||
console.log('TEST: Decrypting the history...');
|
||||
tmp_entry_obj.history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
|
||||
tmp_entry_obj.history_md_html = handle_marked(tmp_entry_obj?.history);
|
||||
}
|
||||
// trigger_decrypt = true;
|
||||
// handle_decrypt_content();
|
||||
// handle_decrypt_string(tmp_entry_obj?.content_encrypted, journal_key).then((result) => {
|
||||
// decrypted_content = result;
|
||||
// console.log('TEST: Decrypted content:', decrypted_content);
|
||||
// });
|
||||
// decrypted_content = await ae_util.decrypt_wrapper(tmp_entry_obj?.content_encrypted, journal_key);
|
||||
|
||||
// // decrypted_content = await handle_decrypt_string(tmp_entry_obj?.content_encrypted, journal_key);
|
||||
// tmp_entry_obj.content = decrypted_content;
|
||||
// console.log('TEST: Decrypted content:', decrypted_content);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$journals_loc.entry.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
tmp_entry_obj.content = null;
|
||||
tmp_entry_obj.content_md_html = null;
|
||||
tmp_entry_obj.history = null;
|
||||
tmp_entry_obj.history_md_html = null;
|
||||
}
|
||||
}
|
||||
}}
|
||||
class:hidden={!$lq__journal_entry_obj?.private || !tmp_entry_obj?.content_encrypted}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle viewing/editing of private encrypted content"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.private && tmp_entry_obj?.content}
|
||||
<LockKeyholeOpen strokeWidth="2.5" color="red" />
|
||||
{:else if $lq__journal_entry_obj?.private && tmp_entry_obj?.content_encrypted}
|
||||
<LockKeyhole strokeWidth="2.5" color="green" />
|
||||
<!-- <Fingerprint strokeWidth="2.5" color="green" /> -->
|
||||
<!-- {:else if $lq__journal_entry_obj?.private}
|
||||
<Fingerprint strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<Fingerprint strokeWidth="1" color="gray" /> -->
|
||||
|
||||
{/if}
|
||||
|
||||
</button>
|
||||
</span>
|
||||
|
||||
<!-- Entry allowed to be public -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_public}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.public = !$lq__journal_entry_obj?.public;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle public visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.public}
|
||||
<Globe strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<Globe strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<!-- Entry marked as personal -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_personal}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.personal = !$lq__journal_entry_obj?.personal;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle personal visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.personal}
|
||||
<BookHeart strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<BookHeart strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<!-- Entry marked as professional -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_professional}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.professional = !$lq__journal_entry_obj?.professional;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle professional visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.professional}
|
||||
<BriefcaseBusiness strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<BriefcaseBusiness strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
</span>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<section class="relative">
|
||||
@@ -970,23 +1185,15 @@ function handle_marked(text_string: string) {
|
||||
<!-- Menu -->
|
||||
{#if show_menu}
|
||||
<div
|
||||
class="absolute top-12 right-0 bg-white dark:bg-gray-800 shadow-lg rounded-lg p-4 z-50 w-80"
|
||||
class="absolute top-12 right-0 bg-white dark:bg-gray-800 shadow-xl rounded-lg p-4 z-50 w-80 space-y-0.5 border border-gray-500"
|
||||
>
|
||||
|
||||
|
||||
<div class="flex flex-row flex-wrap gap-1 items-center justify-end">
|
||||
<!-- Category code for journal entry -->
|
||||
{#if $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'}
|
||||
<!-- <input
|
||||
type="text"
|
||||
bind:value={tmp_entry_obj.category_code}
|
||||
class="input input-bordered"
|
||||
placeholder="Category Code"
|
||||
title="Edit the category code for this journal entry"
|
||||
/> -->
|
||||
<!-- <div class="flex flex-row flex-wrap gap-1 items-center justify-end"> -->
|
||||
|
||||
<!-- Category code for journal entry -->
|
||||
<!-- Give list of categories to base the new entry on -->
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<div class="flex flex-row items-center justify-evenly gap-2 w-full">
|
||||
<span class="text-sm text-gray-500 hidden sm:inline">
|
||||
Category:
|
||||
</span>
|
||||
@@ -995,7 +1202,8 @@ function handle_marked(text_string: string) {
|
||||
variant-soft-primary
|
||||
hover:variant-filled-primary
|
||||
transition
|
||||
text-xs
|
||||
text-sm
|
||||
w-full
|
||||
"
|
||||
bind:value={tmp_entry_obj.category_code}
|
||||
onchange={(event) => {
|
||||
@@ -1018,40 +1226,20 @@ function handle_marked(text_string: string) {
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{:else}
|
||||
<!-- Should tags be here as well? -->
|
||||
|
||||
{#if $lq__journal_entry_obj.category_code}
|
||||
<!-- When clicked, this will change to edit the journal entry. -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// Toggle edit mode
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = 'current';
|
||||
// tmp_entry_obj.category_code = $lq__journal_entry_obj.category_code;
|
||||
console.log('Editing category:', tmp_entry_obj.category_code);
|
||||
}}
|
||||
class="btn btn-sm variant-ghost-secondary hover:variant-filled-secondary transition py-1 px-2"
|
||||
title={`Filter by category: ${$lq__journal_entry_obj.category_code}`}
|
||||
>
|
||||
<span class="text-sm text-gray-500">
|
||||
<Shapes class="mx-1 inline-block"/>
|
||||
</span>
|
||||
{$lq__journal_entry_obj.category_code ?? '-- no category --'}
|
||||
</button>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
|
||||
|
||||
<!-- Journal Entry Options: alert, private, public, personal, professional, template -->
|
||||
<div
|
||||
class="
|
||||
flex flex-row flex-wrap gap-1 items-center justify-center
|
||||
flex flex-row flex-wrap gap-0.5 items-center justify-evenly
|
||||
"
|
||||
>
|
||||
<span class="text-sm text-gray-500">
|
||||
<Settings strokeWidth="1" class="mx-1 inline-block" />
|
||||
Toggles:
|
||||
Flags:
|
||||
</span>
|
||||
|
||||
<!-- Entry alert status -->
|
||||
@@ -1318,6 +1506,113 @@ function handle_marked(text_string: string) {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Journal Entry history information and options -->
|
||||
<!-- If there is history, then we want a toggle button to show and hide the history. -->
|
||||
{#if ($lq__journal_entry_obj?.history || $lq__journal_entry_obj?.history_encrypted)}
|
||||
<div
|
||||
class="
|
||||
flex flex-row-reverse flex-wrap gap-1 items-center justify-center
|
||||
"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
if (!$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id]) {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = 'history';
|
||||
$journals_sess.show__content__journal_entry_history = 'view'
|
||||
} else if ($journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current') {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = 'history';
|
||||
$journals_sess.show__content__journal_entry_history = 'view'
|
||||
} else if ($journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history') {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
} else {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if ($journals_sess.show__content__journal_entry_history == 'view') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'hide';
|
||||
// } else if ($journals_sess.show__content__journal_entry_history == 'edit') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'hide';
|
||||
// } else if ($journals_sess.show__content__journal_entry_history == 'hide') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'view';
|
||||
// } else if (!$journals_sess.show__content__journal_entry_history) {
|
||||
// $journals_sess.show__content__journal_entry_history = 'view';
|
||||
// }
|
||||
|
||||
// !tmp_entry_obj?.history &&
|
||||
if (tmp_entry_obj?.history_encrypted) {
|
||||
decrypted_history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
|
||||
// decrypted_history = await handle_decrypt_string(tmp_entry_obj.history_encrypted, journal_key);
|
||||
console.log('Decrypted history:', decrypted_history);
|
||||
tmp_entry_obj.history = decrypted_history;
|
||||
}
|
||||
|
||||
}}
|
||||
class:variant-filled-secondary={$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history'}
|
||||
class:variant-soft-secondary={$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] != 'history'}
|
||||
class="btn btn-sm hover:variant-filled-secondary *:hover:inline lg:text-xs w-full"
|
||||
title="Toggle history of this journal entry"
|
||||
>
|
||||
{#if !$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] || $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'}
|
||||
<History strokeWidth="1" color="gray" />
|
||||
{:else if $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history'}
|
||||
<History strokeWidth="2.5" color="red" />
|
||||
{/if}
|
||||
<!-- <History strokeWidth="2.5" color="blue" /> -->
|
||||
<span class="hidden sm:inline text-sm">
|
||||
Review History</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={!($journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history')}
|
||||
onclick={async () => {
|
||||
if (!$journals_sess?.show__content__journal_entry_history || $journals_sess.show__content__journal_entry_history == 'view') {
|
||||
$journals_sess.show__content__journal_entry_history = 'edit';
|
||||
} else if ($journals_sess.show__content__journal_entry_history == 'edit') {
|
||||
$journals_sess.show__content__journal_entry_history = 'view';
|
||||
}
|
||||
console.log('History edit mode:', $journals_sess.show__content__journal_entry_history);
|
||||
|
||||
if (tmp_entry_obj?.history_encrypted) {
|
||||
let history_cleaned: null|string = null;
|
||||
let history_md_html: null|string = null;
|
||||
|
||||
decrypted_history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
|
||||
|
||||
// decrypted_history = await handle_decrypt_string(tmp_entry_obj.history_encrypted, journal_key);
|
||||
console.log('Decrypted history:', decrypted_history);
|
||||
tmp_entry_obj.history = decrypted_history;
|
||||
|
||||
history_cleaned = decrypted_history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
|
||||
history_md_html = await marked.parse(history_cleaned ?? '') ?? null;
|
||||
tmp_entry_obj.history_md_html = history_md_html;
|
||||
// console.log('History cleaned:', history_cleaned);
|
||||
console.log('History md html:', history_md_html);
|
||||
}
|
||||
}}
|
||||
class="btn btn-sm variant-soft-secondary hover:variant-filled-secondary *:hover:inline lg:text-xs"
|
||||
title="Toggle edit mode for history of this journal entry"
|
||||
>
|
||||
{#if !$journals_sess?.show__content__journal_entry_history || $journals_sess?.show__content__journal_entry_history == 'view'}
|
||||
<Pencil strokeWidth="2.5" color="blue" class="inline-block" />
|
||||
{:else if $journals_sess?.show__content__journal_entry_history == 'edit'}
|
||||
<PenLine strokeWidth="2.5" color="red" class="inline-block" />
|
||||
{/if}
|
||||
<span class="hidden sm:inline">
|
||||
{#if !$journals_sess?.show__content__journal_entry_history || $journals_sess?.show__content__journal_entry_history == 'view'}
|
||||
Edit?
|
||||
{:else if $journals_sess.show__content__journal_entry_history == 'edit'}
|
||||
View?
|
||||
{/if}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="divider my-2"></div>
|
||||
|
||||
<!-- Core Object Properties -->
|
||||
@@ -1586,326 +1881,15 @@ function handle_marked(text_string: string) {
|
||||
|
||||
|
||||
|
||||
<section
|
||||
<!-- <section
|
||||
class="flex flex-row flex-wrap gap-1 items-center justify-between w-full"
|
||||
>
|
||||
|
||||
<span
|
||||
class="
|
||||
flex flex-row flex-wrap gap-1 items-center justify-center
|
||||
"
|
||||
>
|
||||
<!-- Entry alert status -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_alert}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.alert = !$lq__journal_entry_obj?.alert;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle alert status of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.alert}
|
||||
<Siren strokeWidth="2.5" color="red" />
|
||||
{:else}
|
||||
<MessageSquareWarning strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<!-- Entry alert message -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// tmp_entry_obj.alert_msg = !$lq__journal_entry_obj?.alert_msg;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class:hidden={!$lq__journal_entry_obj?.alert}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle alert message of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.alert_msg}
|
||||
<Skull strokeWidth="2.5" color="red" />
|
||||
{:else}
|
||||
<MessageSquareWarning strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<span class="flex flex-row flex-wrap gap-0.5 items-center justify-center">
|
||||
<!-- Only show this private toggle if not private or in edit mode. -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={($lq__journal_obj.cfg_json?.hide_btn_private) || (tmp_entry_obj?.private && !$ae_loc.edit_mode)}
|
||||
onclick={() => {
|
||||
// Allow for toggle between private (encrypted) and not,
|
||||
// and if private, allow for decryption.
|
||||
if (!$lq__journal_entry_obj?.private && tmp_entry_obj?.content) {
|
||||
// Handle converting to private (encrypted) content
|
||||
if (confirm('Are you sure you want to encrypt and resave this journal entry?')) {
|
||||
// Setting private to true will cause the update_journal_entry() function to encrypt the content.
|
||||
tmp_entry_obj.private = true;
|
||||
update_journal_entry();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if ($lq__journal_entry_obj?.private && tmp_entry_obj?.content_encrypted) {
|
||||
// Handle converting to not private (decrypted) content
|
||||
if (confirm('Are you sure you want to decrypt and resave this journal entry unencrypted?')) {
|
||||
// tmp_entry_obj.private = !$lq__journal_entry_obj?.private;
|
||||
// update_journal_entry();
|
||||
|
||||
// Setting private to false will cause the update_journal_entry() function to decrypt the content. This will also copy it to tmp_entry_obj.content.
|
||||
tmp_entry_obj.private = false;
|
||||
// tmp_entry_obj.
|
||||
// handle_decrypt_content();
|
||||
update_journal_entry();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle private visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.private}
|
||||
<Fingerprint strokeWidth="2.5" color="green" />
|
||||
<!-- Private (Encrypted) -->
|
||||
{:else}
|
||||
<Fingerprint strokeWidth="1" color="gray" />
|
||||
<!-- Not Private -->
|
||||
{/if}
|
||||
|
||||
</button>
|
||||
|
||||
<!-- Only show this encryption toggle if entry is private. -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
if (tmp_entry_obj?.private && decrypted_content) {
|
||||
decrypted_content = '';
|
||||
// tmp_entry_obj.content = null;
|
||||
} else if (tmp_entry_obj?.private && tmp_entry_obj?.content_encrypted) {
|
||||
if (!$journals_loc?.entry?.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id]) {
|
||||
if (confirm('Are you sure you want to decrypt the content to view/edit?')) {
|
||||
$journals_loc.entry.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id] = true;
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = 'current';
|
||||
|
||||
if (!tmp_entry_obj?.content && tmp_entry_obj?.content_encrypted) {
|
||||
console.log('TEST: Decrypting the content...');
|
||||
tmp_entry_obj.content = await ae_util.decrypt_wrapper(tmp_entry_obj?.content_encrypted, journal_key);
|
||||
tmp_entry_obj.content_md_html = handle_marked(tmp_entry_obj?.content);
|
||||
}
|
||||
if (!tmp_entry_obj?.history && tmp_entry_obj?.history_encrypted) {
|
||||
console.log('TEST: Decrypting the history...');
|
||||
tmp_entry_obj.history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
|
||||
tmp_entry_obj.history_md_html = handle_marked(tmp_entry_obj?.history);
|
||||
}
|
||||
// trigger_decrypt = true;
|
||||
// handle_decrypt_content();
|
||||
// handle_decrypt_string(tmp_entry_obj?.content_encrypted, journal_key).then((result) => {
|
||||
// decrypted_content = result;
|
||||
// console.log('TEST: Decrypted content:', decrypted_content);
|
||||
// });
|
||||
// decrypted_content = await ae_util.decrypt_wrapper(tmp_entry_obj?.content_encrypted, journal_key);
|
||||
|
||||
// // decrypted_content = await handle_decrypt_string(tmp_entry_obj?.content_encrypted, journal_key);
|
||||
// tmp_entry_obj.content = decrypted_content;
|
||||
// console.log('TEST: Decrypted content:', decrypted_content);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$journals_loc.entry.decrypt_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
tmp_entry_obj.content = null;
|
||||
tmp_entry_obj.content_md_html = null;
|
||||
tmp_entry_obj.history = null;
|
||||
tmp_entry_obj.history_md_html = null;
|
||||
}
|
||||
}
|
||||
}}
|
||||
class:hidden={!$lq__journal_entry_obj?.private || !tmp_entry_obj?.content_encrypted}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle viewing/editing of private encrypted content"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.private && tmp_entry_obj?.content}
|
||||
<LockKeyholeOpen strokeWidth="2.5" color="red" />
|
||||
{:else if $lq__journal_entry_obj?.private && tmp_entry_obj?.content_encrypted}
|
||||
<LockKeyhole strokeWidth="2.5" color="green" />
|
||||
<!-- <Fingerprint strokeWidth="2.5" color="green" /> -->
|
||||
<!-- {:else if $lq__journal_entry_obj?.private}
|
||||
<Fingerprint strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<Fingerprint strokeWidth="1" color="gray" /> -->
|
||||
|
||||
{/if}
|
||||
|
||||
</button>
|
||||
</span>
|
||||
|
||||
<!-- Entry allowed to be public -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_public}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.public = !$lq__journal_entry_obj?.public;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle public visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.public}
|
||||
<Globe strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<Globe strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<!-- Entry marked as personal -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_personal}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.personal = !$lq__journal_entry_obj?.personal;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle personal visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.personal}
|
||||
<BookHeart strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<BookHeart strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<!-- Entry marked as professional -->
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={$lq__journal_obj.cfg_json?.hide_btn_professional}
|
||||
onclick={() => {
|
||||
tmp_entry_obj.professional = !$lq__journal_entry_obj?.professional;
|
||||
update_journal_entry();
|
||||
}}
|
||||
class="btn-icon btn-icon-sm variant-soft-secondary hover:variant-filled-secondary transition"
|
||||
title="Toggle professional visibility of this journal entry"
|
||||
>
|
||||
{#if $lq__journal_entry_obj?.professional}
|
||||
<BriefcaseBusiness strokeWidth="2.5" color="green" />
|
||||
{:else}
|
||||
<BriefcaseBusiness strokeWidth="1" color="gray" />
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
</span>
|
||||
|
||||
<!-- If there is history, then we want a toggle button to show and hide the history. -->
|
||||
{#if ($lq__journal_entry_obj?.history || $lq__journal_entry_obj?.history_encrypted)}
|
||||
<div
|
||||
class="
|
||||
flex flex-row-reverse flex-wrap gap-1 items-center justify-center
|
||||
"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
if (!$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id]) {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = 'history';
|
||||
$journals_sess.show__content__journal_entry_history = 'view'
|
||||
} else if ($journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current') {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = 'history';
|
||||
$journals_sess.show__content__journal_entry_history = 'view'
|
||||
} else if ($journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history') {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
} else {
|
||||
$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// if ($journals_sess.show__content__journal_entry_history == 'view') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'hide';
|
||||
// } else if ($journals_sess.show__content__journal_entry_history == 'edit') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'hide';
|
||||
// } else if ($journals_sess.show__content__journal_entry_history == 'hide') {
|
||||
// $journals_sess.show__content__journal_entry_history = 'view';
|
||||
// } else if (!$journals_sess.show__content__journal_entry_history) {
|
||||
// $journals_sess.show__content__journal_entry_history = 'view';
|
||||
// }
|
||||
|
||||
// !tmp_entry_obj?.history &&
|
||||
if (tmp_entry_obj?.history_encrypted) {
|
||||
decrypted_history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
|
||||
// decrypted_history = await handle_decrypt_string(tmp_entry_obj.history_encrypted, journal_key);
|
||||
console.log('Decrypted history:', decrypted_history);
|
||||
tmp_entry_obj.history = decrypted_history;
|
||||
}
|
||||
|
||||
}}
|
||||
class:variant-filled-secondary={$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history'}
|
||||
class:variant-soft-secondary={$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] != 'history'}
|
||||
class="btn btn-sm hover:variant-filled-secondary *:hover:inline lg:text-xs"
|
||||
title="Toggle history of this journal entry"
|
||||
>
|
||||
{#if !$journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] || $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'current'}
|
||||
<History strokeWidth="1" color="gray" />
|
||||
{:else if $journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history'}
|
||||
<History strokeWidth="2.5" color="red" />
|
||||
{/if}
|
||||
<!-- <History strokeWidth="2.5" color="blue" /> -->
|
||||
<span class="hidden sm:inline text-sm">
|
||||
History</span>
|
||||
</button>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class:hidden={!($journals_loc.entry.edit_kv[$lq__journal_entry_obj?.journal_entry_id] == 'history')}
|
||||
onclick={async () => {
|
||||
if (!$journals_sess?.show__content__journal_entry_history || $journals_sess.show__content__journal_entry_history == 'view') {
|
||||
$journals_sess.show__content__journal_entry_history = 'edit';
|
||||
} else if ($journals_sess.show__content__journal_entry_history == 'edit') {
|
||||
$journals_sess.show__content__journal_entry_history = 'view';
|
||||
}
|
||||
console.log('History edit mode:', $journals_sess.show__content__journal_entry_history);
|
||||
|
||||
if (tmp_entry_obj?.history_encrypted) {
|
||||
let history_cleaned: null|string = null;
|
||||
let history_md_html: null|string = null;
|
||||
|
||||
decrypted_history = await ae_util.decrypt_wrapper(tmp_entry_obj?.history_encrypted, journal_key);
|
||||
|
||||
// decrypted_history = await handle_decrypt_string(tmp_entry_obj.history_encrypted, journal_key);
|
||||
console.log('Decrypted history:', decrypted_history);
|
||||
tmp_entry_obj.history = decrypted_history;
|
||||
|
||||
history_cleaned = decrypted_history.replace(/^[\u200B\u200C\u200D\u200E\u200F\uFEFF]/,"");
|
||||
history_md_html = await marked.parse(history_cleaned ?? '') ?? null;
|
||||
tmp_entry_obj.history_md_html = history_md_html;
|
||||
// console.log('History cleaned:', history_cleaned);
|
||||
console.log('History md html:', history_md_html);
|
||||
}
|
||||
}}
|
||||
class="btn btn-sm variant-soft-secondary hover:variant-filled-secondary *:hover:inline lg:text-xs"
|
||||
title="Toggle edit mode for history of this journal entry"
|
||||
>
|
||||
{#if !$journals_sess?.show__content__journal_entry_history || $journals_sess?.show__content__journal_entry_history == 'view'}
|
||||
<Pencil strokeWidth="2.5" color="blue" class="inline-block" />
|
||||
{:else if $journals_sess?.show__content__journal_entry_history == 'edit'}
|
||||
<PenLine strokeWidth="2.5" color="red" class="inline-block" />
|
||||
{/if}
|
||||
<span class="hidden sm:inline">
|
||||
{#if !$journals_sess?.show__content__journal_entry_history || $journals_sess?.show__content__journal_entry_history == 'view'}
|
||||
Edit?
|
||||
{:else if $journals_sess.show__content__journal_entry_history == 'edit'}
|
||||
View?
|
||||
{/if}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</section>
|
||||
</section> -->
|
||||
|
||||
|
||||
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
||||
|
||||
Reference in New Issue
Block a user