diff --git a/apps/todo/apps/web/src/routes/(app)/+page.svelte b/apps/todo/apps/web/src/routes/(app)/+page.svelte index 6d4760157..71cc1de63 100644 --- a/apps/todo/apps/web/src/routes/(app)/+page.svelte +++ b/apps/todo/apps/web/src/routes/(app)/+page.svelte @@ -2,12 +2,17 @@ import { getContext } from 'svelte'; import type { LocalBoardView } from '$lib/data/local-store'; import { BoardViewRenderer } from '$lib/components/board-views'; - import { todoSettings } from '$lib/stores/settings.svelte'; + import { todoSettings, type PageWidth } from '$lib/stores/settings.svelte'; + import { boardViewsStore } from '$lib/stores/board-views.svelte'; + import { ArrowLeft, ArrowRight, Plus, Trash } from '@manacore/shared-icons'; - // Get active view from layout context + // Get active view + edit mode from layout context const activeViewCtx: { readonly value: LocalBoardView | null } = getContext('activeView'); + const editModeCtx: { readonly active: boolean; toggle(): void; set(val: boolean): void } = + getContext('editMode'); + + let editMode = $derived(editModeCtx.active); - // Map layout mode to BoardViewRenderer layoutOverride const LAYOUT_MAP = { fokus: 'fokus', uebersicht: 'kanban', @@ -17,13 +22,191 @@ let layoutOverride = $derived(LAYOUT_MAP[todoSettings.activeLayoutMode]); let activeView = $derived(activeViewCtx.value); let pageTitle = $derived(activeView?.name ?? 'Aufgaben'); + + // ── Edit helpers ──────────────────────────────────────── + + const GROUPBY_OPTIONS = [ + { value: 'status', label: 'Status' }, + { value: 'priority', label: 'Priorität' }, + { value: 'project', label: 'Projekt' }, + { value: 'dueDate', label: 'Fälligkeit' }, + { value: 'custom', label: 'Benutzerdefiniert' }, + ]; + + const WIDTH_OPTIONS: { value: PageWidth; label: string }[] = [ + { value: 'narrow', label: 'S' }, + { value: 'medium', label: 'M' }, + { value: 'wide', label: 'L' }, + { value: 'full', label: 'XL' }, + ]; + + const COLUMN_COLORS = [ + '#EF4444', + '#F59E0B', + '#22C55E', + '#3B82F6', + '#8B5CF6', + '#EC4899', + '#14B8A6', + '#F97316', + '#6B7280', + ]; + + async function updateView(data: Partial) { + if (!activeView) return; + await boardViewsStore.updateView(activeView.id, data); + } + + function updateColumn(colIdx: number, data: Record) { + if (!activeView) return; + const cols = activeView.columns.map((c, i) => (i === colIdx ? { ...c, ...data } : { ...c })); + updateView({ columns: cols }); + } + + function removeColumn(colIdx: number) { + if (!activeView || activeView.columns.length <= 1) return; + updateView({ columns: activeView.columns.filter((_, i) => i !== colIdx) }); + } + + function addColumn() { + if (!activeView) return; + const newCol = { + id: `col-${crypto.randomUUID().slice(0, 8)}`, + name: 'Neue Spalte', + color: COLUMN_COLORS[activeView.columns.length % COLUMN_COLORS.length], + match: { type: 'custom' as const, value: `custom-${Date.now()}` }, + }; + updateView({ columns: [...activeView.columns, newCol] }); + } + + function moveColumn(colIdx: number, dir: -1 | 1) { + if (!activeView) return; + const cols = [...activeView.columns]; + const target = colIdx + dir; + if (target < 0 || target >= cols.length) return; + [cols[colIdx], cols[target]] = [cols[target], cols[colIdx]]; + updateView({ columns: cols }); + } + + let columnsEditable = $derived( + activeView?.groupBy === 'status' || activeView?.groupBy === 'custom' + ); + + function handleKeydown(e: KeyboardEvent) { + if (e.key === 'Escape' && editMode) { + editModeCtx.set(false); + } + } + + {pageTitle} - Todo -
+
+ + {#if editMode && activeView} +
+ updateView({ name: e.currentTarget.value })} + placeholder="View-Name" + /> + +
+ Gruppierung +
+ {#each GROUPBY_OPTIONS as opt} + + {/each} +
+
+ +
+ Breite +
+ {#each WIDTH_OPTIONS as opt} + + {/each} +
+
+
+ + + {#if columnsEditable} +
+ {#each activeView.columns as col, i (col.id)} +
+
+ {#each COLUMN_COLORS as c} + + {/each} +
+ updateColumn(i, { name: e.currentTarget.value })} + /> +
+ + + +
+
+ {/each} + +
+ {:else} +

Spalten werden automatisch aus der Gruppierung erzeugt.

+ {/if} + {/if} + + {#if activeView} {:else} @@ -36,6 +219,8 @@