AP1.5e: Projekt-Detail, Bearbeitung und Lifecycle in der Ausführung.
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 1m48s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 3s
Test Suite / compose-smoke (push) Has been skipped
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 1m48s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 3s
Test Suite / compose-smoke (push) Has been skipped
Detail-Route mit vollem Formular, Struktur-Navigator statt Inline-CRUD, Lifecycle sichtbar im Vorhaben-Header und auf Ausführung (0.15.1-ap1.5e).
This commit is contained in:
1 parent
94e815e88a
commit
33831a8c2c
13 files changed
+827
-173
No files matched your search
@@ -2,6 +2,7 @@ import { useInitiativeOperations } from '../../context/InitiativeOperationsConte
|
||||
import { InitiativeActionsHub } from '../../components/InitiativeActionsHub.jsx'
|
||||
import { ProjectsSection } from '../../components/ProjectsSection.jsx'
|
||||
import { BlockersSection } from '../../components/BlockersSection.jsx'
|
||||
import { InitiativeLifecycleBar } from '../../components/InitiativeLifecycleBar.jsx'
|
||||
|
||||
export function InitiativeExecutionPage() {
|
||||
const ops = useInitiativeOperations()
|
||||
@@ -23,19 +24,30 @@ export function InitiativeExecutionPage() {
|
||||
unlinkedBlockers,
|
||||
initiativeId,
|
||||
error,
|
||||
steeringSnapshot,
|
||||
steeringSnapshotLoading,
|
||||
steeringSnapshotError,
|
||||
} = ops
|
||||
|
||||
return (
|
||||
<>
|
||||
{error && <p className="error">{error}</p>}
|
||||
|
||||
<InitiativeLifecycleBar
|
||||
snapshot={steeringSnapshot}
|
||||
loading={steeringSnapshotLoading}
|
||||
error={steeringSnapshotError}
|
||||
initiativeId={initiativeId}
|
||||
compact
|
||||
/>
|
||||
|
||||
<ProjectsSection
|
||||
initiativeId={initiativeId}
|
||||
projects={projects}
|
||||
roadmapItems={roadmapItems}
|
||||
selectedProjectId={selectedProjectId}
|
||||
onSelectProject={setSelectedProjectId}
|
||||
canManage={capabilities.has('kairo.project.manage')}
|
||||
onCreate={ops.handleCreateProject}
|
||||
onDelete={ops.handleDeleteProject}
|
||||
busy={formBusy}
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
import { useMemo, useState } from 'react'
|
||||
import { Link, useNavigate, useParams } from 'react-router-dom'
|
||||
import { ProjectForm } from '../../components/ProjectForm.jsx'
|
||||
import { StatusBadge } from '../../components/StatusBadge.jsx'
|
||||
import { EmptyState } from '../../components/EmptyState.jsx'
|
||||
import { ErrorState } from '../../components/ErrorState.jsx'
|
||||
import { gateTitleById } from '../../components/GateSelect.jsx'
|
||||
import { useInitiativeOperations } from '../../context/InitiativeOperationsContext.jsx'
|
||||
import {
|
||||
buildProjectPath,
|
||||
buildProjectsByParent,
|
||||
collectProjectSubtreeIds,
|
||||
containerKindLabel,
|
||||
} from '../../utils/projectTree.js'
|
||||
|
||||
function formatDate(iso) {
|
||||
if (!iso) return '—'
|
||||
try {
|
||||
return new Date(iso).toLocaleDateString('de-DE')
|
||||
} catch {
|
||||
return iso
|
||||
}
|
||||
}
|
||||
|
||||
function ProjectDetailView({
|
||||
project,
|
||||
projects,
|
||||
roadmapItems,
|
||||
initiativeId,
|
||||
childProjects,
|
||||
linkedActions,
|
||||
canManage,
|
||||
onEdit,
|
||||
onDelete,
|
||||
onFilter,
|
||||
busy,
|
||||
}) {
|
||||
const path = buildProjectPath(projects, project.id)
|
||||
const gateTitle = gateTitleById(roadmapItems, project.roadmap_item_id)
|
||||
|
||||
return (
|
||||
<div className="project-detail-view">
|
||||
<dl className="detail-grid">
|
||||
<div>
|
||||
<dt>Status</dt>
|
||||
<dd>
|
||||
<StatusBadge kind="project" status={project.status} />
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Art</dt>
|
||||
<dd>{containerKindLabel(project.container_kind) || 'Standard'}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Ebene</dt>
|
||||
<dd>
|
||||
{project.depth ?? path.length} · {project.is_leaf ? 'Blatt (Arbeitspakete möglich)' : 'Container'}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Zieldatum</dt>
|
||||
<dd>{formatDate(project.target_date)}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Gate</dt>
|
||||
<dd>
|
||||
{gateTitle ? (
|
||||
<Link to={`/initiatives/${initiativeId}/plan/items/${project.roadmap_item_id}`}>
|
||||
{gateTitle}
|
||||
</Link>
|
||||
) : (
|
||||
'—'
|
||||
)}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Sortierung</dt>
|
||||
<dd>{project.sort_order ?? 0}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
{project.description && (
|
||||
<section className="project-detail-section">
|
||||
<h3>Beschreibung</h3>
|
||||
<p className="detail-text">{project.description}</p>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{path.length > 1 && (
|
||||
<section className="project-detail-section">
|
||||
<h3>Pfad</h3>
|
||||
<nav className="project-path-breadcrumb" aria-label="Projektpfad">
|
||||
{path.map((node, index) => (
|
||||
<span key={node.id}>
|
||||
{index > 0 && <span aria-hidden="true"> → </span>}
|
||||
{index === path.length - 1 ? (
|
||||
<strong>{node.title}</strong>
|
||||
) : (
|
||||
<Link to={`/initiatives/${initiativeId}/execution/projects/${node.id}`}>
|
||||
{node.title}
|
||||
</Link>
|
||||
)}
|
||||
</span>
|
||||
))}
|
||||
</nav>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{childProjects.length > 0 && (
|
||||
<section className="project-detail-section">
|
||||
<h3>Unterprojekte ({childProjects.length})</h3>
|
||||
<ul className="item-list">
|
||||
{childProjects.map((child) => (
|
||||
<li key={child.id} className="list-item card-list-item">
|
||||
<Link to={`/initiatives/${initiativeId}/execution/projects/${child.id}`}>
|
||||
<strong>{child.title}</strong>
|
||||
</Link>
|
||||
<StatusBadge kind="project" status={child.status} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="project-detail-section">
|
||||
<h3>Arbeitspakete ({linkedActions.length})</h3>
|
||||
{linkedActions.length === 0 ? (
|
||||
<EmptyState
|
||||
message={
|
||||
project.is_leaf
|
||||
? 'Noch keine Arbeitspakete an diesem Projekt.'
|
||||
: 'Arbeitspakete nur an Blatt-Projekten — wähle ein Unterprojekt.'
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<ul className="item-list">
|
||||
{linkedActions.map((action) => (
|
||||
<li key={action.id} className="list-item card-list-item">
|
||||
<Link to={`/initiatives/${initiativeId}/actions/${action.id}`}>
|
||||
<strong>{action.title}</strong>
|
||||
</Link>
|
||||
<StatusBadge kind="action" status={action.status} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<div className="project-detail-actions">
|
||||
{canManage && (
|
||||
<button type="button" className="btn btn-primary" onClick={onEdit} disabled={busy}>
|
||||
Bearbeiten
|
||||
</button>
|
||||
)}
|
||||
<button type="button" className="btn btn-secondary" onClick={onFilter} disabled={busy}>
|
||||
In Ausführung filtern
|
||||
</button>
|
||||
{canManage && (
|
||||
<Link
|
||||
className="btn btn-secondary"
|
||||
to={`/initiatives/${initiativeId}/execution/projects/new?parent=${project.id}`}
|
||||
>
|
||||
Unterprojekt
|
||||
</Link>
|
||||
)}
|
||||
{canManage && (
|
||||
<button type="button" className="btn btn-secondary" onClick={onDelete} disabled={busy}>
|
||||
Löschen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function ProjectDetailPage() {
|
||||
const { projectId } = useParams()
|
||||
const navigate = useNavigate()
|
||||
const ops = useInitiativeOperations()
|
||||
const isNew = projectId === 'new'
|
||||
const [editing, setEditing] = useState(isNew)
|
||||
const [localError, setLocalError] = useState(null)
|
||||
|
||||
const project = useMemo(
|
||||
() => (isNew ? null : ops.projects.find((p) => p.id === projectId)),
|
||||
[isNew, ops.projects, projectId],
|
||||
)
|
||||
|
||||
const childProjects = useMemo(() => {
|
||||
if (!project) return []
|
||||
const byParent = buildProjectsByParent(ops.projects)
|
||||
return byParent.get(project.id) || []
|
||||
}, [project, ops.projects])
|
||||
|
||||
const linkedActions = useMemo(() => {
|
||||
if (!project) return []
|
||||
const ids = collectProjectSubtreeIds(ops.projects, project.id)
|
||||
return ops.actions.filter((a) => a.project_id && ids.has(a.project_id))
|
||||
}, [project, ops.projects, ops.actions])
|
||||
|
||||
const canManage = ops.capabilities.has('kairo.project.manage')
|
||||
const parentPreset =
|
||||
typeof window !== 'undefined'
|
||||
? new URLSearchParams(window.location.search).get('parent') || ''
|
||||
: ''
|
||||
|
||||
if (!isNew && !project && !ops.loading) {
|
||||
return <ErrorState message="Projekt nicht gefunden." onRetry={ops.reload} />
|
||||
}
|
||||
|
||||
async function handleCreate(payload) {
|
||||
setLocalError(null)
|
||||
const created = await ops.handleCreateProject(payload)
|
||||
if (created?.id) {
|
||||
navigate(`/initiatives/${ops.initiativeId}/execution/projects/${created.id}`, { replace: true })
|
||||
} else if (ops.error) {
|
||||
setLocalError(ops.error)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUpdate(payload) {
|
||||
setLocalError(null)
|
||||
const ok = await ops.handleUpdateProject(project.id, payload)
|
||||
if (ok) {
|
||||
setEditing(false)
|
||||
} else if (ops.error) {
|
||||
setLocalError(ops.error)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleDelete() {
|
||||
if (!project || !window.confirm(`Projekt „${project.title}“ wirklich löschen?`)) return
|
||||
setLocalError(null)
|
||||
const ok = await ops.handleDeleteProject(project.id)
|
||||
if (ok) {
|
||||
navigate(`/initiatives/${ops.initiativeId}/execution`)
|
||||
} else if (ops.error) {
|
||||
setLocalError(ops.error)
|
||||
}
|
||||
}
|
||||
|
||||
function handleFilter() {
|
||||
if (project) ops.setSelectedProjectId(project.id)
|
||||
navigate(`/initiatives/${ops.initiativeId}/execution`)
|
||||
}
|
||||
|
||||
const title = isNew ? 'Neues Projekt' : project?.title || 'Projekt'
|
||||
|
||||
return (
|
||||
<section className="card project-detail-page">
|
||||
<nav className="breadcrumb breadcrumb--inline">
|
||||
<Link to={`/initiatives/${ops.initiativeId}/execution`}>Ausführung</Link>
|
||||
<span aria-hidden="true"> / </span>
|
||||
<span>{title}</span>
|
||||
</nav>
|
||||
|
||||
<header className="section-header">
|
||||
<div>
|
||||
<h2>{title}</h2>
|
||||
{!isNew && project && (
|
||||
<div className="detail-badges">
|
||||
<StatusBadge kind="project" status={project.status} />
|
||||
{project.container_kind && (
|
||||
<span className="project-kind-badge">{containerKindLabel(project.container_kind)}</span>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{isNew && (
|
||||
<p className="section-lead muted">
|
||||
Struktur-Container unter dem Vorhaben — Bearbeitung und Status hier pflegen, nicht in der Liste.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{!isNew && canManage && !editing && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={() => setEditing(true)}
|
||||
disabled={ops.formBusy}
|
||||
>
|
||||
Bearbeiten
|
||||
</button>
|
||||
)}
|
||||
</header>
|
||||
|
||||
{(localError || ops.error) && <p className="error">{localError || ops.error}</p>}
|
||||
|
||||
{editing ? (
|
||||
<ProjectForm
|
||||
initial={
|
||||
isNew
|
||||
? { parent_project_id: parentPreset, status: 'active' }
|
||||
: project
|
||||
}
|
||||
projects={ops.projects}
|
||||
roadmapItems={ops.roadmapItems}
|
||||
excludeProjectId={project?.id || ''}
|
||||
onSubmit={isNew ? handleCreate : handleUpdate}
|
||||
onCancel={
|
||||
isNew
|
||||
? () => navigate(`/initiatives/${ops.initiativeId}/execution`)
|
||||
: () => setEditing(false)
|
||||
}
|
||||
busy={ops.formBusy}
|
||||
submitLabel={isNew ? 'Anlegen' : 'Speichern'}
|
||||
/>
|
||||
) : (
|
||||
project && (
|
||||
<ProjectDetailView
|
||||
project={project}
|
||||
projects={ops.projects}
|
||||
roadmapItems={ops.roadmapItems}
|
||||
initiativeId={ops.initiativeId}
|
||||
childProjects={childProjects}
|
||||
linkedActions={linkedActions}
|
||||
canManage={canManage}
|
||||
onEdit={() => setEditing(true)}
|
||||
onDelete={handleDelete}
|
||||
onFilter={handleFilter}
|
||||
busy={ops.formBusy}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user