diff --git a/ka-note/client/src/lib/components/DashboardView.svelte b/ka-note/client/src/lib/components/DashboardView.svelte index b1373f6..37e61f4 100644 --- a/ka-note/client/src/lib/components/DashboardView.svelte +++ b/ka-note/client/src/lib/components/DashboardView.svelte @@ -16,11 +16,25 @@ } let { context }: Props = $props(); + const isPerson = $derived(context.type === 'person'); const isProject = $derived(context.type === 'project'); const isCompany = $derived(context.type === 'company'); const entityName = $derived(context.name.replace(/^(Project |Person |Firma )/, '')); const isArchived = $derived(!!context.archivedAt); + // Person sub-type (reactive local state synced from DB) + let personSubType = $state('contact'); + $effect(() => { + personSubType = ((context.meta as PersonMeta | null)?.personSubType) ?? 'contact'; + }); + + function handleSubTypeChange(value: PersonSubType) { + personSubType = value; + const meta = { ...(context.meta ?? { fullName: '', email: '', phone: '', duSince: '' }) } as PersonMeta; + meta.personSubType = value; + upsertContext({ id: context.id, meta }); + } + // Metadata collapsed by default let metaOpen = $state(false); @@ -229,12 +243,6 @@ upsertContext({ id: context.id, meta: meta as any }); } - function updatePersonSubType(value: string) { - const meta = { ...(context.meta ?? { fullName: '', email: '', phone: '', duSince: '' }) } as PersonMeta; - meta.personSubType = value as PersonSubType; - upsertContext({ id: context.id, meta }); - } - // Local state for meta notes — only sync from DB on context switch let metaNotes = $state(''); let metaNotesContextId = ''; @@ -252,6 +260,20 @@ } + +{#if isPerson} + {@const subTypeColors = { contact: 'border-[#555] text-[#ccc]', employee: 'border-accent text-accent', colleague: 'border-[#00b894] text-[#00b894]' } as Record} +
+ Typ: + {#each [['contact', 'Kontakt'], ['employee', 'Mitarbeiter'], ['colleague', 'Kollege']] as [value, label]} + + {/each} +
+{/if} + {#if isArchived}
@@ -362,17 +384,6 @@
{:else} {@const meta = (context.meta ?? { fullName: '', email: '', phone: '', duSince: '' }) as PersonMeta} -
- - -
c.type === type); const sortOrder = existing.length; - await upsertContext({ id, name: fullName, type, sortOrder }); + const meta = type === 'person' ? { fullName: '', email: '', phone: '', duSince: '', personSubType: 'contact' as const } : undefined; + await upsertContext({ id, name: fullName, type, sortOrder, ...(meta ? { meta } : {}) }); cancelCreating(); navigate(id); }