From 81a5a90b209bed75b192512283b21e88f2475b80 Mon Sep 17 00:00:00 2001 From: beo3000 Date: Fri, 20 Feb 2026 17:49:04 +0100 Subject: [PATCH] upd meniu --- .../client/src/lib/components/Sidebar.svelte | 42 +++++++++++++++---- ka-note/client/src/lib/db/repositories.ts | 8 ++++ ka-note/client/src/lib/db/schema.ts | 8 ++++ ka-note/client/src/lib/db/seed.ts | 20 ++++----- ka-note/client/src/routes/+layout.svelte | 2 +- .../client/src/routes/companies/+page.svelte | 7 +++- .../client/src/routes/meetings/+page.svelte | 7 +++- .../client/src/routes/persons/+page.svelte | 7 +++- .../client/src/routes/projects/+page.svelte | 7 +++- ka-note/server/src/db/schema.ts | 1 + ka-note/server/src/lib/sync-service.ts | 2 + ka-note/shared/src/types.ts | 1 + 12 files changed, 89 insertions(+), 23 deletions(-) diff --git a/ka-note/client/src/lib/components/Sidebar.svelte b/ka-note/client/src/lib/components/Sidebar.svelte index c515bc6..ca2d3f8 100644 --- a/ka-note/client/src/lib/components/Sidebar.svelte +++ b/ka-note/client/src/lib/components/Sidebar.svelte @@ -21,10 +21,16 @@ const contexts = liveQuery(() => db.contexts.filter(c => !c.deletedAt && !c.archivedAt).sortBy('sortOrder')); const dailyLog = $derived(($contexts ?? []).find((c: AgendaContext) => c.id === 'daily-log')); - const meetings = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'meeting' && c.id !== 'daily-log')); - const projects = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'project')); - const companies = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'company')); - const people = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'person')); + const meetings = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'meeting' && c.id !== 'daily-log' && c.isFavorite)); + const projects = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'project' && c.isFavorite)); + const companies = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'company' && c.isFavorite)); + const people = $derived(($contexts ?? []).filter((c: AgendaContext) => c.type === 'person' && c.isFavorite)); + + let collapsed: Record = $state({}); + + function toggleSection(key: string) { + collapsed[key] = !collapsed[key]; + } let creatingType: ContextType | null = $state(null); let newName = $state(''); @@ -103,9 +109,13 @@
- Jour Fixes +
+{#if !collapsed['meetings']} +{/if}
- Projects +
+{#if !collapsed['projects']} +{/if}
- Firmen +
+{#if !collapsed['companies']} +{/if}
- People +
+{#if !collapsed['people']} +{/if} {#if isDev}
diff --git a/ka-note/client/src/lib/db/repositories.ts b/ka-note/client/src/lib/db/repositories.ts index 5e0b6fd..40953ac 100644 --- a/ka-note/client/src/lib/db/repositories.ts +++ b/ka-note/client/src/lib/db/repositories.ts @@ -28,6 +28,7 @@ export async function upsertContext(ctx: Partial & { id: string } sortOrder: 0, meta: null, archivedAt: null, + isFavorite: false, deletedAt: null, updatedAt: now(), version: 1, @@ -57,6 +58,13 @@ export async function unarchiveContext(id: string): Promise { } } +export async function toggleFavorite(id: string): Promise { + const ctx = await db.contexts.get(id); + if (ctx) { + await db.contexts.update(id, { isFavorite: !ctx.isFavorite, updatedAt: now(), version: ctx.version + 1 }); + } +} + export async function findContextByMentionName(name: string, type: 'person' | 'project' | 'company'): Promise { const q = name.toLowerCase(); return db.contexts diff --git a/ka-note/client/src/lib/db/schema.ts b/ka-note/client/src/lib/db/schema.ts index ae68e0e..6299e06 100644 --- a/ka-note/client/src/lib/db/schema.ts +++ b/ka-note/client/src/lib/db/schema.ts @@ -60,6 +60,14 @@ export class KaNoteDB extends Dexie { if (rating.comment === undefined) rating.comment = null; }); }); + + this.version(6).stores({ + contexts: 'id, type, sortOrder, deletedAt, archivedAt, isFavorite' + }).upgrade(tx => { + return tx.table('contexts').toCollection().modify(ctx => { + if (ctx.isFavorite === undefined) ctx.isFavorite = false; + }); + }); } } diff --git a/ka-note/client/src/lib/db/seed.ts b/ka-note/client/src/lib/db/seed.ts index 2339f1b..c4f59d8 100644 --- a/ka-note/client/src/lib/db/seed.ts +++ b/ka-note/client/src/lib/db/seed.ts @@ -13,16 +13,16 @@ export async function seedIfEmpty(): Promise { const ts = now(); const contexts: AgendaContext[] = [ - { id: 'daily-log', name: 'Daily Log / Inbox', type: 'meeting', sortOrder: 0, meta: null, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'jf-sysadmins', name: 'JF Team Sysadmins', type: 'meeting', sortOrder: 1, meta: null, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'jf-devs', name: 'JF Developer', type: 'meeting', sortOrder: 2, meta: null, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'p-tisax', name: 'Project TISAX', type: 'project', sortOrder: 0, meta: { status: '#stInArbeit', owner: 'STEFE', links: 'FileServer/Projects/TISAX' }, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'p-cloud-migration', name: 'Project CLOUD-MIGRATION', type: 'project', sortOrder: 1, meta: { status: '#stBlocked', owner: 'CHFI', links: 'Jira-1234' }, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'u-stefe', name: 'Person STEFE', type: 'person', sortOrder: 0, meta: { fullName: 'Stefan E.', email: 'stefe@example.com', phone: '+49 123 456', duSince: '2020', personSubType: 'employee' }, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'u-chfi', name: 'Person CHFI', type: 'person', sortOrder: 1, meta: { fullName: 'Christoph F.', email: 'chfi@example.com', phone: '98765', duSince: '2024', personSubType: 'employee' }, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'u-vendor-x', name: 'Person VENDOR-X', type: 'person', sortOrder: 2, meta: { fullName: 'Hr. Müller (Vendor X)', email: 'sales@vendor-x.com', phone: '', duSince: '', personSubType: 'contact' }, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'u-chrkl', name: 'Person ChrKl', type: 'person', sortOrder: 3, meta: { fullName: 'Christian Kl.', email: '', phone: '', duSince: '', personSubType: 'colleague' }, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 }, - { id: 'f-vendor-x', name: 'Firma VENDOR-X', type: 'company', sortOrder: 0, meta: { website: 'https://vendor-x.com', address: 'Musterstr. 1, 12345 Berlin' }, archivedAt: null, updatedAt: ts, deletedAt: null, version: 1 } + { id: 'daily-log', name: 'Daily Log / Inbox', type: 'meeting', sortOrder: 0, meta: null, archivedAt: null, isFavorite: true, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'jf-sysadmins', name: 'JF Team Sysadmins', type: 'meeting', sortOrder: 1, meta: null, archivedAt: null, isFavorite: true, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'jf-devs', name: 'JF Developer', type: 'meeting', sortOrder: 2, meta: null, archivedAt: null, isFavorite: true, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'p-tisax', name: 'Project TISAX', type: 'project', sortOrder: 0, meta: { status: '#stInArbeit', owner: 'STEFE', links: 'FileServer/Projects/TISAX' }, archivedAt: null, isFavorite: true, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'p-cloud-migration', name: 'Project CLOUD-MIGRATION', type: 'project', sortOrder: 1, meta: { status: '#stBlocked', owner: 'CHFI', links: 'Jira-1234' }, archivedAt: null, isFavorite: false, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'u-stefe', name: 'Person STEFE', type: 'person', sortOrder: 0, meta: { fullName: 'Stefan E.', email: 'stefe@example.com', phone: '+49 123 456', duSince: '2020', personSubType: 'employee' }, archivedAt: null, isFavorite: true, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'u-chfi', name: 'Person CHFI', type: 'person', sortOrder: 1, meta: { fullName: 'Christoph F.', email: 'chfi@example.com', phone: '98765', duSince: '2024', personSubType: 'employee' }, archivedAt: null, isFavorite: false, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'u-vendor-x', name: 'Person VENDOR-X', type: 'person', sortOrder: 2, meta: { fullName: 'Hr. Müller (Vendor X)', email: 'sales@vendor-x.com', phone: '', duSince: '', personSubType: 'contact' }, archivedAt: null, isFavorite: false, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'u-chrkl', name: 'Person ChrKl', type: 'person', sortOrder: 3, meta: { fullName: 'Christian Kl.', email: '', phone: '', duSince: '', personSubType: 'colleague' }, archivedAt: null, isFavorite: false, updatedAt: ts, deletedAt: null, version: 1 }, + { id: 'f-vendor-x', name: 'Firma VENDOR-X', type: 'company', sortOrder: 0, meta: { website: 'https://vendor-x.com', address: 'Musterstr. 1, 12345 Berlin' }, archivedAt: null, isFavorite: true, updatedAt: ts, deletedAt: null, version: 1 } ]; // Topic IDs diff --git a/ka-note/client/src/routes/+layout.svelte b/ka-note/client/src/routes/+layout.svelte index 66b1253..ec7edc4 100644 --- a/ka-note/client/src/routes/+layout.svelte +++ b/ka-note/client/src/routes/+layout.svelte @@ -47,7 +47,7 @@ diff --git a/ka-note/client/src/routes/companies/+page.svelte b/ka-note/client/src/routes/companies/+page.svelte index e9d779e..d27361d 100644 --- a/ka-note/client/src/routes/companies/+page.svelte +++ b/ka-note/client/src/routes/companies/+page.svelte @@ -2,7 +2,7 @@ import { goto } from '$app/navigation'; import { liveQuery } from 'dexie'; import { db } from '$lib/db/schema'; - import { softDeleteContext } from '$lib/db/repositories'; + import { softDeleteContext, toggleFavorite } from '$lib/db/repositories'; import ConfirmDialog from '$lib/components/ConfirmDialog.svelte'; const allCompanies = liveQuery(() => @@ -36,6 +36,11 @@
{#each companies as ctx (ctx.id)}
+