style(journals): apply expanded 80-width formatting and snake_case

- Batch formatted all Journals module files using Prettier with printWidth: 80.
- Refactored preventDefault to prevent_default across all Svelte components.
- Standardized line breaks for imports and long attribute lists for better readability.
- Ensured consistent snake_case naming for internal identifiers.
This commit is contained in:
Scott Idem
2026-02-06 14:15:43 -05:00
parent 07dd6c18a1
commit 2f3125c64b
37 changed files with 3033 additions and 1133 deletions

View File

@@ -16,112 +16,132 @@
log_lvl?: number;
}
let {
open = $bindable(false),
journal_entry,
journal_config,
let {
open = $bindable(false),
journal_entry,
journal_config,
mode = 'auto',
on_close,
on_close,
on_update,
log_lvl = 0
log_lvl = 0
}: Props = $props();
// Local State
let tmp_entry_obj: key_val = $state({});
// Local State
let tmp_entry_obj: key_val = $state({});
// Header Options
let add_timestamp_header: boolean = $state(true);
let add_timestamp_header_w_day_of_week: boolean = $state(true);
let add_text_header: string = $state('');
let add_text: string = $state('');
// Header Options
let add_timestamp_header: boolean = $state(true);
let add_timestamp_header_w_day_of_week: boolean = $state(true);
let add_text_header: string = $state('');
let add_text: string = $state('');
// Change detection
let has_changes: boolean = $derived(add_text_header.length > 0 || add_text.length > 0);
// Initialize tmp object when entry changes or modal opens
$effect(() => {
if (open && journal_entry) {
tmp_entry_obj = JSON.parse(JSON.stringify(journal_entry));
// Reset fields
add_text_header = '';
add_text = '';
}
});
async function handle_save() {
let current_entry_content = tmp_entry_obj?.content || '';
let add_content = '';
let new_content = current_entry_content;
// Construct the header/content to add (Following original logic)
let timestamp_str = ae_util.iso_datetime_formatter(
new Date(),
'datetime_iso_12_no_seconds'
// Change detection
let has_changes: boolean = $derived(
add_text_header.length > 0 || add_text.length > 0
);
let day_of_week_str = add_timestamp_header_w_day_of_week
? ' (' + ae_util.iso_datetime_formatter(new Date(), 'week_long') + ')'
: '';
if (add_timestamp_header && add_text_header) {
add_content =
'## ' +
timestamp_str +
day_of_week_str +
' - ' +
add_text_header.trim() +
'\n' +
add_text.trim() +
'\n\n';
} else if (add_timestamp_header) {
add_content = '## ' + timestamp_str + day_of_week_str + '\n' + add_text.trim() + '\n\n';
} else if (add_text_header) {
add_content =
'## ' + add_text_header.trim() + day_of_week_str + '\n' + add_text.trim() + '\n\n';
} else {
add_content = add_text.trim() + '\n\n';
}
// Initialize tmp object when entry changes or modal opens
$effect(() => {
if (open && journal_entry) {
tmp_entry_obj = JSON.parse(JSON.stringify(journal_entry));
// Reset fields
add_text_header = '';
add_text = '';
}
});
// Determine Append or Prepend
let effective_mode = mode;
if (effective_mode === 'auto') {
effective_mode = journal_config?.entry_add_text || 'append';
}
async function handle_save() {
let current_entry_content = tmp_entry_obj?.content || '';
let add_content = '';
let new_content = current_entry_content;
if (effective_mode == 'prepend') {
new_content = add_content + new_content;
} else {
// Append
new_content = new_content.trim() + '\n\n' + add_content;
}
// Construct the header/content to add (Following original logic)
let timestamp_str = ae_util.iso_datetime_formatter(
new Date(),
'datetime_iso_12_no_seconds'
);
let day_of_week_str = add_timestamp_header_w_day_of_week
? ' (' +
ae_util.iso_datetime_formatter(new Date(), 'week_long') +
')'
: '';
new_content = new_content.trim() + '\n';
let data_kv = { content: new_content };
try {
let update_result = await journals_func.update_ae_obj__journal_entry({
api_cfg: $ae_api,
journal_entry_id: tmp_entry_obj?.journal_entry_id,
data_kv: data_kv,
log_lvl: log_lvl
});
if (update_result) {
// Success
on_update();
open = false;
if (add_timestamp_header && add_text_header) {
add_content =
'## ' +
timestamp_str +
day_of_week_str +
' - ' +
add_text_header.trim() +
'\n' +
add_text.trim() +
'\n\n';
} else if (add_timestamp_header) {
add_content =
'## ' +
timestamp_str +
day_of_week_str +
'\n' +
add_text.trim() +
'\n\n';
} else if (add_text_header) {
add_content =
'## ' +
add_text_header.trim() +
day_of_week_str +
'\n' +
add_text.trim() +
'\n\n';
} else {
add_content = add_text.trim() + '\n\n';
}
// Determine Append or Prepend
let effective_mode = mode;
if (effective_mode === 'auto') {
effective_mode = journal_config?.entry_add_text || 'append';
}
if (effective_mode == 'prepend') {
new_content = add_content + new_content;
} else {
// Append
new_content = new_content.trim() + '\n\n' + add_content;
}
new_content = new_content.trim() + '\n';
let data_kv = { content: new_content };
try {
let update_result =
await journals_func.update_ae_obj__journal_entry({
api_cfg: $ae_api,
journal_entry_id: tmp_entry_obj?.journal_entry_id,
data_kv: data_kv,
log_lvl: log_lvl
});
if (update_result) {
// Success
on_update();
open = false;
} else {
alert('Failed to update journal entry.');
}
} catch (error) {
console.error('Error updating journal entry:', error);
alert('Failed to update journal entry.');
}
} catch (error) {
console.error('Error updating journal entry:', error);
alert('Failed to update journal entry.');
}
}
</script>
<Modal
title="{(mode === 'auto' ? journal_config?.entry_add_text : mode) == 'append' ? 'Append to' : 'Prepend to'} Journal Entry: {journal_entry?.name ?? journal_entry?.created_on}"
bind:open={open}
title="{(mode === 'auto' ? journal_config?.entry_add_text : mode) ==
'append'
? 'Append to'
: 'Prepend to'} Journal Entry: {journal_entry?.name ??
journal_entry?.created_on}"
bind:open
autoclose={false}
placement="top-center"
size="xl"
@@ -138,7 +158,10 @@ async function handle_save() {
bind:checked={add_timestamp_header}
class="p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500 inline-block"
/>
<label for="append_timestamp_header" class="p-2 inline-block">
<label
for="append_timestamp_header"
class="p-2 inline-block"
>
Use timestamp as Markdown header
</label>
@@ -148,7 +171,10 @@ async function handle_save() {
bind:checked={add_timestamp_header_w_day_of_week}
class="p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500 inline-block"
/>
<label for="append_timestamp_header_w_day_of_week" class="p-2 inline-block">
<label
for="append_timestamp_header_w_day_of_week"
class="p-2 inline-block"
>
Include day of week
</label>
</div>
@@ -167,12 +193,14 @@ async function handle_save() {
class="grow min-h-48 h-full w-full p-2 bg-slate-100 text-gray-900 dark:bg-slate-900 dark:text-gray-100 shadow-lg rounded-lg border border-gray-200 dark:border-gray-700 hover:border-gray-500 dark:hover:border-gray-500"
placeholder="Content to {mode === 'auto'
? journal_config?.entry_add_text
: mode}...">
: mode}..."
>
</textarea>
</div>
<div class="modal-action flex justify-end gap-2 mt-4">
<button type="button"
<button
type="button"
disabled={!has_changes}
onclick={handle_save}
class="btn btn-sm md:btn-md lg:btn-lg min-w-32 hover:variant-outline-success hover:preset-filled-success-500"
@@ -182,7 +210,8 @@ async function handle_save() {
<Check class="mr-1" />
Update
</button>
<button type="button"
<button
type="button"
onclick={on_close}
class="btn preset-tonal-surface border border-surface-500 hover:preset-filled-surface-500 transition"
>
@@ -192,4 +221,4 @@ async function handle_save() {
</div>
</div>
</div>
</Modal>
</Modal>