feat(A1): Activity Set am Gate-Detail — Übungen an Zielzustand binden
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 4m54s
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 19s
Test Suite / playwright-smoke (push) Successful in 13s
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 4m54s
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 19s
Test Suite / playwright-smoke (push) Successful in 13s
Gate-Detail: Übungen anlegen mit Rhythmus, Gate aktivieren, Link zu Today. API: /roadmap-items/{id}/practices und roadmap_item_id auf Recurring-Create. Damit ist A1 ohne Starter-Kit manuell durchspielbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
17add13d9d
commit
87ecee5301
11 files changed
+473
-5
No files matched your search
@@ -70,6 +70,17 @@ export function listRoadmapItemCriteria(itemId) {
|
||||
return apiFetch(`/api/roadmap-items/${itemId}/criteria`)
|
||||
}
|
||||
|
||||
export function listGatePractices(gateId) {
|
||||
return apiFetch(`/api/roadmap-items/${gateId}/practices`)
|
||||
}
|
||||
|
||||
export function createGatePractice(gateId, body) {
|
||||
return apiFetch(`/api/roadmap-items/${gateId}/practices`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
}
|
||||
|
||||
export function createRoadmapItemCriterion(itemId, body) {
|
||||
return apiFetch(`/api/roadmap-items/${itemId}/criteria`, {
|
||||
method: 'POST',
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import {
|
||||
createGatePractice,
|
||||
listGatePractices,
|
||||
} from '../api/roadmap.js'
|
||||
import { deleteRecurring, updateRecurring } from '../api/recurring.js'
|
||||
import { RECURRING_STATUSES, RECURRING_STATUS_LABELS } from '../constants/status.js'
|
||||
import { EmptyState } from './EmptyState.jsx'
|
||||
import { StatusBadge } from './StatusBadge.jsx'
|
||||
import { scopedPath } from '../utils/routes.js'
|
||||
|
||||
function formatDueAt(iso) {
|
||||
if (!iso) return null
|
||||
try {
|
||||
return new Date(iso).toLocaleString('de-DE', { dateStyle: 'medium', timeStyle: 'short' })
|
||||
} catch {
|
||||
return iso
|
||||
}
|
||||
}
|
||||
|
||||
export function GateActivitySetSection({
|
||||
gateId,
|
||||
initiativeId,
|
||||
gateStatus,
|
||||
canManage = false,
|
||||
}) {
|
||||
const [practices, setPractices] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
const [title, setTitle] = useState('')
|
||||
const [description, setDescription] = useState('')
|
||||
const [intervalDays, setIntervalDays] = useState('1')
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const items = await listGatePractices(gateId)
|
||||
setPractices(Array.isArray(items) ? items : [])
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [gateId])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
async function runAction(fn) {
|
||||
setBusy(true)
|
||||
setError(null)
|
||||
try {
|
||||
await fn()
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleCreate(e) {
|
||||
e.preventDefault()
|
||||
if (!title.trim()) return
|
||||
const interval = Number.parseInt(intervalDays, 10)
|
||||
if (!Number.isFinite(interval) || interval < 1) {
|
||||
setError('Intervall muss mindestens 1 Tag sein.')
|
||||
return
|
||||
}
|
||||
await runAction(async () => {
|
||||
await createGatePractice(gateId, {
|
||||
title: title.trim(),
|
||||
description: description.trim(),
|
||||
interval_days: interval,
|
||||
status: 'active',
|
||||
})
|
||||
setTitle('')
|
||||
setDescription('')
|
||||
setIntervalDays('1')
|
||||
setShowForm(false)
|
||||
})
|
||||
}
|
||||
|
||||
const isActiveGate = gateStatus === 'active' || gateStatus === 'at_risk'
|
||||
|
||||
return (
|
||||
<section className="card gate-activity-set">
|
||||
<div className="section-header">
|
||||
<div>
|
||||
<h3>Übungen (Activity Set)</h3>
|
||||
<p className="section-lead muted">
|
||||
Wiederkehrende Routinen an diesem Zielzustand — erscheinen in Today, wenn das Gate{' '}
|
||||
<strong>aktiv</strong> ist.
|
||||
</p>
|
||||
</div>
|
||||
{canManage && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-sm"
|
||||
onClick={() => setShowForm((value) => !value)}
|
||||
disabled={busy}
|
||||
>
|
||||
{showForm ? 'Abbrechen' : 'Übung anlegen'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{error && <p className="error">{error}</p>}
|
||||
|
||||
{!isActiveGate && (
|
||||
<p className="muted gate-activity-set__hint">
|
||||
Gate-Status ist <strong>{gateStatus}</strong> — Übungen werden in Today sichtbar, sobald
|
||||
das Gate auf <strong>aktiv</strong> steht (Stammdaten bearbeiten).
|
||||
</p>
|
||||
)}
|
||||
|
||||
{isActiveGate && practices.some((item) => item.status === 'active') && initiativeId && (
|
||||
<p className="muted gate-activity-set__hint">
|
||||
<Link to={scopedPath('/work/today', { initiativeId })} className="link-inline">
|
||||
Ausführen → Today
|
||||
</Link>{' '}
|
||||
— fällige Übungen dieses Gates abhaken.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{showForm && canManage && (
|
||||
<form className="inline-form-block gate-activity-set__form" onSubmit={handleCreate}>
|
||||
<label>
|
||||
Titel
|
||||
<input
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
maxLength={255}
|
||||
required
|
||||
placeholder="z. B. Vorbeuge halten"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Beschreibung (optional)
|
||||
<textarea
|
||||
value={description}
|
||||
onChange={(e) => setDescription(e.target.value)}
|
||||
rows={2}
|
||||
placeholder="Hinweise zur Ausführung"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
Rhythmus (Tage)
|
||||
<input
|
||||
type="number"
|
||||
min={1}
|
||||
value={intervalDays}
|
||||
onChange={(e) => setIntervalDays(e.target.value)}
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
<button type="submit" className="btn btn-primary" disabled={busy}>
|
||||
Übung speichern
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
{loading ? (
|
||||
<p className="muted">Übungen werden geladen…</p>
|
||||
) : practices.length === 0 ? (
|
||||
<EmptyState message="Noch keine Übungen an diesem Gate — mindestens eine für aktive Gates anlegen." />
|
||||
) : (
|
||||
<ul className="item-list gate-activity-set__list">
|
||||
{practices.map((practice) => (
|
||||
<li key={practice.id} className="list-item card-list-item">
|
||||
<div className="list-item-main">
|
||||
<strong>{practice.title}</strong>
|
||||
{practice.description && (
|
||||
<p className="muted list-item-sub">{practice.description}</p>
|
||||
)}
|
||||
<p className="muted list-item-sub">
|
||||
{practice.interval_days
|
||||
? `Alle ${practice.interval_days} Tag(e)`
|
||||
: 'Kein Intervall'}
|
||||
{practice.open_cadence_instance?.due_at
|
||||
? ` · Fällig: ${formatDueAt(practice.open_cadence_instance.due_at)}`
|
||||
: ''}
|
||||
{practice.today_completed ? ' · heute erledigt' : ''}
|
||||
</p>
|
||||
</div>
|
||||
{canManage && (
|
||||
<div className="list-item-meta action-controls">
|
||||
<StatusBadge kind="recurring" status={practice.status} />
|
||||
<select
|
||||
className="inline-select"
|
||||
value={practice.status}
|
||||
disabled={busy}
|
||||
onChange={(e) =>
|
||||
runAction(() =>
|
||||
updateRecurring(practice.id, { status: e.target.value }),
|
||||
)
|
||||
}
|
||||
aria-label="Übungs-Status"
|
||||
>
|
||||
{RECURRING_STATUSES.map((status) => (
|
||||
<option key={status} value={status}>
|
||||
{RECURRING_STATUS_LABELS[status]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary btn-sm"
|
||||
disabled={busy}
|
||||
onClick={() => {
|
||||
const next = window.prompt(
|
||||
'Neues Intervall in Tagen:',
|
||||
String(practice.interval_days || 1),
|
||||
)
|
||||
if (next == null) return
|
||||
const days = Number.parseInt(next, 10)
|
||||
if (!Number.isFinite(days) || days < 1) {
|
||||
setError('Intervall muss mindestens 1 Tag sein.')
|
||||
return
|
||||
}
|
||||
runAction(() => updateRecurring(practice.id, { interval_days: days }))
|
||||
}}
|
||||
>
|
||||
Rhythmus
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary btn-sm"
|
||||
disabled={busy}
|
||||
onClick={() => {
|
||||
if (!window.confirm(`„${practice.title}" löschen?`)) return
|
||||
runAction(() => deleteRecurring(practice.id))
|
||||
}}
|
||||
>
|
||||
Löschen
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -78,10 +78,14 @@ export function RecurringRhythmPanel({
|
||||
</ul>
|
||||
<p className="muted recurring-rhythm-hint">
|
||||
{canManage
|
||||
? 'Übungen anlegen, pausieren oder löschen unter '
|
||||
: 'Rhythmen pflegen unter '}
|
||||
<Link to={scopedPath('/control/journey', { initiativeId })} className="link-inline">
|
||||
Kontrolle → Journey → Wiederkehrend
|
||||
? 'Übungen anlegen und Rhythmus pflegen am '
|
||||
: 'Übungen am '}
|
||||
<Link to={scopedPath('/plan/gates', { initiativeId })} className="link-inline">
|
||||
Zielzustand (Gate-Detail)
|
||||
</Link>
|
||||
{' '}— Activity Set pro Gate. Heute erledigen unter{' '}
|
||||
<Link to={scopedPath('/work/today', { initiativeId })} className="link-inline">
|
||||
Ausführen → Today
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
|
||||
@@ -44,6 +44,12 @@ export function RecurringSection({ items, canManage, onCreate, onUpdateStatus, o
|
||||
)}
|
||||
</div>
|
||||
|
||||
<p className="muted form-hint">
|
||||
Für Reifegrad-Vorhaben (A1): Übungen am{' '}
|
||||
<strong>Zielzustand (Gate-Detail)</strong> anlegen — dort Activity Set mit Rhythmus.
|
||||
Diese Liste ist für initiative-weite Elemente ohne Gate-Bezug.
|
||||
</p>
|
||||
|
||||
{showForm && canManage && (
|
||||
<form className="inline-form-block" onSubmit={handleSubmit}>
|
||||
<label>
|
||||
|
||||
@@ -25,6 +25,7 @@ import { useCapabilities } from '../../hooks/useCapabilities.js'
|
||||
import { useInitiativeOperations } from '../../context/InitiativeOperationsContext.jsx'
|
||||
import { scopedPath } from '../../utils/routes.js'
|
||||
import { listGateContributions } from '../../api/journey.js'
|
||||
import { GateActivitySetSection } from '../../components/GateActivitySetSection.jsx'
|
||||
import { GateContributionsSection } from '../../components/GateContributionsSection.jsx'
|
||||
import { GateDependenciesSection } from '../../components/GateDependenciesSection.jsx'
|
||||
import { GateCriteriaSection } from '../../components/GateCriteriaSection.jsx'
|
||||
@@ -172,6 +173,20 @@ export function RoadmapItemDetailPage({ overrideItemId }) {
|
||||
</div>
|
||||
<div className="section-header__actions">
|
||||
<StatusBadge kind="milestone" status={item.status} />
|
||||
{canManage && item.status === 'planned' && !joinGate && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-primary btn-sm"
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
runAction(async () => {
|
||||
await updateRoadmapItem(itemId, { status: 'active' })
|
||||
})
|
||||
}
|
||||
>
|
||||
Gate aktivieren
|
||||
</button>
|
||||
)}
|
||||
{canManage && item.status !== 'reached' && (
|
||||
<button
|
||||
type="button"
|
||||
@@ -221,6 +236,15 @@ export function RoadmapItemDetailPage({ overrideItemId }) {
|
||||
onDelete={(dependencyId) => runAction(() => deleteRoadmapDependency(dependencyId))}
|
||||
/>
|
||||
|
||||
{!joinGate && (
|
||||
<GateActivitySetSection
|
||||
gateId={itemId}
|
||||
initiativeId={initiativeId || item.initiative_id}
|
||||
gateStatus={item.status}
|
||||
canManage={capabilities.has('kairo.recurring.manage')}
|
||||
/>
|
||||
)}
|
||||
|
||||
{joinGate ? (
|
||||
<section className="card join-gate-detail">
|
||||
<h3>Join / Schaltknoten</h3>
|
||||
|
||||
Reference in new issue
Block a user