From 9886b602f007d9ed6c4143f87d360883e50641b1 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Fri, 20 Feb 2026 18:19:20 +0100 Subject: [PATCH] comp person list --- .../lib/components/CompanyPersonsView.svelte | 46 ++++++++++ .../src/lib/components/ContextPage.svelte | 3 + .../src/lib/components/DashboardView.svelte | 70 ++------------ .../lib/components/EditableMarkdown.svelte | 91 +++++++++++++++++++ .../src/lib/components/PersonList.svelte | 77 ++++++++++++++++ .../client/src/lib/components/ViewTabs.svelte | 2 + .../client/src/routes/persons/+page.svelte | 72 +-------------- 7 files changed, 228 insertions(+), 133 deletions(-) create mode 100644 ka-note/client/src/lib/components/CompanyPersonsView.svelte create mode 100644 ka-note/client/src/lib/components/EditableMarkdown.svelte create mode 100644 ka-note/client/src/lib/components/PersonList.svelte diff --git a/ka-note/client/src/lib/components/CompanyPersonsView.svelte b/ka-note/client/src/lib/components/CompanyPersonsView.svelte new file mode 100644 index 0000000..72e8d32 --- /dev/null +++ b/ka-note/client/src/lib/components/CompanyPersonsView.svelte @@ -0,0 +1,46 @@ + + +
+ {#if persons.length > 0} + + {:else} +
Keine zugeordneten Personen.
+ {/if} +
diff --git a/ka-note/client/src/lib/components/ContextPage.svelte b/ka-note/client/src/lib/components/ContextPage.svelte index 3922e7b..34b6f2e 100644 --- a/ka-note/client/src/lib/components/ContextPage.svelte +++ b/ka-note/client/src/lib/components/ContextPage.svelte @@ -9,6 +9,7 @@ import PersonsView from './PersonsView.svelte'; import SnoozedView from './SnoozedView.svelte'; import DashboardView from './DashboardView.svelte'; + import CompanyPersonsView from './CompanyPersonsView.svelte'; import RatingModal from './RatingModal.svelte'; import RatingsView from './RatingsView.svelte'; @@ -93,6 +94,8 @@ {:else if activeView === 'dashboard'} + {:else if activeView === 'company-persons'} + {:else if activeView === 'ratings'} {/if} diff --git a/ka-note/client/src/lib/components/DashboardView.svelte b/ka-note/client/src/lib/components/DashboardView.svelte index 37e61f4..d0e1f30 100644 --- a/ka-note/client/src/lib/components/DashboardView.svelte +++ b/ka-note/client/src/lib/components/DashboardView.svelte @@ -9,6 +9,7 @@ import { mention } from '$lib/actions/mention'; import RenderedMarkdown from './RenderedMarkdown.svelte'; import MarkdownEditor from './MarkdownEditor.svelte'; + import EditableMarkdown from './EditableMarkdown.svelte'; import ConfirmDialog from './ConfirmDialog.svelte'; interface Props { @@ -202,30 +203,6 @@ return results.sort((a, b) => b.date.localeCompare(a.date)); }); - // Linked persons (company only): find person contexts mentioned alongside this company - const linkedPersons = liveQuery(async () => { - if (!isCompany) return []; - const allHistory = await db.historyEntries.filter(h => !h.deletedAt).toArray(); - const personContexts = await db.contexts.filter(c => !c.deletedAt && c.type === 'person').toArray(); - - const matchingPersonNames = new Set(); - for (const h of allHistory) { - if (extractCompanies(h.text).includes(entityName)) { - for (const mention of extractMentions(h.text)) { - matchingPersonNames.add(mention); - } - for (const assignment of extractAssignments(h.text)) { - matchingPersonNames.add(assignment); - } - } - } - - return personContexts.filter(p => { - const pName = p.name.replace(/^Person\s+/, ''); - return matchingPersonNames.has(pName); - }); - }); - // Archive / unarchive async function handleArchive() { await archiveContext(context.id); @@ -243,21 +220,6 @@ upsertContext({ id: context.id, meta: meta as any }); } - // Local state for meta notes — only sync from DB on context switch - let metaNotes = $state(''); - let metaNotesContextId = ''; - $effect(() => { - if (context.id !== metaNotesContextId) { - metaNotesContextId = context.id; - metaNotes = (context.meta as any)?.notes ?? ''; - } - }); - let metaNotesTimer: ReturnType; - function handleMetaNotesChange(md: string) { - metaNotes = md; - clearTimeout(metaNotesTimer); - metaNotesTimer = setTimeout(() => updateMeta('notes', md), 500); - } @@ -375,11 +337,11 @@
- updateMeta('notes', md)} />
{:else} @@ -406,11 +368,11 @@
- updateMeta('notes', md)} />
{/if} @@ -509,24 +471,6 @@ {/if} - -{#if isCompany} - {@const persons = $linkedPersons ?? []} - {#if persons.length > 0} -
-
Verknüpfte Personen
- {#each persons as p (p.id)} - - {/each} -
- {/if} -{/if} -
diff --git a/ka-note/client/src/lib/components/EditableMarkdown.svelte b/ka-note/client/src/lib/components/EditableMarkdown.svelte new file mode 100644 index 0000000..85fb1ba --- /dev/null +++ b/ka-note/client/src/lib/components/EditableMarkdown.svelte @@ -0,0 +1,91 @@ + + + +
+ {#if editing} + editorContent = md} + /> + {:else} + +
+ {#if content} + + {:else} + {placeholder} + {/if} +
+ {/if} +
+ + diff --git a/ka-note/client/src/lib/components/PersonList.svelte b/ka-note/client/src/lib/components/PersonList.svelte new file mode 100644 index 0000000..799794b --- /dev/null +++ b/ka-note/client/src/lib/components/PersonList.svelte @@ -0,0 +1,77 @@ + + +{#if persons.length > 0} +
+ {#each persons as ctx (ctx.id)} + {@const subType = ((ctx.meta as PersonMeta | null)?.personSubType ?? 'contact') as PersonSubType} +
+ + + +
+ {/each} +
+{:else} +
Keine Personen vorhanden.
+{/if} + +{#if confirmDeleteId} + confirmDeleteId = null} + /> +{/if} diff --git a/ka-note/client/src/lib/components/ViewTabs.svelte b/ka-note/client/src/lib/components/ViewTabs.svelte index e2c46b2..fe19d17 100644 --- a/ka-note/client/src/lib/components/ViewTabs.svelte +++ b/ka-note/client/src/lib/components/ViewTabs.svelte @@ -17,6 +17,7 @@ const isDailyLog = $derived(context.id === 'daily-log'); const isPerson = $derived(context.type === 'person'); + const isCompany = $derived(context.type === 'company'); const isEmployee = $derived(isPerson && ((context.meta as PersonMeta | null)?.personSubType ?? 'contact') === 'employee'); const tabs = $derived( @@ -29,6 +30,7 @@ ] : [ { id: 'dashboard', label: `Dashboard: ${context.name.replace(/^(Project |Person |Firma )/, '')}` }, + ...(isCompany ? [{ id: 'company-persons', label: 'Personen' }] : []), ...(isEmployee ? [{ id: 'ratings', label: 'Bewertungen' }] : []) ] ); diff --git a/ka-note/client/src/routes/persons/+page.svelte b/ka-note/client/src/routes/persons/+page.svelte index d27bbc6..c5367cb 100644 --- a/ka-note/client/src/routes/persons/+page.svelte +++ b/ka-note/client/src/routes/persons/+page.svelte @@ -1,84 +1,16 @@

Alle Personen

- - {#if persons.length > 0} -
- {#each persons as ctx (ctx.id)} - {@const subType = ((ctx.meta as PersonMeta | null)?.personSubType ?? 'contact') as PersonSubType} -
- - - -
- {/each} -
- {:else} -
Keine Personen vorhanden.
- {/if} +
- -{#if confirmDeleteId} - confirmDeleteId = null} - /> -{/if}