fix(A1): Übungen an Stufen binden, Gates entkoppeln, Tages-Abschluss
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Failing after 4m46s
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 2s
Test Suite / compose-smoke (push) Has been skipped
Deploy Development / deploy (push) Successful in 49s
Test Suite / pytest-backend (push) Failing after 4m46s
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 2s
Test Suite / compose-smoke (push) Has been skipped
Activity Set pro Stufe statt Gate-Titel-Recurring; Single-Active-Stufe bei Reopen; Complete heute schliesst Next Action; Heute-Panel fuer alle Uebungen der aktiven Stufe. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b7d88ce24a
commit
19e962d8ec
17 files changed
+620
-209
No files matched your search
@@ -12,54 +12,74 @@ function formatDueAt(iso) {
|
||||
}
|
||||
}
|
||||
|
||||
function activeMaturityStage(roadmapItems = []) {
|
||||
return [...roadmapItems]
|
||||
.filter((item) => item.item_type === 'maturity_stage' && item.status === 'active')
|
||||
.sort((a, b) => (a.sort_order ?? 0) - (b.sort_order ?? 0))[0]
|
||||
}
|
||||
|
||||
function practicesForStage(recurringItems = [], stageId) {
|
||||
if (!stageId) {
|
||||
return (recurringItems || []).filter((item) => item.roadmap_item_id)
|
||||
}
|
||||
return (recurringItems || []).filter((item) => item.roadmap_item_id === stageId)
|
||||
}
|
||||
|
||||
export function RecurringRhythmPanel({
|
||||
initiativeId,
|
||||
roadmapItems = [],
|
||||
recurringItems = [],
|
||||
canManage = false,
|
||||
embedded = true,
|
||||
}) {
|
||||
const sorted = [...recurringItems].sort((a, b) => {
|
||||
const statusOrder = { active: 0, paused: 1, archived: 2 }
|
||||
const diff = (statusOrder[a.status] ?? 9) - (statusOrder[b.status] ?? 9)
|
||||
if (diff !== 0) return diff
|
||||
return (a.title || '').localeCompare(b.title || '', 'de')
|
||||
})
|
||||
|
||||
const active = sorted.filter((item) => item.status === 'active')
|
||||
const stage = activeMaturityStage(roadmapItems)
|
||||
const stagePractices = practicesForStage(recurringItems, stage?.id)
|
||||
const active = stagePractices.filter((item) => item.status === 'active')
|
||||
const paused = stagePractices.filter((item) => item.status === 'paused')
|
||||
|
||||
const body =
|
||||
sorted.length === 0 ? (
|
||||
<EmptyState message="Noch keine Rhythmen — Starter-Kit oder Journey legt Übungen an." />
|
||||
!stage ? (
|
||||
<EmptyState message="Keine aktive Reifegrad-Stufe — Plan → Stufen prüfen." />
|
||||
) : stagePractices.length === 0 ? (
|
||||
<EmptyState message="Keine Übungen für diese Stufe — Starter-Kit oder Stufenwechsel prüfen." />
|
||||
) : (
|
||||
<>
|
||||
{active.length > 0 && (
|
||||
<p className="recurring-rhythm-summary muted">
|
||||
{active.length} aktive Routine{active.length === 1 ? '' : 'n'} — fällige Übung steuert
|
||||
Next Action.
|
||||
</p>
|
||||
)}
|
||||
<p className="recurring-rhythm-summary muted">
|
||||
Stufe <strong>{stage.title}</strong> — {active.length} aktiv
|
||||
{paused.length > 0 ? `, ${paused.length} pausiert` : ''}.
|
||||
</p>
|
||||
<ul className="item-list recurring-rhythm-list">
|
||||
{sorted.map((item) => (
|
||||
{[...active, ...paused].map((item) => (
|
||||
<li
|
||||
key={item.id}
|
||||
className={
|
||||
'list-item card-list-item recurring-rhythm-item' +
|
||||
(item.status === 'active' ? ' recurring-rhythm-item--active' : '')
|
||||
(item.status === 'active' ? ' recurring-rhythm-item--active' : '') +
|
||||
(item.today_completed ? ' recurring-rhythm-item--done-today' : '')
|
||||
}
|
||||
>
|
||||
<div className="list-item-main">
|
||||
<strong>{item.title}</strong>
|
||||
<span className="muted list-item-sub">
|
||||
{RECURRING_STATUS_LABELS[item.status] || item.status}
|
||||
{item.next_due_at ? ` · Fällig: ${formatDueAt(item.next_due_at)}` : ''}
|
||||
{item.today_completed ? ' · heute erledigt' : ''}
|
||||
{!item.today_completed && item.next_due_at
|
||||
? ` · Fällig: ${formatDueAt(item.next_due_at)}`
|
||||
: ''}
|
||||
</span>
|
||||
{item.today_measurement_note && (
|
||||
<span className="muted list-item-sub">Messwert: {item.today_measurement_note}</span>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
<p className="muted recurring-rhythm-hint">
|
||||
Rhythmen pflegen unter{' '}
|
||||
{canManage
|
||||
? 'Übungen anlegen, pausieren oder löschen unter '
|
||||
: 'Rhythmen pflegen unter '}
|
||||
<Link to={scopedPath('/control/journey', { initiativeId })} className="link-inline">
|
||||
Kontrolle → Journey
|
||||
Kontrolle → Journey → Wiederkehrend
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
@@ -72,9 +92,9 @@ export function RecurringRhythmPanel({
|
||||
<section className="card recurring-rhythm-panel">
|
||||
<div className="section-header">
|
||||
<div>
|
||||
<h2>Rhythmen & Übungen</h2>
|
||||
<h2>Übungen der Stufe</h2>
|
||||
<p className="section-lead muted">
|
||||
Aktive Routinen am Reifegrad-Pfad — Leading Next aus fälliger Übung (A1).
|
||||
Activity Set der aktiven Reifegrad-Stufe — nicht die Gates selbst (A1).
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useMemo, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { completeRecurringPractice } from '../api/recurring.js'
|
||||
import { EmptyState } from './EmptyState.jsx'
|
||||
import { scopedPath } from '../utils/routes.js'
|
||||
|
||||
function formatDue(iso) {
|
||||
if (!iso) return null
|
||||
@@ -11,41 +13,34 @@ function formatDue(iso) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A1 — Heutige Übung (CadenceInstance): Tages-Tracking mit optionaler Messnotiz.
|
||||
*/
|
||||
export function WorkTodayPracticePanel({
|
||||
initiativeId,
|
||||
recurringItems = [],
|
||||
canManage = false,
|
||||
onCompleted,
|
||||
busy = false,
|
||||
}) {
|
||||
function activeMaturityStage(roadmapItems = []) {
|
||||
return [...roadmapItems]
|
||||
.filter((item) => item.item_type === 'maturity_stage' && item.status === 'active')
|
||||
.sort((a, b) => (a.sort_order ?? 0) - (b.sort_order ?? 0))[0]
|
||||
}
|
||||
|
||||
function exercisesForStage(recurringItems = [], stageId) {
|
||||
const active = (recurringItems || []).filter((item) => item.status === 'active')
|
||||
if (!stageId) return active
|
||||
const bound = active.filter((item) => item.roadmap_item_id === stageId)
|
||||
return bound.length > 0 ? bound : active
|
||||
}
|
||||
|
||||
function ExerciseRow({ exercise, canManage, busy, onCompleted }) {
|
||||
const [measurement, setMeasurement] = useState('')
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
const [error, setError] = useState(null)
|
||||
|
||||
const activePractice = useMemo(() => {
|
||||
return (recurringItems || []).find((item) => item.status === 'active')
|
||||
}, [recurringItems])
|
||||
|
||||
const openInstance = activePractice?.open_cadence_instance
|
||||
|
||||
if (!activePractice) {
|
||||
return (
|
||||
<section className="card work-today-practice" id="today-practice">
|
||||
<EmptyState message="Keine aktive Übung — Starter-Kit oder Stufenwechsel prüfen." />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
const completedToday = Boolean(exercise.today_completed)
|
||||
const savedNote = exercise.today_measurement_note
|
||||
|
||||
async function handleComplete(e) {
|
||||
e.preventDefault()
|
||||
if (!canManage || submitting) return
|
||||
if (!canManage || submitting || completedToday) return
|
||||
setSubmitting(true)
|
||||
setError(null)
|
||||
try {
|
||||
await completeRecurringPractice(activePractice.id, {
|
||||
await completeRecurringPractice(exercise.id, {
|
||||
measurement_note: measurement.trim() || undefined,
|
||||
})
|
||||
setMeasurement('')
|
||||
@@ -58,42 +53,115 @@ export function WorkTodayPracticePanel({
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="card work-today-practice" id="today-practice">
|
||||
<div className="section-header">
|
||||
<div>
|
||||
<h2>Heutige Übung</h2>
|
||||
<p className="section-lead muted">
|
||||
Tages-Tracking — erledigt markieren, optional Messwert notieren (z. B. Grad, Wiederholungen).
|
||||
<li className="list-item card-list-item work-today-practice__item">
|
||||
<div className="list-item-main">
|
||||
<strong>{exercise.title}</strong>
|
||||
{exercise.description && (
|
||||
<p className="muted list-item-sub">{exercise.description}</p>
|
||||
)}
|
||||
{completedToday ? (
|
||||
<p className="work-today-practice__done muted">
|
||||
Heute erledigt
|
||||
{savedNote ? ` — ${savedNote}` : ''}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="work-today-practice__focus">
|
||||
<strong>{activePractice.title}</strong>
|
||||
{openInstance?.due_at && (
|
||||
<p className="muted list-item-sub">Fällig: {formatDue(openInstance.due_at)}</p>
|
||||
) : (
|
||||
exercise.open_cadence_instance?.due_at && (
|
||||
<p className="muted list-item-sub">
|
||||
Fällig: {formatDue(exercise.open_cadence_instance.due_at)}
|
||||
</p>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
|
||||
{canManage ? (
|
||||
{canManage && !completedToday && (
|
||||
<form className="inline-form-block work-today-practice__form" onSubmit={handleComplete}>
|
||||
<label>
|
||||
Messwert / Notiz (optional)
|
||||
<input
|
||||
value={measurement}
|
||||
onChange={(e) => setMeasurement(e.target.value)}
|
||||
placeholder="z. B. 45° Spagat, 3×30 Sek."
|
||||
placeholder="z. B. 45°, 3×30 Sek."
|
||||
maxLength={2000}
|
||||
/>
|
||||
</label>
|
||||
{error && <p className="error">{error}</p>}
|
||||
<button type="submit" className="btn btn-primary" disabled={submitting || busy}>
|
||||
<button type="submit" className="btn btn-primary btn-sm" disabled={submitting || busy}>
|
||||
{submitting ? 'Speichern …' : 'Heute erledigt'}
|
||||
</button>
|
||||
</form>
|
||||
) : (
|
||||
<p className="muted">Keine Berechtigung zum Markieren der Übung.</p>
|
||||
)}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A1 — Heutige Übungen der aktiven Stufe (CadenceInstance je Übung).
|
||||
*/
|
||||
export function WorkTodayPracticePanel({
|
||||
initiativeId,
|
||||
roadmapItems = [],
|
||||
recurringItems = [],
|
||||
canManage = false,
|
||||
onCompleted,
|
||||
busy = false,
|
||||
}) {
|
||||
const stage = useMemo(() => activeMaturityStage(roadmapItems), [roadmapItems])
|
||||
|
||||
const todayExercises = useMemo(
|
||||
() => exercisesForStage(recurringItems, stage?.id),
|
||||
[recurringItems, stage?.id],
|
||||
)
|
||||
|
||||
const pending = todayExercises.filter((item) => !item.today_completed)
|
||||
const allDone = todayExercises.length > 0 && pending.length === 0
|
||||
|
||||
return (
|
||||
<section className="card work-today-practice" id="today-practice">
|
||||
<div className="section-header">
|
||||
<div>
|
||||
<h2>Heutige Übungen</h2>
|
||||
<p className="section-lead muted">
|
||||
{stage ? (
|
||||
<>
|
||||
Aktive Stufe: <strong>{stage.title}</strong> — pro Übung erledigen, optional Messwert
|
||||
notieren.
|
||||
</>
|
||||
) : (
|
||||
'Tages-Tracking für die aktive Reifegrad-Stufe.'
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{todayExercises.length === 0 ? (
|
||||
<EmptyState message="Keine Übungen für die aktive Stufe — Starter-Kit oder Stufenwechsel prüfen." />
|
||||
) : (
|
||||
<>
|
||||
{allDone && (
|
||||
<p className="work-today-practice__all-done muted">
|
||||
Alle Übungen für heute erledigt — nächste Fälligkeit morgen.
|
||||
</p>
|
||||
)}
|
||||
<ul className="item-list work-today-practice__list">
|
||||
{todayExercises.map((exercise) => (
|
||||
<ExerciseRow
|
||||
key={exercise.id}
|
||||
exercise={exercise}
|
||||
canManage={canManage}
|
||||
busy={busy}
|
||||
onCompleted={onCompleted}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
|
||||
<p className="muted work-today-practice__hint">
|
||||
Übungen verwalten unter{' '}
|
||||
<Link to={scopedPath('/control/journey', { initiativeId })} className="link-inline">
|
||||
Kontrolle → Journey
|
||||
</Link>
|
||||
.
|
||||
</p>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -199,11 +199,14 @@ export function buildProviderProps(provider, input) {
|
||||
case 'RecurringRhythmPanel':
|
||||
return {
|
||||
initiativeId: ops.initiativeId,
|
||||
roadmapItems: ops.roadmapItems || [],
|
||||
recurringItems: ops.recurringItems || [],
|
||||
canManage: capabilities.has('kairo.recurring.manage'),
|
||||
}
|
||||
case 'WorkTodayPracticePanel':
|
||||
return {
|
||||
initiativeId: ops.initiativeId,
|
||||
roadmapItems: ops.roadmapItems || [],
|
||||
recurringItems: ops.recurringItems || [],
|
||||
canManage: capabilities.has('kairo.recurring.manage'),
|
||||
busy: ops.formBusy,
|
||||
|
||||
@@ -287,7 +287,8 @@ describe('resolveSteeringComposition', () => {
|
||||
const props = buildProviderProps(provider, {
|
||||
opsContext: {
|
||||
initiativeId: 'init-1',
|
||||
recurringItems: [{ id: 'rec-1', status: 'active', title: 'Spagat' }],
|
||||
roadmapItems: [{ id: 'stage-1', item_type: 'maturity_stage', status: 'active', title: 'Stufe 1' }],
|
||||
recurringItems: [{ id: 'rec-1', status: 'active', title: 'Vorbeuge', roadmap_item_id: 'stage-1' }],
|
||||
formBusy: false,
|
||||
refreshOm,
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user