feat(exercises): introduce combination exercises and enhance exercise management
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 1m1s
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 1m1s
- Updated app version to 0.8.99, reflecting the addition of combination exercises. - Implemented new data structures and validation for combination slots and archetypes in the backend. - Enhanced frontend components to support selection and display of combination exercises, including new UI elements for managing slots and archetypes. - Updated API payload handling to accommodate new exercise types and their associated data. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
f4f5642c21
commit
8a9f9f960f
8 files changed
+716
-12
No files matched your search
@@ -30,6 +30,29 @@ const VARIANT_DIFFICULTY = [
|
||||
{ value: 'adapted', label: 'Angepasst' },
|
||||
]
|
||||
|
||||
/** An API `method_archetype` (Backend `COMBINATION_ARCHETYPE_IDS`) */
|
||||
const COMBINATION_ARCHETYPE_OPTIONS = [
|
||||
{ id: 'sequence_linear', label: 'Lineare Sequenz' },
|
||||
{ id: 'circuit_rotate_time', label: 'Rotierender Zirkel (Zeit)' },
|
||||
{ id: 'circuit_all_parallel', label: 'Parallele Stationen' },
|
||||
{ id: 'station_parcour', label: 'Parcours' },
|
||||
{ id: 'pair_superset', label: 'Partner- / Paarwechsel' },
|
||||
{ id: 'time_domain_interval', label: 'Intervallblock (Zeitdomäne)' },
|
||||
{ id: 'free_method_block', label: 'Freier Methodenblock' },
|
||||
]
|
||||
|
||||
function comboSlotsFromDetail(exercise) {
|
||||
const raw = exercise?.combination_slots
|
||||
if (!Array.isArray(raw) || raw.length === 0) {
|
||||
return [{ slot_index: 0, title: '', idsText: '' }]
|
||||
}
|
||||
return raw.map((s, i) => ({
|
||||
slot_index: s.slot_index != null ? Number(s.slot_index) : i,
|
||||
title: s.title != null ? String(s.title) : '',
|
||||
idsText: Array.isArray(s.candidate_exercise_ids) ? s.candidate_exercise_ids.join(', ') : '',
|
||||
}))
|
||||
}
|
||||
|
||||
function emptyVariantDraft() {
|
||||
return {
|
||||
variant_name: '',
|
||||
@@ -249,6 +272,10 @@ function emptyForm() {
|
||||
visibility: 'private',
|
||||
status: 'draft',
|
||||
skills: [],
|
||||
exercise_kind: 'simple',
|
||||
method_archetype: '',
|
||||
method_profile_json: '{}',
|
||||
combination_slots: [{ slot_index: 0, title: '', idsText: '' }],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,6 +318,18 @@ function detailToForm(exercise) {
|
||||
required_level: normalizeSkillLevelSlug(s.required_level),
|
||||
target_level: normalizeSkillLevelSlug(s.target_level),
|
||||
})) || [],
|
||||
exercise_kind:
|
||||
String(exercise.exercise_kind || 'simple').toLowerCase() === 'combination'
|
||||
? 'combination'
|
||||
: 'simple',
|
||||
method_archetype: exercise.method_archetype != null ? String(exercise.method_archetype) : '',
|
||||
method_profile_json:
|
||||
typeof exercise.method_profile === 'object' &&
|
||||
exercise.method_profile != null &&
|
||||
!Array.isArray(exercise.method_profile)
|
||||
? JSON.stringify(exercise.method_profile, null, 2)
|
||||
: '{}',
|
||||
combination_slots: comboSlotsFromDetail(exercise),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,6 +988,180 @@ function ExerciseFormPage() {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div
|
||||
style={{
|
||||
padding: '12px',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid var(--border)',
|
||||
background: 'var(--surface2)',
|
||||
marginBottom: '12px',
|
||||
}}
|
||||
>
|
||||
<h3 style={{ marginTop: 0, marginBottom: '10px', fontSize: '1rem' }}>Übungstyp</h3>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Art</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={formData.exercise_kind === 'combination' ? 'combination' : 'simple'}
|
||||
onChange={(e) => {
|
||||
const nk = e.target.value
|
||||
setFormDirty(true)
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
exercise_kind: nk,
|
||||
...(nk === 'simple'
|
||||
? {
|
||||
method_archetype: '',
|
||||
method_profile_json: '{}',
|
||||
combination_slots: [{ slot_index: 0, title: '', idsText: '' }],
|
||||
}
|
||||
: {}),
|
||||
}))
|
||||
}}
|
||||
>
|
||||
<option value="simple">Einzelübung</option>
|
||||
<option value="combination">Kombinationsübung (Stationen / Pool)</option>
|
||||
</select>
|
||||
</div>
|
||||
{formData.exercise_kind === 'combination' ? (
|
||||
<>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Methoden-Archetyp (optional)</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={formData.method_archetype || ''}
|
||||
onChange={(e) => updateFormField('method_archetype', e.target.value)}
|
||||
>
|
||||
<option value="">— später wählen —</option>
|
||||
{COMBINATION_ARCHETYPE_OPTIONS.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Ablaufprofil (JSON, optional)</label>
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={4}
|
||||
value={formData.method_profile_json || '{}'}
|
||||
onChange={(e) => updateFormField('method_profile_json', e.target.value)}
|
||||
spellCheck={false}
|
||||
placeholder='{"work_seconds":45,"rest_seconds":15,"rounds":3}'
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<strong style={{ fontSize: '14px' }}>Stationen</strong>
|
||||
<p style={{ fontSize: '12px', color: 'var(--text2)', margin: '6px 0 10px' }}>
|
||||
Index (Reihenfolge), optional Stationstitel und kommaseparierte IDs von{' '}
|
||||
<strong>Einzelübungen</strong> im Pool (nur Übungen mit Art „Einzelübung“).
|
||||
</p>
|
||||
{(formData.combination_slots || []).map((row, idx) => (
|
||||
<div
|
||||
key={`cs-${idx}`}
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'minmax(0, 72px) minmax(0, 1fr) minmax(0, 1.2fr) auto',
|
||||
gap: '8px',
|
||||
marginBottom: '8px',
|
||||
alignItems: 'end',
|
||||
}}
|
||||
>
|
||||
<div className="form-row">
|
||||
<label className="form-label" style={{ fontSize: '12px' }}>
|
||||
Idx.
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
max={99}
|
||||
className="form-input"
|
||||
value={row.slot_index}
|
||||
onChange={(e) => {
|
||||
const next = [...(formData.combination_slots || [])]
|
||||
const v = e.target.value
|
||||
next[idx] = {
|
||||
...row,
|
||||
slot_index: v === '' ? '' : parseInt(v, 10),
|
||||
}
|
||||
updateFormField('combination_slots', next)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label className="form-label" style={{ fontSize: '12px' }}>
|
||||
Titel
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
value={row.title || ''}
|
||||
onChange={(e) => {
|
||||
const next = [...(formData.combination_slots || [])]
|
||||
next[idx] = { ...row, title: e.target.value }
|
||||
updateFormField('combination_slots', next)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label className="form-label" style={{ fontSize: '12px' }}>
|
||||
Übungs-IDs
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-input"
|
||||
value={row.idsText || ''}
|
||||
onChange={(e) => {
|
||||
const next = [...(formData.combination_slots || [])]
|
||||
next[idx] = { ...row, idsText: e.target.value }
|
||||
updateFormField('combination_slots', next)
|
||||
}}
|
||||
placeholder="z. B. 12, 34, 56"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
className="btn"
|
||||
style={{ fontSize: '12px', padding: '6px 8px' }}
|
||||
onClick={() => {
|
||||
const prev = formData.combination_slots || []
|
||||
const next = prev.filter((_, j) => j !== idx)
|
||||
updateFormField(
|
||||
'combination_slots',
|
||||
next.length ? next : [{ slot_index: 0, title: '', idsText: '' }],
|
||||
)
|
||||
}}
|
||||
>
|
||||
Entf.
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '12px', marginTop: '4px' }}
|
||||
onClick={() => {
|
||||
const cur = formData.combination_slots || []
|
||||
const ixList = cur
|
||||
.map((r) =>
|
||||
typeof r.slot_index === 'number' && !Number.isNaN(r.slot_index) ? r.slot_index : null,
|
||||
)
|
||||
.filter((n) => n != null)
|
||||
const nextIx = ixList.length ? Math.max(...ixList) + 1 : 0
|
||||
updateFormField('combination_slots', [
|
||||
...cur,
|
||||
{ slot_index: nextIx, title: '', idsText: '' },
|
||||
])
|
||||
}}
|
||||
>
|
||||
+ Station
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div className="form-row">
|
||||
<label className="form-label">Ziel *</label>
|
||||
<RichTextEditor
|
||||
@@ -1219,7 +1432,7 @@ function ExerciseFormPage() {
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{isEdit && (
|
||||
{isEdit && formData.exercise_kind !== 'combination' && (
|
||||
<details ref={variantsDetailsRef} className="card exercise-variants-details" style={{ marginTop: '16px' }}>
|
||||
<summary className="exercise-variants-summary">
|
||||
<span className="exercise-variants-summary__title">Übungsvarianten</span>
|
||||
@@ -1380,7 +1593,7 @@ function ExerciseFormPage() {
|
||||
</details>
|
||||
)}
|
||||
|
||||
{isEdit && (
|
||||
{isEdit && formData.exercise_kind !== 'combination' && (
|
||||
<details className="card exercise-variants-details" style={{ marginTop: '16px' }}>
|
||||
<summary className="exercise-variants-summary">
|
||||
<span className="exercise-variants-summary__title">Progressionsgraph</span>
|
||||
|
||||
Reference in new issue
Block a user