Making things prettier:

npx prettier --write src/routes/journals/
This commit is contained in:
Scott Idem
2026-05-05 17:27:48 -04:00
parent 8b087edeb9
commit 62cc26d1f9
16 changed files with 142 additions and 106 deletions

View File

@@ -83,11 +83,11 @@ $effect(() => {
class=" class="
ae_journals__journal ae_journals__journal
mx-auto mx-auto
flex w-full max-w-none min-w-0 flex min-h-0 w-full max-w-none
min-w-0
flex-col flex-col
items-stretch items-stretch
gap-1 gap-1
min-h-0
space-y-2 space-y-2
"> ">
<div <div
@@ -197,12 +197,7 @@ Middle-click to open in new tab`}>
.length}&times; Recent Entries... .length}&times; Recent Entries...
</option> </option>
<!-- loop through each key value --> <!-- loop through each key value -->
{#each Object.entries( {#each Object.entries($journals_loc.entry_view_history_kv as Record<string, { id: string; name: string; url: string }>).reverse() as [journal_entry_id, journal_entry_obj] (journal_entry_id)}
$journals_loc.entry_view_history_kv as Record<
string,
{ id: string; name: string; url: string }
>
).reverse() as [journal_entry_id, journal_entry_obj] (journal_entry_id)}
<option value={journal_entry_obj.id}> <option value={journal_entry_obj.id}>
{(journal_entry_obj?.name || {(journal_entry_obj?.name ||
journal_entry_obj?.id) ?? journal_entry_obj?.id) ??
@@ -237,7 +232,9 @@ Middle-click to open in new tab`}>
</a> </a>
{:else} {:else}
<!-- Edit Journal button. Creates a modal to edit the journal. --> <!-- Edit Journal button. Creates a modal to edit the journal. -->
<Journal_entry_obj_qry {log_lvl} lq__journal_obj={$lq__journal_obj} /> <Journal_entry_obj_qry
{log_lvl}
lq__journal_obj={$lq__journal_obj} />
{/if} {/if}
<!-- Add default journal entry --> <!-- Add default journal entry -->

View File

@@ -114,7 +114,10 @@ let lq__journal_entry_obj_li = $derived(
const journal_id = $lq__journal_obj?.journal_id; const journal_id = $lq__journal_obj?.journal_id;
return liveQuery(async () => { return liveQuery(async () => {
if (params.remote_first && (!Array.isArray(ids) || ids.length === 0)) { if (
params.remote_first &&
(!Array.isArray(ids) || ids.length === 0)
) {
return null; return null;
} }
@@ -258,14 +261,11 @@ async function handle_search_refresh(params: JournalSearchParams) {
const api_ids = api_results const api_ids = api_results
.map((entry) => entry.id || entry.journal_entry_id) .map((entry) => entry.id || entry.journal_entry_id)
.filter((entry): entry is string => Boolean(entry)); .filter((entry): entry is string => Boolean(entry));
const display_ids = !qry_str && local_ids.length > 0 ? local_ids : api_ids; const display_ids =
!qry_str && local_ids.length > 0 ? local_ids : api_ids;
// Protect UI cache if API returns empty during revalidation // Protect UI cache if API returns empty during revalidation
if ( if (!qry_str && local_ids.length > 0 && api_ids.length === 0) {
!qry_str &&
local_ids.length > 0 &&
api_ids.length === 0
) {
untrack(() => { untrack(() => {
$journals_sess.entry.qry__status = 'done'; $journals_sess.entry.qry__status = 'done';
}); });

View File

@@ -278,8 +278,8 @@ $effect(() => {
flex-col flex-col
items-stretch items-stretch
gap-1 gap-1
px-2 md:px-4 space-y-2 px-2
space-y-2 md:px-4
"> ">
<!-- {#if $lq__journal_entry_obj} --> <!-- {#if $lq__journal_entry_obj} -->
<Journal_entry_view <Journal_entry_view

View File

@@ -18,7 +18,8 @@ let { content, summary = $bindable(), on_save, log_lvl = 0 }: Props = $props();
</script> </script>
<div class="journal-entry-floating-actions absolute top-14 right-2 z-10"> <div class="journal-entry-floating-actions absolute top-14 right-2 z-10">
<div class="journal-entry-ai-tools inline-flex flex-wrap items-center justify-end gap-1"> <div
class="journal-entry-ai-tools inline-flex flex-wrap items-center justify-end gap-1">
<AE_AITools <AE_AITools
{content} {content}
model={$journals_loc.llm__api_model} model={$journals_loc.llm__api_model}

View File

@@ -39,7 +39,9 @@ let {
const is_editing = $derived( const is_editing = $derived(
$journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current' $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'
); );
const preferred_viewer = $derived((journal?.cfg_json?.pref_viewer ?? 'rendered').toLowerCase()); const preferred_viewer = $derived(
(journal?.cfg_json?.pref_viewer ?? 'rendered').toLowerCase()
);
</script> </script>
<div <div
@@ -58,7 +60,7 @@ const preferred_viewer = $derived((journal?.cfg_json?.pref_viewer ?? 'rendered')
class_li="w-full rounded-lg bg-surface-50 shadow-lg dark:bg-surface-800" /> class_li="w-full rounded-lg bg-surface-50 shadow-lg dark:bg-surface-800" />
{:else if preferred_viewer === 'plain'} {:else if preferred_viewer === 'plain'}
<div <div
class="bg-surface-50 dark:bg-surface-800 text-surface-800 dark:text-surface-100 w-full rounded-lg border border-gray-200 p-4 font-mono text-sm whitespace-pre-wrap wrap-break-word shadow-lg dark:border-gray-700"> class="bg-surface-50 dark:bg-surface-800 text-surface-800 dark:text-surface-100 w-full rounded-lg border border-gray-200 p-4 font-mono text-sm wrap-break-word whitespace-pre-wrap shadow-lg dark:border-gray-700">
{tmp_entry_obj?.content || ''} {tmp_entry_obj?.content || ''}
</div> </div>
{:else} {:else}
@@ -114,7 +116,7 @@ const preferred_viewer = $derived((journal?.cfg_json?.pref_viewer ?? 'rendered')
{:else} {:else}
<textarea <textarea
bind:value={tmp_entry_obj.content} bind:value={tmp_entry_obj.content}
class="textarea h-125 w-full grow rounded-lg border-orange-500/30 p-4 font-mono whitespace-pre-wrap wrap-break-word shadow-lg" class="textarea h-125 w-full grow rounded-lg border-orange-500/30 p-4 font-mono wrap-break-word whitespace-pre-wrap shadow-lg"
placeholder="Edit content..."></textarea> placeholder="Edit content..."></textarea>
{/if} {/if}

View File

@@ -100,11 +100,12 @@ function toggle_edit_mode() {
<input <input
type="text" type="text"
bind:value={tmp_entry_obj.name} bind:value={tmp_entry_obj.name}
class="input input-sm h-10 min-w-0 flex-1 border-none bg-transparent text-lg font-bold leading-none transition-colors duration-150 focus:ring-2 focus:ring-primary-500" class="input input-sm focus:ring-primary-500 h-10 min-w-0 flex-1 border-none bg-transparent text-lg leading-none font-bold transition-colors duration-150 focus:ring-2"
placeholder="Entry Title..." placeholder="Entry Title..."
onchange={on_save} /> onchange={on_save} />
{:else} {:else}
<h2 class="flex h-10 min-w-0 flex-1 items-center truncate text-base font-bold leading-none md:text-lg"> <h2
class="flex h-10 min-w-0 flex-1 items-center truncate text-base leading-none font-bold md:text-lg">
{entry.name || {entry.name ||
ae_util.iso_datetime_formatter( ae_util.iso_datetime_formatter(
entry.created_on, entry.created_on,
@@ -115,14 +116,16 @@ function toggle_edit_mode() {
</div> </div>
</div> </div>
<div class="ml-auto flex shrink-0 items-center gap-2 whitespace-nowrap transition-colors duration-150"> <div
class="ml-auto flex shrink-0 items-center gap-2 whitespace-nowrap transition-colors duration-150">
<!-- Auto-Save indicator --> <!-- Auto-Save indicator -->
{#if $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'} {#if $journals_loc.entry.edit_kv[entry.journal_entry_id] === 'current'}
<div <div
class="border-surface-500/20 mr-1 flex items-center gap-1 border-r px-2"> class="border-surface-500/20 mr-1 flex items-center gap-1 border-r px-2">
<button <button
type="button" type="button"
class="btn-icon btn-icon-sm transition-colors duration-150 {$journals_loc.entry.auto_save class="btn-icon btn-icon-sm transition-colors duration-150 {$journals_loc
.entry.auto_save
? 'text-primary-500' ? 'text-primary-500'
: 'opacity-30'}" : 'opacity-30'}"
onclick={() => onclick={() =>

View File

@@ -231,7 +231,8 @@ async function handle_remove_file(file_id: string) {
file.hosted_file_id || file.id || file.hosted_file_id} file.hosted_file_id || file.id || file.hosted_file_id}
<div <div
class="bg-surface-50-950 border-surface-500/10 group hover:border-primary-500 flex items-center justify-between rounded-xl border p-3 shadow-sm transition-all"> class="bg-surface-50-950 border-surface-500/10 group hover:border-primary-500 flex items-center justify-between rounded-xl border p-3 shadow-sm transition-all">
<div class="flex grow items-center gap-3 overflow-hidden"> <div
class="flex grow items-center gap-3 overflow-hidden">
<AE_Comp_Hosted_Files_Download_Button <AE_Comp_Hosted_Files_Download_Button
hosted_file_id={file_id} hosted_file_id={file_id}
hosted_file_obj={file} hosted_file_obj={file}
@@ -281,7 +282,9 @@ async function handle_remove_file(file_id: string) {
<FileUp size="1.8em" /> <FileUp size="1.8em" />
</div> </div>
<div class="text-center"> <div class="text-center">
<p class="font-bold">Upload new attachment</p> <p class="font-bold">
Upload new attachment
</p>
<p class="text-xs opacity-60"> <p class="text-xs opacity-60">
Drag and drop or click to browse Drag and drop or click to browse
</p> </p>

View File

@@ -438,9 +438,9 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
group-hover/entry-view:opacity-15 dark:opacity-10 dark:group-hover/entry-view:opacity-20"> group-hover/entry-view:opacity-15 dark:opacity-10 dark:group-hover/entry-view:opacity-20">
</div> </div>
<section <section
class="ae_view relative flex w-full min-w-0 flex-col gap-4 rounded-xl class="ae_view border-surface-200-800 bg-surface-50-900 relative flex w-full min-w-0 flex-col
border border-surface-200-800 gap-4 rounded-xl
bg-surface-50-900 p-2 shadow-xl" border p-2 shadow-xl"
bind:clientHeight={$ae_loc.iframe_height_modal_body}> bind:clientHeight={$ae_loc.iframe_height_modal_body}>
{#if $lq__journal_entry_obj && $lq__journal_obj} {#if $lq__journal_entry_obj && $lq__journal_obj}
<AE_Comp_Journal_Entry_Header <AE_Comp_Journal_Entry_Header
@@ -459,7 +459,8 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
{#if decryption_error} {#if decryption_error}
<div <div
class="bg-error-100 border-error-300 flex w-full animate-bounce items-center justify-between rounded-lg border p-4 shadow-xl"> class="bg-error-100 border-error-300 flex w-full animate-bounce items-center justify-between rounded-lg border p-4 shadow-xl">
<div class="text-error-700 flex items-center gap-4 font-bold"> <div
class="text-error-700 flex items-center gap-4 font-bold">
<CircleAlert size="2.5em" /> <CircleAlert size="2.5em" />
<span class="text-xl">{decryption_error}</span> <span class="text-xl">{decryption_error}</span>
</div> </div>
@@ -474,19 +475,17 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
<!-- ring-2 inset indicates "edit mode" in both light and dark without a background swap --> <!-- ring-2 inset indicates "edit mode" in both light and dark without a background swap -->
<section <section
class="relative grow overflow-hidden rounded-xl border border-surface-200-800 class="border-surface-200-800 bg-surface-100-900 relative min-w-0 grow overflow-hidden
bg-surface-100-900 p-2 shadow-md min-w-0 rounded-xl border p-2 shadow-md
{$journals_loc.entry.edit_kv[ {$journals_loc.entry.edit_kv[
$lq__journal_entry_obj?.journal_entry_id $lq__journal_entry_obj?.journal_entry_id
] == 'current' ] == 'current'
? 'ring-primary-500/40 ring-2 ring-inset' ? 'ring-primary-500/40 ring-2 ring-inset'
: ''}"> : ''}">
<AE_Comp_Journal_Entry_AiTools <AE_Comp_Journal_Entry_AiTools
content={ content={typeof tmp_entry_obj.content === 'string'
typeof tmp_entry_obj.content === 'string'
? tmp_entry_obj.content ? tmp_entry_obj.content
: '' : ''}
}
bind:summary={tmp_entry_obj.summary} bind:summary={tmp_entry_obj.summary}
on_save={() => update_journal_entry()} on_save={() => update_journal_entry()}
{log_lvl} /> {log_lvl} />
@@ -509,8 +508,9 @@ let modal_mode: 'append' | 'prepend' | 'auto' = $state('auto');
{lq__journal_entry_obj} /> {lq__journal_entry_obj} />
<div <div
class="rounded-xl border border-surface-200-800 bg-surface-100-900 p-3 shadow-sm"> class="border-surface-200-800 bg-surface-100-900 rounded-xl border p-3 shadow-sm">
<AE_Comp_Journal_Entry_Metadata entry={$lq__journal_entry_obj} /> <AE_Comp_Journal_Entry_Metadata
entry={$lq__journal_entry_obj} />
</div> </div>
</div> </div>

View File

@@ -107,9 +107,7 @@ let visible_journal_entry_obj_li = $derived(
</div> </div>
<section <section
class="journal_list relative flex w-full flex-col items-center justify-center gap-1 md:gap-2"> class="journal_list relative flex w-full flex-col items-center justify-center gap-1 md:gap-2">
{#if visible_journal_entry_obj_li === null || {#if visible_journal_entry_obj_li === null || ($journals_sess.entry.qry__status === 'loading' && visible_journal_entry_obj_li.length === 0)}
($journals_sess.entry.qry__status === 'loading' &&
visible_journal_entry_obj_li.length === 0)}
<!-- Loading state --> <!-- Loading state -->
<div <div
class="flex flex-col items-center justify-center p-10 opacity-50"> class="flex flex-col items-center justify-center p-10 opacity-50">

View File

@@ -16,14 +16,9 @@ interface Props {
let { log_lvl = $bindable(0), lq__journal_obj }: Props = $props(); let { log_lvl = $bindable(0), lq__journal_obj }: Props = $props();
import { import { Library, RemoveFormatting } from '@lucide/svelte';
Library,
RemoveFormatting
} from '@lucide/svelte';
import { import { ae_loc } from '$lib/stores/ae_stores';
ae_loc,
} from '$lib/stores/ae_stores';
import { import {
journals_loc, journals_loc,
journals_sess journals_sess
@@ -127,10 +122,13 @@ function prevent_default<T extends Event>(fn: (event: T) => void) {
{#if $ae_loc.edit_mode && ($ae_loc.manager_access || $ae_loc.trusted_access)} {#if $ae_loc.edit_mode && ($ae_loc.manager_access || $ae_loc.trusted_access)}
<span class="flex flex-row flex-wrap items-center gap-2"> <span class="flex flex-row flex-wrap items-center gap-2">
<span class="hidden text-sm text-gray-500 lg:inline"> Filters: </span> <span class="hidden text-sm text-gray-500 lg:inline">
Filters:
</span>
{#if $ae_loc.manager_access} {#if $ae_loc.manager_access}
<label class="flex flex-row items-center gap-1 text-xs font-semibold text-gray-500"> <label
class="flex flex-row items-center gap-1 text-xs font-semibold text-gray-500">
<span>Enabled</span> <span>Enabled</span>
<select <select
class="select select-sm" class="select select-sm"
@@ -145,7 +143,8 @@ function prevent_default<T extends Event>(fn: (event: T) => void) {
{/if} {/if}
{#if $ae_loc.trusted_access} {#if $ae_loc.trusted_access}
<label class="flex flex-row items-center gap-1 text-xs font-semibold text-gray-500"> <label
class="flex flex-row items-center gap-1 text-xs font-semibold text-gray-500">
<span>Hidden</span> <span>Hidden</span>
<select <select
class="select select-sm" class="select select-sm"

View File

@@ -236,7 +236,6 @@ async function handle_new_entry() {
{/if} {/if}
</div> </div>
</header> </header>
</section> </section>
</div> </div>

View File

@@ -41,12 +41,17 @@ let tmp_config: key_val = $state({
entry: {} entry: {}
}); });
const panel_class = 'space-y-4 rounded-xl border border-surface-500/20 bg-surface-500/5 p-4 shadow-sm'; const panel_class =
const panel_title_class = 'flex items-center gap-2 border-b border-surface-500/20 pb-2 text-lg font-bold'; 'space-y-4 rounded-xl border border-surface-500/20 bg-surface-500/5 p-4 shadow-sm';
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'; 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';
const tab_button_base_class = 'btn btn-sm border transition-all duration-200'; const tab_button_base_class = 'btn btn-sm border transition-all duration-200';
const tab_button_active_class = 'border-surface-200-800 bg-surface-200-800 text-surface-950-50 shadow-sm'; const tab_button_active_class =
const tab_button_inactive_class = 'border-transparent bg-surface-50-900/60 text-surface-600-400 hover:border-surface-200-800 hover:bg-surface-100-900 hover:text-surface-950-50'; 'border-surface-200-800 bg-surface-200-800 text-surface-950-50 shadow-sm';
const tab_button_inactive_class =
'border-transparent bg-surface-50-900/60 text-surface-600-400 hover:border-surface-200-800 hover:bg-surface-100-900 hover:text-surface-950-50';
function tab_button_class(is_active: boolean): string { function tab_button_class(is_active: boolean): string {
return `${tab_button_base_class} ${is_active ? tab_button_active_class : tab_button_inactive_class}`; return `${tab_button_base_class} ${is_active ? tab_button_active_class : tab_button_inactive_class}`;
@@ -75,7 +80,7 @@ function handle_save() {
dismissable={false} dismissable={false}
placement="top-center" placement="top-center"
size="xl" size="xl"
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" class="border-surface-200-800 bg-surface-50-900 text-surface-950-50 relative mx-auto flex h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] w-full flex-col rounded-xl border shadow-xl"
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" 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 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"> 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()}
@@ -306,7 +311,8 @@ function handle_save() {
<ShieldCheck size="1.2em" class="text-primary-500" /> <ShieldCheck size="1.2em" class="text-primary-500" />
Security & Encryption Security & Encryption
</h2> </h2>
<div class="space-y-4 rounded-lg border border-surface-500/10 bg-surface-500/5 p-4"> <div
class="border-surface-500/10 bg-surface-500/5 space-y-4 rounded-lg border p-4">
<div class="text-sm italic opacity-80"> <div class="text-sm italic opacity-80">
Global security overrides for the journal module. Global security overrides for the journal module.
</div> </div>
@@ -329,7 +335,8 @@ function handle_save() {
<CircleAlert size="1.2em" class="text-primary-500" /> <CircleAlert size="1.2em" class="text-primary-500" />
Alerts & Messaging Alerts & Messaging
</h2> </h2>
<div class="space-y-4 rounded-xl border border-surface-500/10 bg-surface-500/5 p-4"> <div
class="border-surface-500/10 bg-surface-500/5 space-y-4 rounded-xl border p-4">
<label class="label flex flex-col items-start gap-1"> <label class="label flex flex-col items-start gap-1">
<span class="text-sm font-bold opacity-70" <span class="text-sm font-bold opacity-70"
>Alert Message</span> >Alert Message</span>
@@ -362,7 +369,8 @@ function handle_save() {
<Settings size="1.2em" class="text-primary-500" /> <Settings size="1.2em" class="text-primary-500" />
Admin Admin
</h2> </h2>
<div class="space-y-4 rounded-xl border border-surface-500/10 bg-surface-500/5 p-4"> <div
class="border-surface-500/10 bg-surface-500/5 space-y-4 rounded-xl border p-4">
<label class="label flex flex-col items-start gap-1"> <label class="label flex flex-col items-start gap-1">
<span class="text-sm font-bold opacity-70" <span class="text-sm font-bold opacity-70"
>Notes</span> >Notes</span>
@@ -414,7 +422,8 @@ function handle_save() {
</div> </div>
</label> </label>
<label class="bg-surface-500/5 border-surface-500/10 flex items-center justify-between rounded-lg border p-3"> <label
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>
@@ -429,7 +438,8 @@ function handle_save() {
</label> </label>
</div> </div>
<div class="rounded-xl border border-surface-500/10 bg-surface-500/5 p-4"> <div
class="border-surface-500/10 bg-surface-500/5 rounded-xl border p-4">
<p class="text-xs italic opacity-70"> <p class="text-xs italic opacity-70">
Admin changes apply to the journal module state Admin changes apply to the journal module state
and are saved with the rest of this config. and are saved with the rest of this config.

View File

@@ -27,10 +27,7 @@ import { ae_loc, ae_api } from '$lib/stores/ae_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 { import type { ae_Journal, ae_JournalEntryDraft } from '$lib/types/ae_types';
ae_Journal,
ae_JournalEntryDraft
} from '$lib/types/ae_types';
interface Props { interface Props {
log_lvl?: number; log_lvl?: number;
@@ -64,12 +61,17 @@ const normalize_date = (val?: string | Date | null) => {
return val.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_class =
const panel_title_class = 'flex items-center gap-2 border-b border-surface-500/20 pb-2 text-lg font-bold'; 'space-y-4 rounded-xl border border-surface-500/20 bg-surface-500/5 p-4 shadow-sm';
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'; 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';
const tab_button_base_class = 'btn btn-sm border transition-all duration-200'; const tab_button_base_class = 'btn btn-sm border transition-all duration-200';
const tab_button_active_class = 'border-surface-200-800 bg-surface-200-800 text-surface-950-50 shadow-sm'; const tab_button_active_class =
const tab_button_inactive_class = 'border-transparent bg-surface-50-900/60 text-surface-600-400 hover:border-surface-200-800 hover:bg-surface-100-900 hover:text-surface-950-50'; 'border-surface-200-800 bg-surface-200-800 text-surface-950-50 shadow-sm';
const tab_button_inactive_class =
'border-transparent bg-surface-50-900/60 text-surface-600-400 hover:border-surface-200-800 hover:bg-surface-100-900 hover:text-surface-950-50';
function tab_button_class(is_active: boolean): string { function tab_button_class(is_active: boolean): string {
return `${tab_button_base_class} ${is_active ? tab_button_active_class : tab_button_inactive_class}`; return `${tab_button_base_class} ${is_active ? tab_button_active_class : tab_button_inactive_class}`;
@@ -134,7 +136,11 @@ async function handle_admin_delete_action() {
return; return;
} }
if (!confirm(`Are you sure you want to ${confirm_label} this journal entry?`)) { if (
!confirm(
`Are you sure you want to ${confirm_label} this journal entry?`
)
) {
return; return;
} }
@@ -149,7 +155,10 @@ async function handle_admin_delete_action() {
show = false; show = false;
await goto(`/journals/${tmp_entry_obj.journal_id}`); await goto(`/journals/${tmp_entry_obj.journal_id}`);
} catch (error) { } catch (error) {
console.error(`Error attempting to ${action_label} journal entry:`, error); console.error(
`Error attempting to ${action_label} journal entry:`,
error
);
alert(`Failed to ${action_label} journal entry.`); alert(`Failed to ${action_label} journal entry.`);
} }
} }
@@ -161,7 +170,7 @@ async function handle_admin_delete_action() {
dismissable={false} dismissable={false}
placement="top-center" placement="top-center"
size="lg" size="lg"
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" class="border-surface-200-800 bg-surface-50-900 text-surface-950-50 relative mx-auto flex h-[calc(100dvh-2rem)] max-h-[calc(100dvh-2rem)] w-full flex-col rounded-xl border shadow-xl"
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" 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="mt-auto flex w-full shrink-0 flex-row items-center justify-center gap-2 rounded-b-xl border-t border-surface-200-800 bg-surface-100-900 p-4"> footerClass="mt-auto flex w-full shrink-0 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()}
@@ -383,7 +392,8 @@ async function handle_admin_delete_action() {
</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">
{#if tmp_entry_obj.alert} {#if tmp_entry_obj.alert}
<label class="label md:col-span-2 flex flex-col items-start gap-1"> <label
class="label flex flex-col items-start gap-1 md:col-span-2">
<span class="text-sm font-bold opacity-70" <span class="text-sm font-bold opacity-70"
>Alert Message</span> >Alert Message</span>
<textarea <textarea
@@ -434,9 +444,11 @@ async function handle_admin_delete_action() {
</div> </div>
</label> </label>
<label class="bg-surface-500/5 border-surface-500/10 flex items-center justify-between rounded-lg border p-3"> <label
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">Sort Order</span> <span class="text-sm font-bold"
>Sort Order</span>
<span class="text-xs opacity-60"> <span class="text-xs opacity-60">
Lower numbers appear earlier in lists. Lower numbers appear earlier in lists.
</span> </span>
@@ -468,10 +480,13 @@ async function handle_admin_delete_action() {
<section class={panel_class}> <section class={panel_class}>
<h2 class={panel_title_class}> <h2 class={panel_title_class}>
<FingerprintPattern size="1.2em" class="text-primary-500" /> <FingerprintPattern
size="1.2em"
class="text-primary-500" />
Security and Privacy Security and Privacy
</h2> </h2>
<div class="space-y-4 rounded-xl border border-surface-500/10 bg-surface-500/5 p-4"> <div
class="border-surface-500/10 bg-surface-500/5 space-y-4 rounded-xl border p-4">
<label class="label flex flex-col items-start gap-1"> <label class="label flex flex-col items-start gap-1">
<span class="text-sm font-bold opacity-70" <span class="text-sm font-bold opacity-70"
>Passcode</span> >Passcode</span>
@@ -490,7 +505,8 @@ async function handle_admin_delete_action() {
</label> </label>
<div class="space-y-2"> <div class="space-y-2">
<p class="text-xs font-semibold uppercase tracking-wider opacity-60"> <p
class="text-xs font-semibold tracking-wider uppercase opacity-60">
Visibility and audience Visibility and audience
</p> </p>
<AE_Object_Flags <AE_Object_Flags
@@ -501,9 +517,11 @@ async function handle_admin_delete_action() {
on_save(); on_save();
}} }}
hide_alert={true} hide_alert={true}
hide_private={journal?.cfg_json?.hide_btn_private} hide_private={journal?.cfg_json
?.hide_btn_private}
hide_public={journal?.cfg_json?.hide_btn_public} hide_public={journal?.cfg_json?.hide_btn_public}
hide_personal={journal?.cfg_json?.hide_btn_personal} hide_personal={journal?.cfg_json
?.hide_btn_personal}
hide_professional={journal?.cfg_json hide_professional={journal?.cfg_json
?.hide_btn_professional} ?.hide_btn_professional}
hide_template={true} /> hide_template={true} />
@@ -536,19 +554,24 @@ async function handle_admin_delete_action() {
</section> </section>
{/if} {/if}
<details class="rounded-xl border border-surface-500/20 bg-surface-500/5 shadow-sm"> <details
<summary class="flex cursor-pointer items-center gap-2 border-b border-surface-500/20 px-4 py-3 text-lg font-bold"> class="border-surface-500/20 bg-surface-500/5 rounded-xl border shadow-sm">
<summary
class="border-surface-500/20 flex cursor-pointer items-center gap-2 border-b px-4 py-3 text-lg font-bold">
<Settings size="1.2em" class="text-primary-500" /> <Settings size="1.2em" class="text-primary-500" />
Admin Admin
</summary> </summary>
<div class="space-y-4 p-4"> <div class="space-y-4 p-4">
<p class="text-xs opacity-60"> <p class="text-xs opacity-60">
Trusted access and above only. Notes are for staff use; managers and admins see Delete while trusted access sees Remove. Trusted access and above only. Notes are for staff
use; managers and admins see Delete while trusted
access sees Remove.
</p> </p>
<div class="grid grid-cols-1 gap-4"> <div class="grid grid-cols-1 gap-4">
<label class="label"> <label class="label">
<span class="text-sm font-bold opacity-70">Notes</span> <span class="text-sm font-bold opacity-70"
>Notes</span>
<textarea <textarea
bind:value={tmp_entry_obj.notes} bind:value={tmp_entry_obj.notes}
class="textarea min-h-24" class="textarea min-h-24"
@@ -572,15 +595,21 @@ async function handle_admin_delete_action() {
<div class="flex flex-col"> <div class="flex flex-col">
<span class="font-bold">Enabled</span> <span class="font-bold">Enabled</span>
<span class="text-xs opacity-60"> <span class="text-xs opacity-60">
Allow default access for AE object type; essentially marked for deletion. Allow default access for AE object
type; essentially marked for
deletion.
</span> </span>
</div> </div>
</label> </label>
<button <button
type="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'}" 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 ||
title={($ae_loc.manager_access || $ae_loc.administrator_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' ? 'Permanently delete this journal entry'
: 'Disable this journal entry instead of deleting it'} : 'Disable this journal entry instead of deleting it'}
onclick={handle_admin_delete_action}> onclick={handle_admin_delete_action}>

View File

@@ -54,12 +54,7 @@ describe('Journal Entry Search Filtering', () => {
}); });
expect(result?.length).toBe(4); expect(result?.length).toBe(4);
expect(result?.map((entry) => entry.id)).toEqual([ expect(result?.map((entry) => entry.id)).toEqual(['4', '3', '2', '1']);
'4',
'3',
'2',
'1'
]);
}); });
it('should filter by enabled and hidden status', () => { it('should filter by enabled and hidden status', () => {