Standardize Core UI forms and unify schemas for V3 API compatibility

- Implement new Svelte 5 Person, Address, and Contact form components with surgical payload logic.
- Refactor core routes (People, Addresses, Contacts) to support unified Create/Edit workflows.
- Update ae_types.ts, db_core.ts, and db_journals.ts to align with V3 backend object models.
- Fix type safety issues in Journal history views and refine metadata display.
- Migrate person core functions to the newer ae_core__person module.
This commit is contained in:
Scott Idem
2026-01-09 15:14:36 -05:00
parent 8e205b2db9
commit 5056d5d8f0
18 changed files with 1276 additions and 944 deletions

View File

@@ -2,11 +2,13 @@
import { onMount } from 'svelte';
import { ae_loc, ae_api, slct } from '$lib/stores/ae_stores';
import { goto } from '$app/navigation';
import { Phone, Plus, Search, Mail, User, ExternalLink } from 'lucide-svelte';
import { Phone, Plus, Search, Mail, User, ExternalLink, X } from 'lucide-svelte';
import { load_ae_obj_li__contact, create_ae_obj__contact } from '$lib/ae_core/ae_core__contact';
import Contact_form from './ae_comp__contact_form.svelte';
let contact_li: any[] = $state([]);
let loading = $state(true);
let show_add_form = $state(false);
async function load_contacts() {
if (!$ae_loc.account_id) return;
@@ -20,27 +22,6 @@
loading = false;
}
async function handle_add() {
const name = prompt('Enter contact name:');
if (!name) return;
const email = prompt('Enter email address:');
const phone = prompt('Enter phone number:');
const result = await create_ae_obj__contact({
api_cfg: $ae_api,
account_id: $ae_loc.account_id,
data_kv: { name, email, phone, enable: true },
log_lvl: 1
});
if (result) {
load_contacts();
if (result.contact_id_random) {
goto(`/core/contacts/${result.contact_id_random}`);
}
}
}
onMount(() => {
if (!$ae_loc.manager_access) {
goto('/core');
@@ -56,11 +37,30 @@
<Phone size={24} />
<h1 class="h2">Contact Management</h1>
</div>
<button class="btn variant-filled-primary" onclick={handle_add}>
<Plus size={16} class="mr-2" /> Add Contact
<button class="btn variant-filled-primary" onclick={() => show_add_form = !show_add_form}>
{#if show_add_form}
<X size={16} class="mr-2" /> Cancel
{:else}
<Plus size={16} class="mr-2" /> Add Contact
{/if}
</button>
</header>
{#if show_add_form}
<div class="mb-8">
<Contact_form
onSave={(new_con) => {
show_add_form = false;
load_contacts();
if (new_con.contact_id_random) {
goto(`/core/contacts/${new_con.contact_id_random}`);
}
}}
onCancel={() => show_add_form = false}
/>
</div>
{/if}
{#if loading}
<div class="placeholder animate-pulse h-64 w-full"></div>
{:else if contact_li.length === 0}