Now with ability to set archive on datetime. Need to fix the timezone though.
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
CalendarClock, Check, CodeXml, Copy,
|
||||
Eye, EyeOff,
|
||||
Flag, FlagOff,
|
||||
Group,
|
||||
ListPlus,
|
||||
NotebookPen, NotebookText, NotepadTextDashed,
|
||||
RemoveFormatting,
|
||||
@@ -117,161 +118,179 @@ $effect(() => {
|
||||
class:bg-warning-100={!journals_journal_entry_obj?.enable}
|
||||
>
|
||||
<header class="ae_header flex flex-row gap-2 items-center justify-between w-full">
|
||||
|
||||
<span class="flex flex-row flex-wrap gap-1">
|
||||
<h3
|
||||
class:dim={journals_journal_entry_obj.hide}
|
||||
class="journal__name h4"
|
||||
>
|
||||
<span class="journal_entry__name">
|
||||
|
||||
|
||||
<span class="journal_entry__name *:hover:inline-block">
|
||||
{#if (journals_journal_entry_obj.alert)}
|
||||
<Siren class="mx-1 inline-block text-red-500"/>
|
||||
<Siren size="1.25em" class="mx-1 inline-block text-red-500"/>
|
||||
{/if}
|
||||
|
||||
{#if (journals_journal_entry_obj.priority)}
|
||||
<Flag class="mx-1 inline-block text-yellow-500"/>
|
||||
<Flag size="1.25emem" class="mx-1 inline-block text-yellow-500"/>
|
||||
{/if}
|
||||
{#if journals_journal_entry_obj.template}
|
||||
<NotepadTextDashed class="mx-1 inline-block" />
|
||||
{@html journals_journal_entry_obj.name ?? '-- no name --'}
|
||||
{:else if (journals_journal_entry_obj.name)}
|
||||
<NotebookText class="mx-1 inline-block" />
|
||||
{@html journals_journal_entry_obj.name}
|
||||
{:else}
|
||||
<CalendarClock class="mx-1 inline-block" />
|
||||
{ae_util.iso_datetime_formatter(journals_journal_entry_obj.created_on, 'datetime_iso_12_no_seconds')}
|
||||
|
||||
{#if (journals_journal_entry_obj.group)}
|
||||
<Group size="1.25emem" class="mx-1 inline-block text-green-500"/>
|
||||
<span class="text-xs text-gray-500 hidden">Group:</span>
|
||||
<span class="font-semibold text-sm text-gray-500 hidden md:inline">
|
||||
{journals_journal_entry_obj.group}
|
||||
</span>
|
||||
{/if}
|
||||
</span>
|
||||
</h3>
|
||||
|
||||
<!-- Button to copy the Markdown version -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
let tmp_entry_obj = journals_journal_entry_obj;
|
||||
<h3
|
||||
class:dim={journals_journal_entry_obj.hide}
|
||||
class="journal__name h4"
|
||||
>
|
||||
|
||||
navigator.clipboard.writeText(tmp_entry_obj.content).then(() => {
|
||||
alert('Markdown content copied to clipboard!');
|
||||
}).catch((error) => {
|
||||
console.error('Failed to copy content:', error);
|
||||
alert('Failed to copy content.');
|
||||
});
|
||||
}}
|
||||
class:hidden={journals_journal_entry_obj.template}
|
||||
class="btn btn-sm p-1 variant-soft-secondary hover:variant-filled-secondary *:hover:inline text-xs lg:text-sm"
|
||||
title="Copy the markdown content"
|
||||
{#if journals_journal_entry_obj.template}
|
||||
<NotepadTextDashed class="mx-1 inline-block" />
|
||||
{@html journals_journal_entry_obj.name ?? '-- no name --'}
|
||||
{:else if (journals_journal_entry_obj.name)}
|
||||
<NotebookText class="mx-1 inline-block" />
|
||||
{@html journals_journal_entry_obj.name}
|
||||
{:else}
|
||||
<CalendarClock class="mx-1 inline-block" />
|
||||
{ae_util.iso_datetime_formatter(journals_journal_entry_obj.created_on, 'datetime_iso_12_no_seconds')}
|
||||
{/if}
|
||||
|
||||
</h3>
|
||||
|
||||
<span class="flex flex-row flex-wrap gap-1">
|
||||
<!-- Button to copy the Markdown version -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
let tmp_entry_obj = journals_journal_entry_obj;
|
||||
|
||||
navigator.clipboard.writeText(tmp_entry_obj.content).then(() => {
|
||||
alert('Markdown content copied to clipboard!');
|
||||
}).catch((error) => {
|
||||
console.error('Failed to copy content:', error);
|
||||
alert('Failed to copy content.');
|
||||
});
|
||||
}}
|
||||
class:hidden={journals_journal_entry_obj.template}
|
||||
class="btn btn-sm p-1 variant-soft-secondary hover:variant-filled-secondary *:hover:inline text-xs lg:text-sm"
|
||||
title="Copy the markdown content"
|
||||
>
|
||||
<!-- <span class="fas fa-copy mx-1"></span> -->
|
||||
<Copy size="1em" />
|
||||
<RemoveFormatting size="1.25em" />
|
||||
<span class="hidden">
|
||||
Copy Plaintext Markdown
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<!-- Button to copy the rendered to HTML version -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// Copy the rendered HTML content to clipboard
|
||||
// const htmlContent = $lq__journal_entry_obj?.content_md_html || '';
|
||||
let htmlContent = journals_journal_entry_obj.content_md_html || '';
|
||||
|
||||
navigator.clipboard.writeText(htmlContent).then(() => {
|
||||
alert('Rendered HTML content copied to clipboard!');
|
||||
}).catch((error) => {
|
||||
console.error('Failed to copy HTML content:', error);
|
||||
alert('Failed to copy HTML content.');
|
||||
});
|
||||
}}
|
||||
class:hidden={journals_journal_entry_obj.template}
|
||||
class="btn btn-sm p-1 variant-soft-secondary hover:variant-filled-secondary *:hover:inline lg:text-xs"
|
||||
title="Copy the rendered HTML content"
|
||||
>
|
||||
<!-- <span class="fas fa-copy mx-1"></span> -->
|
||||
<Copy size="1em" />
|
||||
<CodeXml size="1.25em" />
|
||||
<span class="hidden">
|
||||
Copy Rendered HTML
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<!-- Clone entry -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// Clone the journal entry
|
||||
// We only want to clone certain fields from the original journal entry object to avoid conflicts.
|
||||
let data_kv = {
|
||||
code: journals_journal_entry_obj.code,
|
||||
category_code: journals_journal_entry_obj.category_code,
|
||||
name: journals_journal_entry_obj.name,
|
||||
short_name: journals_journal_entry_obj.short_name,
|
||||
content: journals_journal_entry_obj.content,
|
||||
description: journals_journal_entry_obj.description,
|
||||
tags: journals_journal_entry_obj.tags,
|
||||
};
|
||||
|
||||
journals_func.create_ae_obj__journal_entry({
|
||||
api_cfg: $ae_api,
|
||||
journal_id: journals_journal_entry_obj.journal_id,
|
||||
data_kv: data_kv,
|
||||
log_lvl: log_lvl,
|
||||
}).then((result) => {
|
||||
alert('Journal entry cloned successfully!');
|
||||
goto(`/journals/${result.journal_id_random}/entry/${result.journal_entry_id_random}`);
|
||||
}).catch((error) => {
|
||||
console.error('Error cloning journal entry:', error);
|
||||
alert('Failed to clone journal entry.');
|
||||
});
|
||||
}}
|
||||
class:hidden={!journals_journal_entry_obj.template}
|
||||
class="btn btn-sm p-1 variant-soft-secondary hover:variant-filled-secondary *:hover:inline lg:text-xs"
|
||||
title="Clone this journal entry"
|
||||
>
|
||||
<!-- class="btn btn-sm variant-soft-surface hover:variant-filled-warning transition py-1 px-2" -->
|
||||
<!-- <Copy strokeWidth="1" /> -->
|
||||
<Copy size="1.25em" />
|
||||
<span class="hidden md:inline">Clone</span>
|
||||
</button>
|
||||
|
||||
|
||||
<!-- Button to copy the rich text (rendered HTML) version -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
const element = document.getElementById(`rendered_journal_entry_content_${journals_journal_entry_obj.journal_entry_id}`);
|
||||
if (!element) {
|
||||
console.error('Element not found: rendered_journal_entry_content');
|
||||
alert('Failed to copy rich content.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get the rendered HTML content
|
||||
const htmlContent = element.innerHTML;
|
||||
|
||||
// Use the Clipboard API to write the HTML content as rich text
|
||||
await navigator.clipboard.write([
|
||||
new ClipboardItem({
|
||||
'text/html': new Blob([htmlContent], { type: 'text/html' }),
|
||||
}),
|
||||
]);
|
||||
|
||||
alert('Rendered rich content copied to clipboard!');
|
||||
} catch (error) {
|
||||
console.error('Failed to copy rich content:', error);
|
||||
alert('Failed to copy rich content.');
|
||||
}
|
||||
}}
|
||||
class="btn btn-sm p-1 variant-soft-secondary *:hover:inline lg:text-xs"
|
||||
title="Copy the rich text (rendered HTML) content"
|
||||
>
|
||||
<!-- <span class="fas fa-copy mx-1"></span> -->
|
||||
<Copy size="1em" />
|
||||
<RemoveFormatting size="1.25em" />
|
||||
<span class="hidden">
|
||||
Copy Plaintext Markdown
|
||||
<Copy size="1em" />
|
||||
<TypeOutline size="1.25em" />
|
||||
<span class="hidden">Copy Rich Text</span>
|
||||
</button>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<!-- Button to copy the rendered to HTML version -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// Copy the rendered HTML content to clipboard
|
||||
// const htmlContent = $lq__journal_entry_obj?.content_md_html || '';
|
||||
let htmlContent = journals_journal_entry_obj.content_md_html || '';
|
||||
|
||||
navigator.clipboard.writeText(htmlContent).then(() => {
|
||||
alert('Rendered HTML content copied to clipboard!');
|
||||
}).catch((error) => {
|
||||
console.error('Failed to copy HTML content:', error);
|
||||
alert('Failed to copy HTML content.');
|
||||
});
|
||||
}}
|
||||
class:hidden={journals_journal_entry_obj.template}
|
||||
class="btn btn-sm p-1 variant-soft-secondary hover:variant-filled-secondary *:hover:inline lg:text-xs"
|
||||
title="Copy the rendered HTML content"
|
||||
>
|
||||
<!-- <span class="fas fa-copy mx-1"></span> -->
|
||||
<Copy size="1em" />
|
||||
<CodeXml size="1.25em" />
|
||||
<span class="hidden">
|
||||
Copy Rendered HTML
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<!-- Clone entry -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => {
|
||||
// Clone the journal entry
|
||||
// We only want to clone certain fields from the original journal entry object to avoid conflicts.
|
||||
let data_kv = {
|
||||
code: journals_journal_entry_obj.code,
|
||||
category_code: journals_journal_entry_obj.category_code,
|
||||
name: journals_journal_entry_obj.name,
|
||||
short_name: journals_journal_entry_obj.short_name,
|
||||
content: journals_journal_entry_obj.content,
|
||||
description: journals_journal_entry_obj.description,
|
||||
tags: journals_journal_entry_obj.tags,
|
||||
};
|
||||
|
||||
journals_func.create_ae_obj__journal_entry({
|
||||
api_cfg: $ae_api,
|
||||
journal_id: journals_journal_entry_obj.journal_id,
|
||||
data_kv: data_kv,
|
||||
log_lvl: log_lvl,
|
||||
}).then((result) => {
|
||||
alert('Journal entry cloned successfully!');
|
||||
goto(`/journals/${result.journal_id_random}/entry/${result.journal_entry_id_random}`);
|
||||
}).catch((error) => {
|
||||
console.error('Error cloning journal entry:', error);
|
||||
alert('Failed to clone journal entry.');
|
||||
});
|
||||
}}
|
||||
class:hidden={!journals_journal_entry_obj.template}
|
||||
class="btn btn-sm p-1 variant-soft-secondary hover:variant-filled-secondary *:hover:inline lg:text-xs"
|
||||
title="Clone this journal entry"
|
||||
>
|
||||
<!-- class="btn btn-sm variant-soft-surface hover:variant-filled-warning transition py-1 px-2" -->
|
||||
<!-- <Copy strokeWidth="1" /> -->
|
||||
<Copy size="1.25em" />
|
||||
<span class="hidden md:inline">Clone</span>
|
||||
</button>
|
||||
|
||||
|
||||
<!-- Button to copy the rich text (rendered HTML) version -->
|
||||
<button
|
||||
type="button"
|
||||
onclick={async () => {
|
||||
const element = document.getElementById(`rendered_journal_entry_content_${journals_journal_entry_obj.journal_entry_id}`);
|
||||
if (!element) {
|
||||
console.error('Element not found: rendered_journal_entry_content');
|
||||
alert('Failed to copy rich content.');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Get the rendered HTML content
|
||||
const htmlContent = element.innerHTML;
|
||||
|
||||
// Use the Clipboard API to write the HTML content as rich text
|
||||
await navigator.clipboard.write([
|
||||
new ClipboardItem({
|
||||
'text/html': new Blob([htmlContent], { type: 'text/html' }),
|
||||
}),
|
||||
]);
|
||||
|
||||
alert('Rendered rich content copied to clipboard!');
|
||||
} catch (error) {
|
||||
console.error('Failed to copy rich content:', error);
|
||||
alert('Failed to copy rich content.');
|
||||
}
|
||||
}}
|
||||
class="btn btn-sm p-1 variant-soft-secondary *:hover:inline lg:text-xs"
|
||||
title="Copy the rich text (rendered HTML) content"
|
||||
>
|
||||
<Copy size="1em" />
|
||||
<TypeOutline size="1.25em" />
|
||||
<span class="hidden">Copy Rich Text</span>
|
||||
</button>
|
||||
|
||||
</span>
|
||||
|
||||
|
||||
<div class="flex flex-row flex-wrap gap-2 items-center justify-end">
|
||||
<!-- Tags for journal entry. Comma delimited list. -->
|
||||
{#if journals_journal_entry_obj.tags && journals_journal_entry_obj.tags.length}
|
||||
|
||||
Reference in New Issue
Block a user