Saving these files that should be pretty good.

This commit is contained in:
Scott Idem
2026-01-08 18:56:44 -05:00
parent ca73a5376a
commit 4fa59c3c0f
2 changed files with 135 additions and 75 deletions

View File

@@ -19,20 +19,26 @@
interface Props {
entry: ae_JournalEntry;
journal: ae_Journal;
journals_li?: ae_Journal[];
tmp_entry_obj: any; // Bindable
has_changed: boolean;
onSave: () => void;
onDecrypt: () => void;
onDecryptHistory: () => void;
onChangeJournal: () => void;
log_lvl?: number;
}
let {
entry,
journal,
journals_li = [],
tmp_entry_obj = $bindable(),
has_changed,
onSave,
onDecrypt,
onDecryptHistory,
onChangeJournal,
log_lvl = 0
}: Props = $props();
@@ -209,8 +215,11 @@ p-2 md:p-3 rounded-lg shadow-md
<JournalEntry_SettingsMenu
{entry}
{journal}
{journals_li}
bind:tmp_entry_obj={tmp_entry_obj}
{onSave}
{onDecryptHistory}
{onChangeJournal}
{log_lvl}
/>
</div>

View File

@@ -2,28 +2,43 @@
/**
* JournalEntry_SettingsMenu.svelte
* Extracted 2026-01-08 to modularize the Journal Entry Header.
* Manages Category, Priority, Sort, and Deletion.
* Manages Category, Flags, Copy/Clone, History, and Sort Order.
*/
import {
Plus, Minus, ArrowDown10, Flag, FlagOff,
Eye, EyeOff, ShieldCheck, ShieldMinus,
Clock, X, Trash2
Clock, X, Trash2, Settings, Shapes,
Copy, RemoveFormatting, CodeXml, TypeOutline,
History, Pencil, PenLine, FileX, SquareLibrary
} from '@lucide/svelte';
import { ae_loc, ae_api } from '$lib/stores/ae_stores';
import { journals_slct } from '$lib/ae_journals/ae_journals_stores';
import { journals_slct, journals_loc, journals_sess } from '$lib/ae_journals/ae_journals_stores';
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
import { goto } from '$app/navigation';
import AE_ObjectFlags from '$lib/ae_elements/AE_ObjectFlags.svelte';
import type { ae_JournalEntry, ae_Journal } from '$lib/types/ae_types';
interface Props {
entry: ae_JournalEntry;
journal: ae_Journal;
journals_li: ae_Journal[];
tmp_entry_obj: any; // Bindable
onSave: () => void;
onDecryptHistory: () => void;
onChangeJournal: () => void;
log_lvl?: number;
}
let { entry, journal, tmp_entry_obj = $bindable(), onSave, log_lvl = 0 }: Props = $props();
let {
entry,
journal,
journals_li = [],
tmp_entry_obj = $bindable(),
onSave,
onDecryptHistory,
onChangeJournal,
log_lvl = 0
}: Props = $props();
async function delete_entry() {
if (confirm(`Are you sure you want to delete this journal entry?`)) {
@@ -46,97 +61,133 @@
}
}
}
function copyToClipboard(text: string, msg: string) {
navigator.clipboard.writeText(text)
.then(() => alert(msg))
.catch(err => console.error('Copy failed:', err));
}
async function copyRichText() {
const element = document.getElementById(`rendered_journal_entry_content_${entry.journal_entry_id}`);
if (!element) return;
try {
await navigator.clipboard.write([
new ClipboardItem({ 'text/html': new Blob([element.innerHTML], { type: 'text/html' }) })
]);
alert('Rich text copied!');
} catch (err) {
console.error('Rich copy failed:', err);
}
}
</script>
<div class="space-y-4">
<!-- Category -->
<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>
<div class="space-y-4 min-w-[280px]">
<!-- Category selection -->
<div class="flex items-center gap-2">
<Shapes size="1.1em" class="text-surface-500" />
<select
class="select select-sm preset-tonal-primary w-full"
class="select select-sm preset-tonal-primary grow"
bind:value={tmp_entry_obj.category_code}
onchange={onSave}
title="Select a category"
>
<option value="">Select Category</option>
{#each journal?.cfg_json.category_li ?? [] as category}
{#each journal?.cfg_json?.category_li ?? [] as category}
<option value={category.code}>{category.name}</option>
{/each}
</select>
</div>
<!-- Priority Toggle -->
<button
type="button"
onclick={() => {
tmp_entry_obj.priority = !entry.priority;
onSave();
}}
class="btn w-full mb-2 preset-tonal-tertiary transition hover:preset-filled-tertiary-500"
>
{#if entry.priority}
<Flag size="1.25em" class="text-success-500 mr-2" />
{:else}
<FlagOff size="1.25em" class="opacity-50 mr-2" />
{/if}
<span>Priority Status</span>
</button>
<!-- Flags (Standardized component) -->
<AE_ObjectFlags
bind:obj={tmp_entry_obj}
onToggle={onSave}
hideAlert={journal?.cfg_json?.hide_btn_alert}
hidePrivate={journal?.cfg_json?.hide_btn_private}
hidePublic={journal?.cfg_json?.hide_btn_public}
hidePersonal={journal?.cfg_json?.hide_btn_personal}
hideProfessional={journal?.cfg_json?.hide_btn_professional}
hideTemplate={journal?.cfg_json?.hide_btn_template}
/>
<!-- Sort Order -->
<div class="w-full flex flex-row items-center justify-center border border-surface-500/30 rounded-lg p-1 bg-surface-500/5">
<button
type="button"
onclick={() => {
tmp_entry_obj.sort = (entry.sort ?? 0) + 1;
onSave();
}}
class="btn-icon btn-icon-sm preset-tonal-surface hover:preset-filled-secondary-500"
>
<Plus size="1em" />
<!-- Copy Actions -->
<div class="grid grid-cols-3 gap-1">
<button class="btn btn-sm variant-soft-surface" onclick={() => copyToClipboard(tmp_entry_obj.content, 'Markdown copied!')} title="Copy Markdown">
<RemoveFormatting size="1.2em" />
</button>
<span class="mx-4 font-bold text-base min-w-[1.5em] text-center">
{tmp_entry_obj.sort ?? entry.sort ?? 0}
</span>
<button
type="button"
onclick={() => {
tmp_entry_obj.sort = Math.max(0, (entry.sort ?? 0) - 1);
onSave();
}}
class="btn-icon btn-icon-sm preset-tonal-surface hover:preset-filled-secondary-500"
>
<Minus size="1em" />
<button class="btn btn-sm variant-soft-surface" onclick={() => copyToClipboard(entry.content_md_html || '', 'HTML copied!')} title="Copy HTML">
<CodeXml size="1.2em" />
</button>
<button class="btn btn-sm variant-soft-surface" onclick={copyRichText} title="Copy Rich Text">
<TypeOutline size="1.2em" />
</button>
</div>
<div class="divider"></div>
<div class="divider !my-1"></div>
<!-- Archive On -->
<div class="flex flex-row items-center justify-between gap-2 border border-surface-500/20 rounded p-1">
<input
type="datetime-local"
bind:value={tmp_entry_obj.archive_on}
onchange={onSave}
class="input input-sm border-none bg-transparent"
/>
<!-- History & Sort Section -->
<div class="flex flex-col gap-2">
<!-- History Toggle -->
{#if entry.history || entry.history_encrypted}
<button
class="btn btn-sm w-full { $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'history' ? 'variant-filled-secondary' : 'variant-soft-secondary'}"
onclick={onDecryptHistory}
>
<History size="1.1em" class="mr-2" /> Review History
</button>
{/if}
<!-- Cleaned Sort Controls -->
<div class="flex items-center justify-between p-2 bg-surface-500/10 rounded-lg border border-surface-500/20">
<span class="text-xs font-bold uppercase tracking-wider opacity-60">Sort Order</span>
<div class="flex items-center gap-3">
<button
class="btn-icon btn-icon-sm variant-filled-surface border border-surface-500/50"
onclick={() => { tmp_entry_obj.sort = (entry.sort ?? 0) + 1; onSave(); }}
>
<Plus size="1em" />
</button>
<span class="font-mono font-bold text-sm w-6 text-center">{tmp_entry_obj.sort ?? entry.sort ?? 0}</span>
<button
class="btn-icon btn-icon-sm variant-filled-surface border border-surface-500/50"
onclick={() => { tmp_entry_obj.sort = Math.max(0, (entry.sort ?? 0) - 1); onSave(); }}
>
<Minus size="1em" />
</button>
</div>
</div>
</div>
<!-- Archive Control -->
<div class="flex items-center gap-2 p-1 bg-surface-500/5 rounded border border-surface-500/10">
<Clock size="1.1em" class="opacity-50 ml-1" />
<input type="datetime-local" bind:value={tmp_entry_obj.archive_on} onchange={onSave} class="input input-sm border-none bg-transparent text-xs grow" />
{#if entry.archive_on}
<button onclick={() => { tmp_entry_obj.archive_on = null; onSave(); }} class="text-error-500">
<X size="1.2em" />
</button>
{:else}
<button onclick={() => { tmp_entry_obj.archive_on = new Date().toISOString().slice(0, 16); onSave(); }} class="text-primary-500">
<Clock size="1.2em" />
</button>
<button onclick={() => { tmp_entry_obj.archive_on = null; onSave(); }} class="btn-icon btn-icon-sm text-error-500"><X size="1em"/></button>
{/if}
</div>
<!-- Danger Zone: Delete -->
<button
type="button"
onclick={delete_entry}
class="btn variant-filled-error w-full mt-4"
>
<Trash2 size="1.25em" class="mr-2" />
Delete Entry
<!-- Move to Journal -->
{#if $ae_loc.edit_mode && journals_li.length}
<div class="p-2 border border-surface-500/20 rounded-lg space-y-1">
<span class="text-[10px] uppercase font-bold opacity-50 flex items-center gap-1">
<SquareLibrary size="1em" /> Move to Journal
</span>
<select
class="select select-sm w-full text-xs"
bind:value={tmp_entry_obj.journal_id}
onchange={() => { if(confirm('Change parent journal?')) onChangeJournal(); }}
>
<option value="">Select Journal</option>
{#each journals_li as j}
<option value={j.journal_id}>{j.name}</option>
{/each}
</select>
</div>
{/if}
<!-- Deletion -->
<button class="btn btn-sm variant-filled-error w-full mt-2" onclick={delete_entry}>
<Trash2 size="1.1em" class="mr-2" /> Delete Entry
</button>
</div>
</div>