AP1.5c: Rekursive Projects fuer Mega-Programme ohne Stream-Typ.
Deploy Development / deploy (push) Successful in 53s
Test Suite / pytest-backend (push) Successful in 1m42s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 21s
Test Suite / playwright-smoke (push) Successful in 14s
Deploy Development / deploy (push) Successful in 53s
Test Suite / pytest-backend (push) Successful in 1m42s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 21s
Test Suite / playwright-smoke (push) Successful in 14s
parent_project_id und container_kind ermoeglichen verschachtelte Projektstruktur; Arbeitspakete bleiben an Blatt-Projekten gebunden. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
6eeddfdc76
commit
4ca0a2c460
15 files changed
+947
-91
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { ACTION_STATUSES, PRIORITIES } from '../constants/status.js'
|
||||
import { ACTION_STATUS_LABELS, PRIORITY_LABELS } from '../constants/status.js'
|
||||
import { ActorSelect } from './ActorSelect.jsx'
|
||||
import { flattenLeafProjectOptions, getLeafProjects } from '../utils/projectTree.js'
|
||||
|
||||
function isoToLocalInput(iso) {
|
||||
if (!iso) return ''
|
||||
@@ -38,6 +39,8 @@ export function ActionForm({
|
||||
}
|
||||
|
||||
const defaultActors = initial.assigned_actor_ids || []
|
||||
const leafProjects = getLeafProjects(projects)
|
||||
const projectOptions = flattenLeafProjectOptions(projects)
|
||||
|
||||
return (
|
||||
<form className="form workspace-form" onSubmit={handleSubmit}>
|
||||
@@ -77,14 +80,14 @@ export function ActionForm({
|
||||
defaultValue={isoToLocalInput(initial.due_at)}
|
||||
/>
|
||||
</label>
|
||||
{projects.length > 0 && (
|
||||
{leafProjects.length > 0 && (
|
||||
<label>
|
||||
Projekt (optional)
|
||||
Projekt (optional, Blatt-Ebene)
|
||||
<select name="project_id" defaultValue={initial.project_id || ''}>
|
||||
<option value="">— keins —</option>
|
||||
{projects.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.title}
|
||||
{projectOptions.map(({ project, label }) => (
|
||||
<option key={project.id} value={project.id}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
@@ -1,6 +1,80 @@
|
||||
import { useState } from 'react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { EmptyState } from './EmptyState.jsx'
|
||||
import { StatusBadge } from './StatusBadge.jsx'
|
||||
import {
|
||||
buildProjectsByParent,
|
||||
containerKindLabel,
|
||||
flattenProjectOptions,
|
||||
} from '../utils/projectTree.js'
|
||||
|
||||
function ProjectTreeNodes({
|
||||
projects,
|
||||
parentId,
|
||||
depth,
|
||||
selectedProjectId,
|
||||
onSelectProject,
|
||||
canManage,
|
||||
onDelete,
|
||||
busy,
|
||||
}) {
|
||||
const byParent = useMemo(() => buildProjectsByParent(projects), [projects])
|
||||
const nodes = byParent.get(parentId || '') || []
|
||||
|
||||
if (nodes.length === 0) return null
|
||||
|
||||
return (
|
||||
<ul className="project-tree-children">
|
||||
{nodes.map((project) => (
|
||||
<li key={project.id} className="project-tree-branch">
|
||||
<div className="list-item card-list-item project-tree-item">
|
||||
<div className="list-item-main">
|
||||
<button
|
||||
type="button"
|
||||
className="link-button"
|
||||
onClick={() =>
|
||||
onSelectProject(selectedProjectId === project.id ? '' : project.id)
|
||||
}
|
||||
>
|
||||
<strong>{project.title}</strong>
|
||||
</button>
|
||||
{project.container_kind && (
|
||||
<span className="project-kind-badge muted">
|
||||
{containerKindLabel(project.container_kind)}
|
||||
</span>
|
||||
)}
|
||||
{project.description && (
|
||||
<p className="list-item-desc muted">{project.description}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="list-item-meta action-controls">
|
||||
<StatusBadge kind="initiative" status={project.status} />
|
||||
{canManage && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={busy}
|
||||
onClick={() => onDelete(project.id)}
|
||||
>
|
||||
Löschen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<ProjectTreeNodes
|
||||
projects={projects}
|
||||
parentId={project.id}
|
||||
depth={depth + 1}
|
||||
selectedProjectId={selectedProjectId}
|
||||
onSelectProject={onSelectProject}
|
||||
canManage={canManage}
|
||||
onDelete={onDelete}
|
||||
busy={busy}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
|
||||
export function ProjectsSection({
|
||||
projects,
|
||||
@@ -13,37 +87,65 @@ export function ProjectsSection({
|
||||
}) {
|
||||
const [title, setTitle] = useState('')
|
||||
const [description, setDescription] = useState('')
|
||||
const [parentProjectId, setParentProjectId] = useState('')
|
||||
const [containerKind, setContainerKind] = useState('')
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
|
||||
const parentOptions = useMemo(
|
||||
() => flattenProjectOptions(projects),
|
||||
[projects]
|
||||
)
|
||||
|
||||
async function handleSubmit(e) {
|
||||
e.preventDefault()
|
||||
if (!title.trim()) return
|
||||
await onCreate({
|
||||
title: title.trim(),
|
||||
description: description.trim(),
|
||||
parent_project_id: parentProjectId || undefined,
|
||||
container_kind: containerKind || undefined,
|
||||
})
|
||||
setTitle('')
|
||||
setDescription('')
|
||||
setParentProjectId('')
|
||||
setContainerKind('')
|
||||
setShowForm(false)
|
||||
}
|
||||
|
||||
function openFormUnderSelected() {
|
||||
setParentProjectId(selectedProjectId || '')
|
||||
setShowForm(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="card projects-section">
|
||||
<div className="section-header">
|
||||
<div>
|
||||
<h2>Projekte</h2>
|
||||
<p className="section-lead muted">
|
||||
Operative Struktur — Arbeitspakete gruppieren. Zielzustände (Gates) sind optional.
|
||||
Operative Struktur — verschachtelbar für große Vorhaben. Arbeitspakete nur an
|
||||
Blatt-Projekten. Gates optional.
|
||||
</p>
|
||||
</div>
|
||||
{canManage && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-block-mobile"
|
||||
onClick={() => setShowForm((v) => !v)}
|
||||
>
|
||||
{showForm ? 'Abbrechen' : 'Projekt'}
|
||||
</button>
|
||||
<div className="section-header-actions">
|
||||
{selectedProjectId && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary btn-block-mobile"
|
||||
onClick={openFormUnderSelected}
|
||||
>
|
||||
Unterprojekt
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-block-mobile"
|
||||
onClick={() => setShowForm((v) => !v)}
|
||||
>
|
||||
{showForm ? 'Abbrechen' : 'Projekt'}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -67,6 +169,32 @@ export function ProjectsSection({
|
||||
rows={2}
|
||||
/>
|
||||
</label>
|
||||
{parentOptions.length > 0 && (
|
||||
<label>
|
||||
Unter (optional)
|
||||
<select
|
||||
value={parentProjectId}
|
||||
onChange={(e) => setParentProjectId(e.target.value)}
|
||||
>
|
||||
<option value="">— oberste Ebene —</option>
|
||||
{parentOptions.map(({ project, label }) => (
|
||||
<option key={project.id} value={project.id}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
)}
|
||||
<label>
|
||||
Art (optional)
|
||||
<select value={containerKind} onChange={(e) => setContainerKind(e.target.value)}>
|
||||
<option value="">— Standard —</option>
|
||||
<option value="project">Projekt</option>
|
||||
<option value="stream">Stream</option>
|
||||
<option value="phase">Phase</option>
|
||||
<option value="release">Release</option>
|
||||
</select>
|
||||
</label>
|
||||
<button type="submit" className="btn btn-primary" disabled={busy}>
|
||||
Anlegen
|
||||
</button>
|
||||
@@ -77,7 +205,7 @@ export function ProjectsSection({
|
||||
<EmptyState message="Noch keine Projekte — optional. Du kannst auch direkt Arbeitspakete anlegen." />
|
||||
)}
|
||||
|
||||
<ul className="item-list project-filter-list">
|
||||
<ul className="item-list project-filter-list project-tree-list">
|
||||
<li className="list-item card-list-item">
|
||||
<button
|
||||
type="button"
|
||||
@@ -87,38 +215,17 @@ export function ProjectsSection({
|
||||
Alle Arbeitspakete
|
||||
</button>
|
||||
</li>
|
||||
{projects.map((project) => (
|
||||
<li key={project.id} className="list-item card-list-item">
|
||||
<div className="list-item-main">
|
||||
<button
|
||||
type="button"
|
||||
className="link-button"
|
||||
onClick={() =>
|
||||
onSelectProject(selectedProjectId === project.id ? '' : project.id)
|
||||
}
|
||||
>
|
||||
<strong>{project.title}</strong>
|
||||
</button>
|
||||
{project.description && (
|
||||
<p className="list-item-desc muted">{project.description}</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="list-item-meta action-controls">
|
||||
<StatusBadge kind="initiative" status={project.status} />
|
||||
{canManage && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
disabled={busy}
|
||||
onClick={() => onDelete(project.id)}
|
||||
>
|
||||
Löschen
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<ProjectTreeNodes
|
||||
projects={projects}
|
||||
parentId=""
|
||||
depth={1}
|
||||
selectedProjectId={selectedProjectId}
|
||||
onSelectProject={onSelectProject}
|
||||
canManage={canManage}
|
||||
onDelete={onDelete}
|
||||
busy={busy}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user