feat(combo-planning): enhance candidate interaction and UI for combination exercises
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / playwright-tests (push) Successful in 57s

- Introduced new CSS styles for interactive candidate buttons and links in the `CombinationPlanBracket` and `CombinationCoachSlots` components, improving user engagement.
- Updated `CombinationPlanBracket` to conditionally render candidates as buttons or links based on interaction type, enhancing navigation options.
- Refactored candidate handling in `CombinationCoachSlots` to support new interaction methods, streamlining candidate exercise display.
- Enhanced `ExercisePeekModal` and related components to support candidate peek functionality, allowing for a more seamless user experience.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 4.6 committed 2026-05-13 21:51:52 +02:00
1 parent 00edc7a93d
commit 502dddd3b3
10 files changed
+270 -109

No files matched your search

+88 -41
View File
@@ -1,7 +1,8 @@
/**
* Schnellansicht einer Übung aus dem Katalog (ohne die Planungsseite zu verlassen).
* Unterstützt Drill-down zu Kandidaten-Übungen bei Kombinationen inkl. „Zurück“ (PWA-sicher).
*/
import React, { useEffect, useMemo, useState } from 'react'
import React, { useEffect, useMemo, useRef, useState } from 'react'
import { Link } from 'react-router-dom'
import api from '../utils/api'
import ExerciseRichTextBlock from './ExerciseRichTextBlock'
@@ -25,6 +26,8 @@ function TagMini({ exercise }) {
)
}
/** @typedef {{ exerciseId: number, variantId?: number | null, peekExtras?: object | null }} PeekStackEntry */
export default function ExercisePeekModal({
open,
exerciseId,
@@ -37,36 +40,37 @@ export default function ExercisePeekModal({
const [loading, setLoading] = useState(false)
const [err, setErr] = useState(null)
const [exercise, setExercise] = useState(null)
/** @type {[PeekStackEntry[], React.Dispatch<React.SetStateAction<PeekStackEntry[]>>]} */
const [stack, setStack] = useState([])
const variant =
variantId != null && variantId !== '' && exercise?.variants?.length
? exercise.variants.find((v) => String(v.id) === String(variantId)) || null
: null
const isCombination =
exercise &&
String(exercise.exercise_kind || 'simple').toLowerCase().trim() === 'combination'
const comboMethodProfileEffective = useMemo(() => {
if (!exercise || !isCombination) return {}
const fromPeek =
peekExtras?.catalog_method_profile &&
typeof peekExtras.catalog_method_profile === 'object' &&
!Array.isArray(peekExtras.catalog_method_profile) &&
Object.keys(peekExtras.catalog_method_profile).length > 0
? peekExtras.catalog_method_profile
: exercise.method_profile || {}
return effectiveComboMethodProfile(fromPeek, peekExtras?.planning_method_profile ?? null)
}, [exercise, isCombination, peekExtras])
/** @type {React.MutableRefObject<boolean>} */
const wasOpenRef = useRef(false)
useEffect(() => {
if (!open) {
setExercise(null)
setErr(null)
setStack([])
wasOpenRef.current = false
return
}
if (!exerciseId) {
setErr('Keine Übung gewählt')
if (exerciseId == null || exerciseId === '') return
if (!wasOpenRef.current) {
wasOpenRef.current = true
setStack([
{
exerciseId: Number(exerciseId),
variantId: variantId ?? null,
peekExtras: peekExtras ?? null,
},
])
}
}, [open, exerciseId, variantId, peekExtras])
const top = stack.length ? stack[stack.length - 1] : null
useEffect(() => {
if (!open || !top?.exerciseId) {
setExercise(null)
setErr(null)
return
}
let cancelled = false
@@ -74,7 +78,7 @@ export default function ExercisePeekModal({
setLoading(true)
setErr(null)
try {
const data = await api.getExercise(exerciseId)
const data = await api.getExercise(top.exerciseId)
if (!cancelled) setExercise(data)
} catch (e) {
if (!cancelled) setErr(e.message || 'Laden fehlgeschlagen')
@@ -85,7 +89,40 @@ export default function ExercisePeekModal({
return () => {
cancelled = true
}
}, [open, exerciseId, variantId])
}, [open, top?.exerciseId])
const variant =
top?.variantId != null &&
top.variantId !== '' &&
exercise?.variants?.length
? exercise.variants.find((v) => String(v.id) === String(top.variantId)) || null
: null
const isCombination =
exercise && String(exercise.exercise_kind || 'simple').toLowerCase().trim() === 'combination'
const comboMethodProfileEffective = useMemo(() => {
if (!exercise || !isCombination) return {}
const fromPeek =
top?.peekExtras?.catalog_method_profile &&
typeof top.peekExtras.catalog_method_profile === 'object' &&
!Array.isArray(top.peekExtras.catalog_method_profile) &&
Object.keys(top.peekExtras.catalog_method_profile).length > 0
? top.peekExtras.catalog_method_profile
: exercise.method_profile || {}
return effectiveComboMethodProfile(fromPeek, top?.peekExtras?.planning_method_profile ?? null)
}, [exercise, isCombination, top?.peekExtras])
const planningAdjustedBadge =
top?.peekExtras?.planning_method_profile != null &&
typeof top.peekExtras.planning_method_profile === 'object' &&
!Array.isArray(top.peekExtras.planning_method_profile)
const pushCandidatePeek = (id) => {
const n = Number(id)
if (!Number.isFinite(n)) return
setStack((s) => [...s, { exerciseId: n, variantId: null, peekExtras: null }])
}
if (!open) return null
@@ -107,9 +144,19 @@ export default function ExercisePeekModal({
}}
onClick={(e) => e.stopPropagation()}
>
<div className="admin-modal-sheet__header">
<h3 id="exercise-peek-title" className="admin-modal-sheet__title">
{loading ? '…' : exercise?.title || titleFallback || `Übung #${exerciseId}`}
<div className="admin-modal-sheet__header" style={{ gap: '8px', flexWrap: 'wrap' }}>
{stack.length > 1 ? (
<button
type="button"
className="btn btn-secondary"
style={{ flexShrink: 0, fontWeight: 600 }}
onClick={() => setStack((s) => (s.length > 1 ? s.slice(0, -1) : s))}
>
← Zurück
</button>
) : null}
<h3 id="exercise-peek-title" className="admin-modal-sheet__title" style={{ flex: '1 1 200px', minWidth: 0 }}>
{loading ? '…' : exercise?.title || titleFallback || (top?.exerciseId != null ? `Übung #${top.exerciseId}` : 'Übung')}
</h3>
<button type="button" className="btn btn-secondary admin-modal-sheet__close" onClick={onClose}>
Schließen
@@ -130,14 +177,10 @@ export default function ExercisePeekModal({
<CombinationPlanBracket
methodArchetype={exercise.method_archetype || ''}
methodProfile={comboMethodProfileEffective}
combinationSlots={
Array.isArray(exercise.combination_slots) ? exercise.combination_slots : []
}
planningAdjusted={
peekExtras?.planning_method_profile != null &&
typeof peekExtras.planning_method_profile === 'object' &&
!Array.isArray(peekExtras.planning_method_profile)
}
combinationSlots={Array.isArray(exercise.combination_slots) ? exercise.combination_slots : []}
planningAdjusted={planningAdjustedBadge}
candidateInteraction="button"
onCandidatePeek={pushCandidatePeek}
/>
<hr style={{ border: 'none', borderTop: '1px solid var(--border)', margin: '1rem 0' }} />
</>
@@ -210,13 +253,17 @@ export default function ExercisePeekModal({
</>
)}
</div>
{exerciseId && (
{top?.exerciseId != null ? (
<div style={{ padding: '0 1rem 1rem', flexShrink: 0 }}>
<Link to={`/exercises/${exerciseId}`} className="btn btn-secondary" style={{ width: '100%', textDecoration: 'none', textAlign: 'center', display: 'block' }}>
<Link
to={`/exercises/${top.exerciseId}`}
className="btn btn-secondary"
style={{ width: '100%', textDecoration: 'none', textAlign: 'center', display: 'block' }}
>
Vollständige Übungsseite öffnen
</Link>
</div>
)}
) : null}
</div>
</div>
)