diff --git a/src/admin/components/PlanCellModal.tsx b/src/admin/components/PlanCellModal.tsx index b29661f..23ebcb9 100644 --- a/src/admin/components/PlanCellModal.tsx +++ b/src/admin/components/PlanCellModal.tsx @@ -8,6 +8,7 @@ import { ResolvedCell } from "../lib/queries/plan"; interface Project { id: number; name: string; + project_number?: string; } export type PlanCellModalMode = @@ -64,6 +65,7 @@ interface Props { userId: number, date: string, ) => Promise; + onSwitchToEditRange: (entryId: number, userId: number, date: string) => void; } const CATEGORIES = [ @@ -218,13 +220,7 @@ function EditForm(props: Props) { loading={submitting} > {mode.kind !== "create" && ( -
+
+
); } function ViewModal(props: Props) { - const { mode, onClose } = props; + const { mode, onClose, projects } = props; if (mode.kind !== "view") return null; const c = mode.cell; + const project = c.project_id + ? (projects.find((p) => p.id === c.project_id) ?? null) + : null; return (

@@ -386,10 +390,15 @@ function ViewModal(props: Props) { Kategorie: {c.category}

- Projekt: {c.project_id ?? "—"} + Projekt:{" "} + {project + ? project.project_number + ? `${project.project_number} — ${project.name}` + : project.name + : "—"}

- Text: {c.note} + Text: {c.note || "—"}

{c.rangeFrom && c.rangeTo && (

diff --git a/src/admin/pages/PlanWork.tsx b/src/admin/pages/PlanWork.tsx index 456af20..8d881d0 100644 --- a/src/admin/pages/PlanWork.tsx +++ b/src/admin/pages/PlanWork.tsx @@ -203,6 +203,23 @@ export default function PlanWork() { setModalCell(null); }, [setHookModal]); + // Switch the modal from "day-in-range" to "edit-range" mode, keeping the + // same cell context so the EditForm opens with the range's values. + const switchToEditRange = useCallback( + (entryId: number, userId: number, date: string) => { + const cell = getCell(grid, userId, date); + if (!cell) return; + setModalCell(cell); + setHookModal({ + kind: "edit-range", + entryId, + userId, + date, + }); + }, + [grid, setHookModal], + ); + // --- Mutation wrappers ----------------------------------------------------- // The modal calls these with plain objects / ids. We resolve them to the // hook's mutateAsync calls and surface server errors as alerts. @@ -468,6 +485,7 @@ export default function PlanWork() { onUpdateOverride={updateOverrideFn} onDeleteOverride={deleteOverrideFn} onCreateOverrideFromRange={createOverrideFromRange} + onSwitchToEditRange={switchToEditRange} />

); diff --git a/src/admin/plan.css b/src/admin/plan.css index 1db18a7..c7e9450 100644 --- a/src/admin/plan.css +++ b/src/admin/plan.css @@ -167,3 +167,14 @@ background: transparent; padding: 0; } + +/* Action row inside a modal body (e.g. Delete button at top, or button + group in the day-in-range chooser). Mirrors .admin-modal-footer + styling but lives inside .admin-modal-body. */ +.plan-modal-actions { + display: flex; + gap: 8px; + justify-content: flex-end; + margin-top: 12px; + margin-bottom: 0; +}