Normalize journal entry config actions

This commit is contained in:
Scott Idem
2026-05-05 12:59:30 -04:00
parent 0d0cec9819
commit 80957316f2
3 changed files with 387 additions and 221 deletions

View File

@@ -177,6 +177,25 @@ async function load_ae_obj_id__my_obj({ api_cfg, obj_id }) {
} }
``` ```
### Shared/Common Aether object fields
The core fields for almost all Aether objects are:
* id/id_random
* code - string
* name - string
* summary - string
* content - string
* alert - boolean
* alert_msg - text
* priority - boolean
* sort - int
* group - string
* hide - boolean
* enable - boolean
* default_qry_str - special concat string index
* notes - text
* created_on - timestamp
* updated_on - timestamp
### ID convention — never use `_id_random` fields ### ID convention — never use `_id_random` fields
The V3 API uses random string IDs (e.g. `event_file_id = "aBc123"`). The `*_id_random` The V3 API uses random string IDs (e.g. `event_file_id = "aBc123"`). The `*_id_random`
fields are legacy aliases. The integer version of the ID is never returned by the API. Always use the short form: fields are legacy aliases. The integer version of the ID is never returned by the API. Always use the short form:
@@ -229,7 +248,7 @@ When looking up a single object by its string ID, always use `.where().equals().
--- ---
## 6. Naming Conventions ## 6. Naming Conventions (snake_case; no camelCase)
| Pattern | Example | Used for | | Pattern | Example | Used for |
|---|---|---| |---|---|---|

View File

@@ -6,7 +6,6 @@
*/ */
import { import {
Siren, Siren,
MessageSquareWarning,
Fingerprint, Fingerprint,
Globe, Globe,
BookHeart, BookHeart,
@@ -15,10 +14,11 @@ import {
Settings Settings
} from '@lucide/svelte'; } from '@lucide/svelte';
import { ae_loc } from '$lib/stores/ae_stores'; import { ae_loc } from '$lib/stores/ae_stores';
import type { ae_JournalEntry } from '$lib/types/ae_types';
interface Props { interface Props {
// The object containing the flags (bindable) // The object containing the flags (bindable)
obj: any; obj: ae_JournalEntry;
// Visibility configuration (optional overrides) // Visibility configuration (optional overrides)
show_labels?: boolean; show_labels?: boolean;
@@ -49,9 +49,38 @@ let {
container_class = 'flex flex-row flex-wrap gap-1 items-center justify-evenly py-2 border-y border-surface-500/10' container_class = 'flex flex-row flex-wrap gap-1 items-center justify-evenly py-2 border-y border-surface-500/10'
}: Props = $props(); }: Props = $props();
function handle_toggle(prop: string) { function emit_toggle(prop: string, value: boolean) {
obj[prop] = !obj[prop]; if (onToggle) onToggle(prop, value);
if (onToggle) onToggle(prop, obj[prop]); }
function toggle_alert() {
obj.alert = !obj.alert;
emit_toggle('alert', !!obj.alert);
}
function toggle_private() {
obj.private = !obj.private;
emit_toggle('private', !!obj.private);
}
function toggle_public() {
obj.public = !obj.public;
emit_toggle('public', !!obj.public);
}
function toggle_personal() {
obj.personal = !obj.personal;
emit_toggle('personal', !!obj.personal);
}
function toggle_professional() {
obj.professional = !obj.professional;
emit_toggle('professional', !!obj.professional);
}
function toggle_template() {
obj.template = !obj.template;
emit_toggle('template', !!obj.template);
} }
</script> </script>
@@ -63,81 +92,69 @@ function handle_toggle(prop: string) {
</span> </span>
{/if} {/if}
<!-- Alert Status -->
{#if !hide_alert} {#if !hide_alert}
<button <button
type="button" type="button"
onclick={() => handle_toggle('alert')} onclick={toggle_alert}
class="btn-icon btn-icon-sm preset-tonal-secondary hover:preset-filled-secondary-500 transition" class="btn btn-sm flex items-center gap-2 px-3 transition preset-tonal-secondary hover:preset-filled-secondary-500"
title="Toggle Alert Status"> title="Toggle alert status">
<Siren <Siren size="1.2em" class={obj?.alert ? 'text-error-500' : 'opacity-40'} />
size="1.2em" <span class="whitespace-nowrap text-[10px] font-bold uppercase tracking-wider">Alert</span>
class={obj?.alert ? 'text-error-500' : 'opacity-40'} />
</button> </button>
{/if} {/if}
<!-- Private / E2EE -->
{#if !hide_private} {#if !hide_private}
<button <button
type="button" type="button"
onclick={() => handle_toggle('private')} onclick={toggle_private}
class="btn-icon btn-icon-sm preset-tonal-secondary hover:preset-filled-secondary-500 transition" class="btn btn-sm flex items-center gap-2 px-3 transition preset-tonal-secondary hover:preset-filled-secondary-500"
title="Toggle Private/Encrypted"> title="Toggle private or encrypted visibility">
<Fingerprint <Fingerprint size="1.2em" class={obj?.private ? 'text-success-500' : 'opacity-40'} />
size="1.2em" <span class="whitespace-nowrap text-[10px] font-bold uppercase tracking-wider">Private</span>
class={obj?.private ? 'text-success-500' : 'opacity-40'} />
</button> </button>
{/if} {/if}
<!-- Public Visibility -->
{#if !hide_public} {#if !hide_public}
<button <button
type="button" type="button"
onclick={() => handle_toggle('public')} onclick={toggle_public}
class="btn-icon btn-icon-sm preset-tonal-secondary hover:preset-filled-secondary-500 transition" class="btn btn-sm flex items-center gap-2 px-3 transition preset-tonal-secondary hover:preset-filled-secondary-500"
title="Toggle Public Visibility"> title="Toggle public visibility">
<Globe <Globe size="1.2em" class={obj?.public ? 'text-success-500' : 'opacity-40'} />
size="1.2em" <span class="whitespace-nowrap text-[10px] font-bold uppercase tracking-wider">Public</span>
class={obj?.public ? 'text-success-500' : 'opacity-40'} />
</button> </button>
{/if} {/if}
<!-- Personal Scope -->
{#if !hide_personal} {#if !hide_personal}
<button <button
type="button" type="button"
onclick={() => handle_toggle('personal')} onclick={toggle_personal}
class="btn-icon btn-icon-sm preset-tonal-secondary hover:preset-filled-secondary-500 transition" class="btn btn-sm flex items-center gap-2 px-3 transition preset-tonal-secondary hover:preset-filled-secondary-500"
title="Toggle Personal Scope"> title="Toggle personal scope">
<BookHeart <BookHeart size="1.2em" class={obj?.personal ? 'text-success-500' : 'opacity-40'} />
size="1.2em" <span class="whitespace-nowrap text-[10px] font-bold uppercase tracking-wider">Personal</span>
class={obj?.personal ? 'text-success-500' : 'opacity-40'} />
</button> </button>
{/if} {/if}
<!-- Professional Scope -->
{#if !hide_professional} {#if !hide_professional}
<button <button
type="button" type="button"
onclick={() => handle_toggle('professional')} onclick={toggle_professional}
class="btn-icon btn-icon-sm preset-tonal-secondary hover:preset-filled-secondary-500 transition" class="btn btn-sm flex items-center gap-2 px-3 transition preset-tonal-secondary hover:preset-filled-secondary-500"
title="Toggle Professional Scope"> title="Toggle professional scope">
<BriefcaseBusiness <BriefcaseBusiness size="1.2em" class={obj?.professional ? 'text-success-500' : 'opacity-40'} />
size="1.2em" <span class="whitespace-nowrap text-[10px] font-bold uppercase tracking-wider">Professional</span>
class={obj?.professional ? 'text-success-500' : 'opacity-40'} />
</button> </button>
{/if} {/if}
<!-- Template Status -->
{#if !hide_template && $ae_loc.edit_mode} {#if !hide_template && $ae_loc.edit_mode}
<button <button
type="button" type="button"
onclick={() => handle_toggle('template')} onclick={toggle_template}
class="btn-icon btn-icon-sm preset-tonal-secondary hover:preset-filled-secondary-500 transition" class="btn btn-sm flex items-center gap-2 px-3 transition preset-tonal-secondary hover:preset-filled-secondary-500"
title="Toggle Template Mode"> title="Toggle template mode">
<NotepadTextDashed <NotepadTextDashed size="1.2em" class={obj?.template ? 'text-success-500' : 'opacity-40'} />
size="1.2em" <span class="whitespace-nowrap text-[10px] font-bold uppercase tracking-wider">Template</span>
class={obj?.template ? 'text-success-500' : 'opacity-40'} />
</button> </button>
{/if} {/if}
</div> </div>

View File

@@ -7,10 +7,9 @@ import {
ArrowDownToLine, ArrowDownToLine,
ArrowUpToLine, ArrowUpToLine,
Check, Check,
Clock, CircleAlert,
CodeXml, CodeXml,
Copy, Copy,
Database,
FileDown, FileDown,
Fingerprint, Fingerprint,
Minus, Minus,
@@ -24,22 +23,19 @@ import {
X, X,
Zap Zap
} from '@lucide/svelte'; } from '@lucide/svelte';
import { goto } from '$app/navigation';
import { Modal } from 'flowbite-svelte'; import { Modal } from 'flowbite-svelte';
import { ae_loc, ae_api } from '$lib/stores/ae_stores'; import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import {
journals_loc,
journals_sess
} from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions'; import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import AE_Comp_Editor_CodeMirror from '$lib/elements/element_editor_codemirror.svelte'; import AE_Comp_Editor_CodeMirror from '$lib/elements/element_editor_codemirror.svelte';
import AE_Object_Flags from '$lib/ae_elements/AE_Object_Flags.svelte'; import AE_Object_Flags from '$lib/ae_elements/AE_Object_Flags.svelte';
import type { ae_Journal, ae_JournalEntry } from '$lib/types/ae_types';
interface Props { interface Props {
log_lvl?: number; log_lvl?: number;
show?: boolean; show?: boolean;
entry: any; journal: ae_Journal;
journal: any; tmp_entry_obj: ae_JournalEntry; // Bindable
tmp_entry_obj: any; // Bindable
on_save: () => void; on_save: () => void;
on_force_reset?: () => void; on_force_reset?: () => void;
on_show_export?: () => void; on_show_export?: () => void;
@@ -50,7 +46,6 @@ interface Props {
let { let {
log_lvl = $bindable(0), log_lvl = $bindable(0),
show = $bindable(false), show = $bindable(false),
entry,
journal, journal,
tmp_entry_obj = $bindable(), tmp_entry_obj = $bindable(),
on_save, on_save,
@@ -62,7 +57,15 @@ let {
let tab: 'actions' | 'meta' | 'security' | 'json' = $state('actions'); let tab: 'actions' | 'meta' | 'security' | 'json' = $state('actions');
const normalize_date = (val: string | null) => (val ? val.slice(0, 16) : null); const normalize_date = (val?: string | Date | null) => {
if (!val) return null;
if (val instanceof Date) return val.toISOString().slice(0, 16);
return val.slice(0, 16);
};
const panel_class = 'space-y-4 rounded-xl border border-surface-500/20 bg-surface-500/5 p-4 shadow-sm';
const panel_title_class = 'flex items-center gap-2 border-b border-surface-500/20 pb-2 text-lg font-bold';
const field_card_class = 'bg-surface-500/5 border-surface-500/10 flex cursor-pointer items-center space-x-3 rounded-lg border p-3 transition-colors hover:bg-surface-500/10';
async function handle_update_entry() { async function handle_update_entry() {
try { try {
@@ -103,6 +106,32 @@ async function handle_update_entry() {
console.error('Error updating journal entry:', error); console.error('Error updating journal entry:', error);
} }
} }
async function handle_admin_delete_action() {
const can_delete = $ae_loc.manager_access || $ae_loc.administrator_access;
const delete_method = can_delete ? 'delete' : 'disable';
const action_label = can_delete ? 'delete' : 'remove';
const confirm_label = can_delete ? 'delete' : 'remove';
if (!confirm(`Are you sure you want to ${confirm_label} this journal entry?`)) {
return;
}
try {
await journals_func.delete_ae_obj_id__journal_entry({
api_cfg: $ae_api,
journal_entry_id: tmp_entry_obj.journal_entry_id,
method: delete_method,
log_lvl
});
show = false;
await goto(`/journals/${tmp_entry_obj.journal_id}`);
} catch (error) {
console.error(`Error attempting to ${action_label} journal entry:`, error);
alert(`Failed to ${action_label} journal entry.`);
}
}
</script> </script>
<Modal <Modal
@@ -111,9 +140,9 @@ async function handle_update_entry() {
dismissable={false} dismissable={false}
placement="top-center" placement="top-center"
size="lg" size="lg"
class="relative mx-auto flex w-full flex-col rounded-lg border border-orange-300 bg-white text-gray-800 shadow-xl dark:border-orange-700 dark:bg-gray-800 dark:text-gray-200" class="relative mx-auto flex h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] w-full flex-col rounded-xl border border-surface-200-800 bg-surface-50-900 text-surface-950-50 shadow-xl"
headerClass="flex flex-row gap-2 items-center justify-between w-full bg-orange-100 dark:bg-orange-900 p-4 rounded-t-lg border-b border-orange-200 dark:border-orange-800" headerClass="flex w-full flex-row items-center justify-between gap-2 rounded-t-xl border-b border-surface-200-800 bg-surface-100-900 p-4"
footerClass="flex flex-row gap-2 items-center justify-center w-full bg-orange-100 dark:bg-orange-900 p-4 rounded-b-lg border-t border-orange-200 dark:border-orange-800"> footerClass="flex w-full flex-row items-center justify-center gap-2 rounded-b-xl border-t border-surface-200-800 bg-surface-100-900 p-4">
{#snippet header()} {#snippet header()}
<h3 class="flex flex-1 items-center gap-2 text-lg font-bold"> <h3 class="flex flex-1 items-center gap-2 text-lg font-bold">
<Settings class="text-primary-500" /> <Settings class="text-primary-500" />
@@ -127,7 +156,7 @@ async function handle_update_entry() {
</button> </button>
{/snippet} {/snippet}
<div class="h-[60vh] space-y-6 overflow-y-auto px-4 py-2"> <div class="min-h-0 flex-1 space-y-6 overflow-y-auto px-4 py-3">
<!-- Navigation Tabs --> <!-- Navigation Tabs -->
<div <div
class="bg-surface-500/10 sticky top-0 z-10 mx-auto mb-4 flex max-w-fit justify-center gap-1 rounded-lg p-1 backdrop-blur-sm"> class="bg-surface-500/10 sticky top-0 z-10 mx-auto mb-4 flex max-w-fit justify-center gap-1 rounded-lg p-1 backdrop-blur-sm">
@@ -166,51 +195,62 @@ async function handle_update_entry() {
</div> </div>
{#if tab === 'actions'} {#if tab === 'actions'}
<div class="animate-in fade-in space-y-6 duration-300"> <div class="animate-in fade-in space-y-4 duration-300">
<section class="grid grid-cols-1 gap-4 md:grid-cols-2"> <section class={panel_class}>
<button <h2 class={panel_title_class}>
type="button" <Zap size="1.2em" class="text-primary-500" />
class="btn preset-tonal-secondary w-full" Quick Actions
onclick={() => { </h2>
show = false; <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
on_prepend?.(); <button
}}> type="button"
<ArrowUpToLine size="1.2em" class="mr-2" /> Prepend Content class="btn preset-tonal-secondary w-full justify-start gap-2"
</button> onclick={() => {
<button show = false;
type="button" on_prepend?.();
class="btn preset-tonal-secondary w-full" }}>
onclick={() => { <ArrowUpToLine size="1.2em" />
show = false; Prepend Content
on_append?.(); </button>
}}> <button
<ArrowDownToLine size="1.2em" class="mr-2" /> Append Content type="button"
</button> class="btn preset-tonal-secondary w-full justify-start gap-2"
<button onclick={() => {
type="button" show = false;
class="btn preset-tonal-surface w-full" on_append?.();
onclick={() => { }}>
show = false; <ArrowDownToLine size="1.2em" />
on_show_export?.(); Append Content
}}> </button>
<FileDown size="1.2em" class="mr-2" /> Export Entry <button
</button> type="button"
<button class="btn preset-tonal-surface w-full justify-start gap-2"
type="button" onclick={() => {
class="btn preset-tonal-surface w-full" show = false;
onclick={() => { on_show_export?.();
/* Clone logic here */ alert( }}>
'Clone not yet implemented in modal' <FileDown size="1.2em" />
); Export Entry
}}> </button>
<Copy size="1.2em" class="mr-2" /> Clone Entry <button
</button> type="button"
class="btn preset-tonal-surface w-full justify-start gap-2"
onclick={() => {
/* Clone logic here */ alert(
'Clone not yet implemented in modal'
);
}}>
<Copy size="1.2em" />
Clone Entry
</button>
</div>
</section> </section>
<section class="border-surface-500/20 space-y-4 border-t pt-4"> <section class={panel_class}>
<h4 class="text-xs font-bold uppercase opacity-50"> <h2 class={panel_title_class}>
<Shapes size="1.2em" class="text-primary-500" />
Quick Category Quick Category
</h4> </h2>
<div class="flex flex-wrap gap-2"> <div class="flex flex-wrap gap-2">
{#each journal?.cfg_json?.category_li ?? [] as cat (cat.code)} {#each journal?.cfg_json?.category_li ?? [] as cat (cat.code)}
<button <button
@@ -231,94 +271,86 @@ async function handle_update_entry() {
</section> </section>
</div> </div>
{:else if tab === 'meta'} {:else if tab === 'meta'}
<div class="animate-in fade-in space-y-6 duration-300"> <div class="animate-in fade-in space-y-4 duration-300">
<label class="label"> <section class={panel_class}>
<span class="text-sm font-bold opacity-70">Category</span> <h2 class={panel_title_class}>
<select <Shapes size="1.2em" class="text-primary-500" />
class="select" Entry Details
bind:value={tmp_entry_obj.category_code} </h2>
onchange={() => { <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
handle_update_entry(); <label class="label">
on_save(); <span class="text-sm font-bold opacity-70"
}}> >Category</span>
<option value="">None</option> <select
{#each journal?.cfg_json?.category_li ?? [] as cat (cat.code)} class="select"
<option value={cat.code}>{cat.name}</option> bind:value={tmp_entry_obj.category_code}
{/each} onchange={() => {
</select> handle_update_entry();
</label> on_save();
}}>
<option value="">None</option>
{#each journal?.cfg_json?.category_li ?? [] as cat (cat.code)}
<option value={cat.code}>{cat.name}</option>
{/each}
</select>
</label>
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70" <span class="text-sm font-bold opacity-70"
>Tags (Comma separated)</span> >Tags (Comma separated)</span>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<Tag size="1.2em" class="opacity-30" /> <Tag size="1.2em" class="opacity-30" />
<input <input
type="text" type="text"
bind:value={tmp_entry_obj.tags} bind:value={tmp_entry_obj.tags}
class="input grow" class="input grow"
placeholder="meeting, urgent, ideas" placeholder="meeting, urgent, ideas"
onchange={() => { onchange={() => {
handle_update_entry(); handle_update_entry();
on_save(); on_save();
}} /> }} />
</div>
</label>
<label class="label md:col-span-2">
<span class="text-sm font-bold opacity-70"
>Summary</span>
<textarea
bind:value={tmp_entry_obj.summary}
class="textarea min-h-24"
placeholder="Short summary for search results and quick review"
onchange={() => {
handle_update_entry();
on_save();
}}></textarea>
</label>
<label class="label md:col-span-2">
<span class="text-sm font-bold opacity-70"
>Archive On</span>
<input
type="datetime-local"
value={normalize_date(tmp_entry_obj.archive_on)}
onchange={(e) => {
tmp_entry_obj.archive_on =
e.currentTarget.value;
handle_update_entry();
on_save();
}}
class="input" />
</label>
</div> </div>
</label> </section>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<label class="label">
<span class="text-sm font-bold opacity-70"
>Archive On</span>
<input
type="datetime-local"
value={normalize_date(tmp_entry_obj.archive_on)}
onchange={(e) => {
tmp_entry_obj.archive_on =
e.currentTarget.value;
handle_update_entry();
on_save();
}}
class="input" />
</label>
<label class="label">
<span class="text-sm font-bold opacity-70"
>Sort Priority</span>
<div class="flex items-center gap-2">
<button
type="button"
class="btn-icon btn-icon-sm preset-tonal-surface"
onclick={() => {
tmp_entry_obj.sort =
(tmp_entry_obj.sort ?? 0) - 1;
handle_update_entry();
on_save();
}}><Minus size="1em" /></button>
<span class="w-8 text-center font-mono font-bold"
>{tmp_entry_obj.sort ?? 0}</span>
<button
type="button"
class="btn-icon btn-icon-sm preset-tonal-surface"
onclick={() => {
tmp_entry_obj.sort =
(tmp_entry_obj.sort ?? 0) + 1;
handle_update_entry();
on_save();
}}><Plus size="1em" /></button>
</div>
</label>
</div>
</div> </div>
{:else if tab === 'security'} {:else if tab === 'security'}
<div class="animate-in fade-in space-y-6 duration-300"> <div class="animate-in fade-in space-y-4 duration-300">
<section class="space-y-4"> <section class={panel_class}>
<h2 <h2 class={panel_title_class}>
class="border-surface-500/30 flex items-center gap-2 border-b pb-2 text-lg font-bold"> <ShieldCheck size="1.2em" class="text-primary-500" />
<Fingerprint size="1.2em" class="text-primary-500" />
Status & Security Status & Security
</h2> </h2>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2"> <div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<label <label class={field_card_class}>
class="bg-surface-500/5 border-surface-500/10 hover:bg-surface-500/10 flex cursor-pointer items-center space-x-3 rounded-lg border p-3 transition-colors">
<input <input
type="checkbox" type="checkbox"
bind:checked={tmp_entry_obj.enable} bind:checked={tmp_entry_obj.enable}
@@ -333,8 +365,7 @@ async function handle_update_entry() {
>Allow access to this entry</span> >Allow access to this entry</span>
</div> </div>
</label> </label>
<label <label class={field_card_class}>
class="bg-surface-500/5 border-surface-500/10 hover:bg-surface-500/10 flex cursor-pointer items-center space-x-3 rounded-lg border p-3 transition-colors">
<input <input
type="checkbox" type="checkbox"
bind:checked={tmp_entry_obj.hide} bind:checked={tmp_entry_obj.hide}
@@ -349,8 +380,7 @@ async function handle_update_entry() {
>Hide from standard lists</span> >Hide from standard lists</span>
</div> </div>
</label> </label>
<label <label class={field_card_class}>
class="bg-surface-500/5 border-surface-500/10 hover:bg-surface-500/10 flex cursor-pointer items-center space-x-3 rounded-lg border p-3 transition-colors">
<input <input
type="checkbox" type="checkbox"
bind:checked={tmp_entry_obj.priority} bind:checked={tmp_entry_obj.priority}
@@ -365,8 +395,7 @@ async function handle_update_entry() {
>Star or pin to top</span> >Star or pin to top</span>
</div> </div>
</label> </label>
<div <div class="bg-surface-500/5 border-surface-500/10 flex items-center justify-between rounded-lg border p-3">
class="bg-surface-500/5 border-surface-500/10 flex items-center justify-between rounded-lg border p-3">
<div class="flex flex-col"> <div class="flex flex-col">
<span class="text-sm font-bold" <span class="text-sm font-bold"
>Sort Order</span> >Sort Order</span>
@@ -400,12 +429,17 @@ async function handle_update_entry() {
</div> </div>
</section> </section>
<section class="space-y-4"> <section class={panel_class}>
<h4 class="text-xs font-bold uppercase opacity-50"> <h2 class={panel_title_class}>
<Fingerprint size="1.2em" class="text-primary-500" />
Privacy Flags Privacy Flags
</h4> </h2>
<p class="text-xs opacity-60">
Visibility and audience controls for the entry itself.
</p>
<AE_Object_Flags <AE_Object_Flags
bind:obj={tmp_entry_obj} bind:obj={tmp_entry_obj}
show_labels={false}
on_toggle={() => { on_toggle={() => {
handle_update_entry(); handle_update_entry();
on_save(); on_save();
@@ -419,15 +453,50 @@ async function handle_update_entry() {
hide_template={journal?.cfg_json?.hide_btn_template} /> hide_template={journal?.cfg_json?.hide_btn_template} />
</section> </section>
<section class={panel_class}>
<h2 class={panel_title_class}>
<CircleAlert size="1.2em" class="text-primary-500" />
Alerts & Messaging
</h2>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<label class={field_card_class}>
<input
type="checkbox"
bind:checked={tmp_entry_obj.alert}
onchange={() => {
handle_update_entry();
on_save();
}}
class="checkbox checkbox-primary" />
<div class="flex flex-col">
<span class="font-bold">Alert</span>
<span class="text-xs opacity-60"
>Flag this entry for emphasis</span>
</div>
</label>
<label class="label md:col-span-2">
<span class="text-sm font-bold opacity-70"
>Alert Message</span>
<textarea
bind:value={tmp_entry_obj.alert_msg}
class="textarea min-h-24"
placeholder="Optional note shown with the alert"
onchange={() => {
handle_update_entry();
on_save();
}}></textarea>
</label>
</div>
</section>
{#if tmp_entry_obj.private && !tmp_entry_obj.content && tmp_entry_obj.content_encrypted} {#if tmp_entry_obj.private && !tmp_entry_obj.content && tmp_entry_obj.content_encrypted}
<section class="border-error-500/20 border-t pt-8"> <section class={panel_class}>
<div <h2 class={panel_title_class}>
class="bg-error-500/10 border-error-500/30 rounded-lg border p-4"> <RefreshCcw size="1.2em" class="text-primary-500" />
<h4 Disaster Recovery
class="text-error-500 mb-2 flex items-center gap-2 font-bold"> </h2>
<RefreshCcw size="1.2em" /> Disaster Recovery <div class="space-y-4">
</h4> <p class="text-xs italic opacity-70">
<p class="mb-4 text-xs italic opacity-70">
If the encryption passcode is lost, the data is If the encryption passcode is lost, the data is
unrecoverable. You can force a reset to plain unrecoverable. You can force a reset to plain
text to reuse this entry ID. text to reuse this entry ID.
@@ -445,24 +514,85 @@ async function handle_update_entry() {
</section> </section>
{/if} {/if}
<section class="pt-12"> {#if $ae_loc.trusted_access || $ae_loc.manager_access || $ae_loc.administrator_access}
<button <section class={panel_class}>
type="button" <h2 class={panel_title_class}>
class="btn btn-sm preset-tonal-error w-full" <Settings size="1.2em" class="text-primary-500" />
onclick={() => { Admin
alert('Delete logic handled in parent component'); </h2>
}}> <p class="text-xs opacity-60">
<Trash2 size="1.1em" class="mr-2" /> Delete Entry Trusted access and above only. Notes are for staff
</button> use; managers and admins see Delete while trusted
</section> access sees Remove.
</p>
<div class="grid grid-cols-1 gap-4">
<label class="label">
<span class="text-sm font-bold opacity-70"
>Notes</span>
<textarea
bind:value={tmp_entry_obj.notes}
class="textarea min-h-24"
placeholder="Rarely used staff/admin note"
onchange={() => {
handle_update_entry();
on_save();
}}></textarea>
</label>
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
<label class={field_card_class}>
<input
type="checkbox"
bind:checked={tmp_entry_obj.enable}
onchange={() => {
handle_update_entry();
on_save();
}}
class="checkbox checkbox-primary" />
<div class="flex flex-col">
<span class="font-bold">Enabled</span>
<span class="text-xs opacity-60"
>Default access state for this entry</span>
</div>
</label>
<button
type="button"
class="btn btn-sm mx-auto inline-flex w-fit min-w-36 justify-center gap-2 px-4 font-bold {($ae_loc.manager_access || $ae_loc.administrator_access) ? 'preset-tonal-error hover:preset-filled-error-500' : 'preset-tonal-warning hover:preset-filled-warning-500'}"
title={($ae_loc.manager_access || $ae_loc.administrator_access)
? 'Permanently delete this journal entry'
: 'Disable this journal entry instead of deleting it'}
onclick={handle_admin_delete_action}>
{#if $ae_loc.manager_access || $ae_loc.administrator_access}
<Trash2 size="1.1em" />
Delete
{:else}
<Minus size="1.1em" />
Remove
{/if}
</button>
</div>
</div>
</section>
{/if}
</div> </div>
{:else if tab === 'json'} {:else if tab === 'json'}
<div class="h-full min-h-[400px]"> <div class="h-full min-h-100">
<AE_Comp_Editor_CodeMirror <section class={panel_class}>
readonly={true} <h2 class={panel_title_class}>
content={JSON.stringify(tmp_entry_obj, null, 2)} <CodeXml size="1.2em" class="text-primary-500" />
theme_mode={$ae_loc.theme_mode} Raw Entry JSON
class_li="rounded-lg border border-surface-500/30" /> </h2>
<p class="text-xs opacity-60">
Read-only view of the current bound entry object.
</p>
<AE_Comp_Editor_CodeMirror
readonly={true}
content={JSON.stringify(tmp_entry_obj, null, 2)}
theme_mode={$ae_loc.theme_mode}
class_li="rounded-lg border border-surface-500/20" />
</section>
</div> </div>
{/if} {/if}
</div> </div>
@@ -470,10 +600,10 @@ async function handle_update_entry() {
{#snippet footer()} {#snippet footer()}
<button <button
type="button" type="button"
class="btn preset-filled-primary min-w-[120px] font-bold" class="btn preset-filled-primary min-w-30 font-bold"
onclick={() => (show = false)}> onclick={() => (show = false)}>
<Check size="1.2em" class="mr-2" /> <Check size="1.2em" class="mr-2" />
Done Done
</button> </button>
{/snippet} {/snippet}
</Modal> </Modal>