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:
@@ -1,19 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { api } from '$lib/api/api';
|
||||
import { ae_api } from '$lib/stores/ae_stores';
|
||||
import { journals_slct, journals_loc, journals_trig } from '$lib/ae_journals/ae_journals_stores';
|
||||
import {
|
||||
journals_slct,
|
||||
journals_loc,
|
||||
journals_trig
|
||||
} from '$lib/ae_journals/ae_journals_stores';
|
||||
import { journals_func } from '$lib/ae_journals/ae_journals_functions';
|
||||
import { BookType } from 'lucide-svelte';
|
||||
|
||||
|
||||
// Props
|
||||
let {
|
||||
class: className = "",
|
||||
placeholder = "Type your quick note... (First line = Title)",
|
||||
let {
|
||||
class: className = '',
|
||||
placeholder = 'Type your quick note... (First line = Title)',
|
||||
journals_li = [] // Optional list of journals to select from
|
||||
} = $props();
|
||||
|
||||
// State
|
||||
let note_content = $state("");
|
||||
let note_content = $state('');
|
||||
let is_submitting = $state(false);
|
||||
|
||||
// Derived / Local target
|
||||
@@ -21,12 +25,14 @@
|
||||
let selected_journal_id = $state($journals_loc.entry.qry__journal_id);
|
||||
|
||||
// If a journal is explicitly selected via slct (e.g. we are in a journal view), use that
|
||||
let target_journal_id = $derived($journals_slct.journal_id || selected_journal_id);
|
||||
let target_journal_id = $derived(
|
||||
$journals_slct.journal_id || selected_journal_id
|
||||
);
|
||||
|
||||
async function handle_submit() {
|
||||
if (!note_content.trim()) return;
|
||||
if (!target_journal_id) {
|
||||
alert("Please select a target journal first.");
|
||||
alert('Please select a target journal first.');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,8 +40,8 @@
|
||||
|
||||
const lines = note_content.trim().split('\n');
|
||||
let name = lines[0].substring(0, 100);
|
||||
if (lines[0].length > 100) name += "...";
|
||||
|
||||
if (lines[0].length > 100) name += '...';
|
||||
|
||||
// Remove the first line (title) from the content
|
||||
const entry_content = lines.slice(1).join('\n').trim();
|
||||
|
||||
@@ -57,15 +63,15 @@
|
||||
});
|
||||
|
||||
if (res) {
|
||||
note_content = "";
|
||||
note_content = '';
|
||||
// Trigger refresh
|
||||
$journals_trig.journal_entry_li = true;
|
||||
} else {
|
||||
alert("Failed to create note.");
|
||||
alert('Failed to create note.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error creating journal entry:", error);
|
||||
alert("Failed to create note.");
|
||||
console.error('Error creating journal entry:', error);
|
||||
alert('Failed to create note.');
|
||||
}
|
||||
|
||||
is_submitting = false;
|
||||
@@ -85,20 +91,24 @@
|
||||
</script>
|
||||
|
||||
<div class="card p-4 space-y-4 variant-filled-surface {className}">
|
||||
<header class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2">
|
||||
<header
|
||||
class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-2"
|
||||
>
|
||||
<h3 class="h3 flex items-center gap-2">
|
||||
<BookType size="1.2em" class="text-primary-500" />
|
||||
Quick Add
|
||||
</h3>
|
||||
|
||||
|
||||
{#if journals_li && journals_li.length > 0}
|
||||
<div class="w-full sm:w-auto">
|
||||
<select
|
||||
<select
|
||||
class="select select-sm variant-filled-surface border-surface-500/30 font-bold"
|
||||
value={target_journal_id}
|
||||
onchange={handle_journal_change}
|
||||
>
|
||||
<option value="" disabled selected={!target_journal_id}>Select Target Journal...</option>
|
||||
<option value="" disabled selected={!target_journal_id}
|
||||
>Select Target Journal...</option
|
||||
>
|
||||
{#each journals_li as journal}
|
||||
<option value={journal.id}>{journal.name}</option>
|
||||
{/each}
|
||||
@@ -108,8 +118,8 @@
|
||||
<span class="badge variant-filled-error">No Journal Selected</span>
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
<textarea
|
||||
|
||||
<textarea
|
||||
class="textarea variant-filled-surface border-surface-500/20"
|
||||
rows="3"
|
||||
bind:value={note_content}
|
||||
@@ -119,26 +129,30 @@
|
||||
></textarea>
|
||||
|
||||
<div class="flex justify-between items-center">
|
||||
<span class="text-[10px] opacity-50 font-mono uppercase tracking-tighter hidden sm:block">
|
||||
<span
|
||||
class="text-[10px] opacity-50 font-mono uppercase tracking-tighter hidden sm:block"
|
||||
>
|
||||
Press Ctrl + Enter to save
|
||||
</span>
|
||||
<div class="flex justify-end space-x-2 grow sm:grow-0">
|
||||
<button
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm variant-ghost-surface"
|
||||
onclick={() => note_content = ""}
|
||||
onclick={() => (note_content = '')}
|
||||
disabled={is_submitting || note_content.length === 0}
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
<button
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm variant-filled-primary font-bold shadow-md"
|
||||
onclick={handle_submit}
|
||||
disabled={is_submitting || !target_journal_id || note_content.length === 0}
|
||||
disabled={is_submitting ||
|
||||
!target_journal_id ||
|
||||
note_content.length === 0}
|
||||
>
|
||||
{#if is_submitting}Saving...{:else}Add Note{/if}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user