feat(combination-exercises): enhance method profile integration and update specifications
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 1m4s
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 1m4s
- Updated app version to 0.8.102, reflecting recent enhancements in combination exercises. - Introduced structured method profiles for combination exercises, allowing for detailed planning and coaching support. - Enhanced frontend components to display method profiles in the Exercise and Combination Coach views. - Updated documentation to include new specifications and implementation details for method archetypes and profiles. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
919910d52a
commit
12fd3926b2
12 files changed
+564
-27
No files matched your search
@@ -11,7 +11,7 @@ import {
|
||||
sortCombinationSlotsForDisplay,
|
||||
} from '../constants/combinationArchetypes'
|
||||
|
||||
export default function CombinationCoachSlots({ combinationSlots, methodArchetype }) {
|
||||
export default function CombinationCoachSlots({ combinationSlots, methodArchetype, methodProfile }) {
|
||||
const slots = useMemo(() => sortCombinationSlotsForDisplay(combinationSlots), [combinationSlots])
|
||||
|
||||
const candidateIds = useMemo(() => {
|
||||
@@ -111,6 +111,42 @@ export default function CombinationCoachSlots({ combinationSlots, methodArchetyp
|
||||
{archetypeCoachHint(archeKey)}
|
||||
</p>
|
||||
|
||||
{methodProfile && typeof methodProfile === 'object' && !Array.isArray(methodProfile) && Object.keys(methodProfile).length ? (
|
||||
<div
|
||||
style={{
|
||||
margin: '0 0 14px',
|
||||
padding: '8px 10px',
|
||||
borderRadius: '8px',
|
||||
background: 'var(--surface)',
|
||||
border: '1px solid var(--border)',
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: '0.7rem', fontWeight: 700, color: 'var(--text3)', textTransform: 'uppercase', marginBottom: '6px' }}>
|
||||
Geplantes Ablaufprofil (Katalog)
|
||||
</div>
|
||||
<dl style={{ margin: 0, fontSize: '0.82rem', lineHeight: 1.45 }}>
|
||||
{Object.entries(methodProfile)
|
||||
.sort(([a], [b]) => a.localeCompare(b, 'de'))
|
||||
.map(([k, val]) => (
|
||||
<div key={k} style={{ marginBottom: '4px', display: 'grid', gridTemplateColumns: 'minmax(72px,1fr) minmax(0,2fr)', gap: '6px 10px' }}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)', wordBreak: 'break-all' }}>{k}</dt>
|
||||
<dd style={{ margin: 0, color: 'var(--text1)' }}>
|
||||
{typeof val === 'boolean'
|
||||
? val
|
||||
? 'ja'
|
||||
: 'nein'
|
||||
: typeof val === 'number'
|
||||
? String(val)
|
||||
: typeof val === 'string'
|
||||
? val
|
||||
: JSON.stringify(val)}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{!slots.length ? (
|
||||
<p style={{ margin: 0, color: 'var(--text3)', fontSize: '0.88rem' }}>Keine Stationen hinterlegt.</p>
|
||||
) : (
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import { archetypeCoachHint, combinationArchetypeLabel } from '../constants/combinationArchetypes'
|
||||
import {
|
||||
METHOD_PROFILE_GUI_FIELDS,
|
||||
parseProfileJson,
|
||||
setFullProfileRawJson,
|
||||
updateProfileGuided,
|
||||
} from '../utils/combinationMethodProfileUi'
|
||||
|
||||
function clampInt(n, min, max) {
|
||||
if (!Number.isFinite(n)) return null
|
||||
let x = n
|
||||
if (typeof min === 'number' && x < min) x = min
|
||||
if (typeof max === 'number' && x > max) x = max
|
||||
return Math.round(x)
|
||||
}
|
||||
|
||||
/**
|
||||
* Kombination: geführtes Ablaufprofil + optionales Roh-JSON.
|
||||
*/
|
||||
export default function CombinationMethodProfileEditor({
|
||||
methodArchetype,
|
||||
methodProfileJson,
|
||||
onChangeMethodProfileJson,
|
||||
}) {
|
||||
const arch = typeof methodArchetype === 'string' ? methodArchetype.trim() : ''
|
||||
const fieldsGui = METHOD_PROFILE_GUI_FIELDS[arch]
|
||||
const fields = Array.isArray(fieldsGui) ? fieldsGui : null
|
||||
const parseState = useMemo(() => parseProfileJson(methodProfileJson || '{}'), [methodProfileJson])
|
||||
const [rawOpenError, setRawOpenError] = useState(null)
|
||||
const [rawDraft, setRawDraft] = useState(null)
|
||||
|
||||
const profileObj = parseState.ok ? parseState.obj : {}
|
||||
|
||||
const applyGuided = (key, value, kind) => {
|
||||
if (kind === 'bool') {
|
||||
const res = updateProfileGuided(arch, methodProfileJson || '{}', key, value, 'bool')
|
||||
if (!res.ok) return
|
||||
onChangeMethodProfileJson(res.json)
|
||||
return
|
||||
}
|
||||
if (value === '' || value === undefined || value === null) {
|
||||
const res = updateProfileGuided(arch, methodProfileJson || '{}', key, '', 'int')
|
||||
if (!res.ok) return
|
||||
onChangeMethodProfileJson(res.json)
|
||||
return
|
||||
}
|
||||
const num = typeof value === 'number' ? value : parseInt(String(value), 10)
|
||||
if (!Number.isFinite(num)) return
|
||||
const def = METHOD_PROFILE_GUI_FIELDS[arch]?.find((f) => f.key === key && f.kind === 'int')
|
||||
const c = clampInt(num, def?.min, def?.max)
|
||||
if (c == null) return
|
||||
const res = updateProfileGuided(arch, methodProfileJson || '{}', key, c, 'int')
|
||||
if (!res.ok) return
|
||||
onChangeMethodProfileJson(res.json)
|
||||
}
|
||||
|
||||
const archeLabel = arch ? combinationArchetypeLabel(arch) : null
|
||||
|
||||
const openAdvanced = () => {
|
||||
setRawOpenError(null)
|
||||
const p = parseProfileJson(methodProfileJson || '{}')
|
||||
setRawDraft(p.ok ? JSON.stringify(p.obj, null, 2) : String(methodProfileJson || ''))
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ marginTop: '10px' }}>
|
||||
{arch ? (
|
||||
<p style={{ fontSize: '12px', color: 'var(--text2)', lineHeight: 1.48, margin: '0 0 12px' }}>
|
||||
<strong style={{ color: 'var(--text1)' }}>
|
||||
Coach & Planung:{' '}
|
||||
{archeLabel && archeLabel !== arch ? `${archeLabel} · ` : ''}
|
||||
</strong>
|
||||
{archetypeCoachHint(arch)}
|
||||
</p>
|
||||
) : (
|
||||
<p style={{ fontSize: '12px', color: 'var(--text3)', margin: '0 0 12px' }}>
|
||||
Wähle einen Archetyp, um das Ablaufprofil strukturiert zu erfassen — oder nur das JSON weiter unten.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{!parseState.ok ? (
|
||||
<p style={{ color: 'var(--danger)', fontSize: '13px', marginBottom: '10px' }}>{parseState.error}</p>
|
||||
) : null}
|
||||
|
||||
{fields && fields.length > 0 ? (
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '10px', marginBottom: '12px' }}>
|
||||
{fields.map((def) => {
|
||||
if (def.kind === 'bool') {
|
||||
const ck = !!profileObj[def.key]
|
||||
return (
|
||||
<label
|
||||
key={def.key}
|
||||
style={{ display: 'flex', gap: '8px', alignItems: 'center', cursor: 'pointer', fontSize: '0.9rem' }}
|
||||
>
|
||||
<input type="checkbox" checked={ck} onChange={(e) => applyGuided(def.key, e.target.checked, 'bool')} />
|
||||
<span>{def.label}</span>
|
||||
</label>
|
||||
)
|
||||
}
|
||||
const v = profileObj[def.key]
|
||||
const str =
|
||||
v === undefined || v === null ? '' : typeof v === 'number' && Number.isFinite(v) ? String(v) : String(v)
|
||||
|
||||
return (
|
||||
<div className="form-row" key={def.key}>
|
||||
<label className="form-label" style={{ fontSize: '12px' }}>
|
||||
{def.label}
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
className="form-input"
|
||||
min={def.min}
|
||||
max={def.max}
|
||||
value={str}
|
||||
placeholder="optional"
|
||||
onChange={(e) => {
|
||||
const t = e.target.value
|
||||
if (t.trim() === '') applyGuided(def.key, '', 'int')
|
||||
else applyGuided(def.key, parseInt(t, 10), 'int')
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
) : arch && fields && fields.length === 0 ? (
|
||||
<p style={{ fontSize: '12px', color: 'var(--text3)', margin: '0 0 10px' }}>
|
||||
Für diesen Archetyp gibt es keine vorgegebenen Profilfelder — nutze die Freitexte der Kombination oder Roh‑JSON bei Bedarf.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<details
|
||||
style={{
|
||||
marginTop: '4px',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid var(--border)',
|
||||
padding: '8px 10px',
|
||||
background: 'var(--surface)',
|
||||
}}
|
||||
onToggle={(ev) => {
|
||||
if (ev.target.open) openAdvanced()
|
||||
}}
|
||||
>
|
||||
<summary style={{ cursor: 'pointer', fontSize: '0.82rem', fontWeight: 600 }}>Erweitert: JSON direkt bearbeiten</summary>
|
||||
<p style={{ fontSize: '11px', color: 'var(--text3)', margin: '8px 0 6px', lineHeight: 1.4 }}>
|
||||
Zusätzliche Schlüssel (Piloten). Geführte Felder können dieselben Schlüssel beim nächsten Speichern überlagern.
|
||||
</p>
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={8}
|
||||
style={{ fontFamily: 'Consolas,monospace', fontSize: '12px' }}
|
||||
value={rawDraft != null ? rawDraft : methodProfileJson || '{}'}
|
||||
onChange={(e) => {
|
||||
setRawDraft(e.target.value)
|
||||
setRawOpenError(null)
|
||||
}}
|
||||
spellCheck={false}
|
||||
onBlur={() => {
|
||||
const src = rawDraft != null ? rawDraft : methodProfileJson
|
||||
const res = setFullProfileRawJson(src || '{}')
|
||||
if (!res.ok) {
|
||||
setRawOpenError(res.error)
|
||||
return
|
||||
}
|
||||
setRawOpenError(null)
|
||||
setRawDraft(null)
|
||||
onChangeMethodProfileJson(res.json)
|
||||
}}
|
||||
/>
|
||||
{rawOpenError ? <p style={{ color: 'var(--danger)', fontSize: '12px', marginTop: '6px' }}>{rawOpenError}</p> : null}
|
||||
</details>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -114,6 +114,7 @@ export default function ExerciseFullContent({ exercise, loading, error, exercise
|
||||
<CombinationCoachSlots
|
||||
combinationSlots={exercise.combination_slots}
|
||||
methodArchetype={exercise.method_archetype}
|
||||
methodProfile={exercise.method_profile}
|
||||
/>
|
||||
) : null}
|
||||
<h2 style={{ margin: '0 0 8px', fontSize: '1.2rem', lineHeight: 1.35 }}>{exercise.title}</h2>
|
||||
|
||||
@@ -7,6 +7,7 @@ import ExerciseProgressionGraphPanel from '../components/ExerciseProgressionGrap
|
||||
import ExerciseMediaThumbTile from '../components/ExerciseMediaThumbTile'
|
||||
import MediaPreviewModal from '../components/MediaPreviewModal'
|
||||
import ReportContentModal from '../components/ReportContentModal'
|
||||
import CombinationMethodProfileEditor from '../components/CombinationMethodProfileEditor'
|
||||
import {
|
||||
SHINKAN_EXERCISE_MEDIA_DRAG_MIME,
|
||||
buildExerciseMediaDragPayload,
|
||||
@@ -1016,13 +1017,13 @@ function ExerciseFormPage() {
|
||||
{formData.exercise_kind === 'combination' ? (
|
||||
<>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Methoden-Archetyp (optional)</label>
|
||||
<label className="form-label">Methoden-Archetyp (für Coach & Planung empfohlen)</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={formData.method_archetype || ''}
|
||||
onChange={(e) => updateFormField('method_archetype', e.target.value)}
|
||||
>
|
||||
<option value="">— später wählen —</option>
|
||||
<option value="">— noch nicht festgelegt —</option>
|
||||
{COMBINATION_ARCHETYPE_OPTIONS.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.label}
|
||||
@@ -1031,14 +1032,11 @@ function ExerciseFormPage() {
|
||||
</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}'
|
||||
<label className="form-label">Ablaufprofil (über Archetyp)</label>
|
||||
<CombinationMethodProfileEditor
|
||||
methodArchetype={formData.method_archetype || ''}
|
||||
methodProfileJson={formData.method_profile_json || '{}'}
|
||||
onChangeMethodProfileJson={(s) => updateFormField('method_profile_json', s)}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* Geführtes method_profile für Kombinationsübungen — Felder nach method_archetype.
|
||||
* Unbekannte JSON-Schlüssel bleiben beim Zusammenführen erhalten (Erweiterbarkeit).
|
||||
*/
|
||||
|
||||
const INT_MAX = 86400
|
||||
|
||||
function parseProfileJson(raw) {
|
||||
if (typeof raw !== 'string' || !raw.trim()) return { ok: true, obj: {} }
|
||||
try {
|
||||
const p = JSON.parse(raw)
|
||||
if (!p || typeof p !== 'object' || Array.isArray(p)) {
|
||||
return { ok: false, error: 'Ablaufprofil muss ein JSON-Objekt sein.' }
|
||||
}
|
||||
return { ok: true, obj: { ...p } }
|
||||
} catch {
|
||||
return { ok: false, error: 'Ablaufprofil (JSON): Syntax ungültig.' }
|
||||
}
|
||||
}
|
||||
|
||||
/** Pro Archetyp: UI-Feldbeschreibungen (Werte werden in method_profile geschrieben) */
|
||||
export const METHOD_PROFILE_GUI_FIELDS = Object.freeze({
|
||||
sequence_linear: [
|
||||
{
|
||||
key: 'hint_step_duration_sec',
|
||||
kind: 'int',
|
||||
label: 'Orientierung: Sekunden je Station/Schritt (optional)',
|
||||
min: 5,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'block_intro_sec',
|
||||
kind: 'int',
|
||||
label: 'Einführung / Demon am Block Gesamt (Sek., optional)',
|
||||
min: 0,
|
||||
max: INT_MAX,
|
||||
},
|
||||
],
|
||||
circuit_rotate_time: [
|
||||
{
|
||||
key: 'work_seconds',
|
||||
kind: 'int',
|
||||
label: 'Arbeitszeit pro Station (Sek.)',
|
||||
min: 5,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'transition_seconds',
|
||||
kind: 'int',
|
||||
label: 'Wechsel / Rotation (Sek., optional)',
|
||||
min: 0,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'rest_seconds',
|
||||
kind: 'int',
|
||||
label: 'Pause zwischen Runden oder Stationen-Folgen (Sek., optional)',
|
||||
min: 0,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'rounds',
|
||||
kind: 'int',
|
||||
label: 'Runden (optional, wenn alle Station je Runde angefahren werden)',
|
||||
min: 1,
|
||||
max: 999,
|
||||
},
|
||||
],
|
||||
circuit_all_parallel: [
|
||||
{
|
||||
key: 'explain_before_seconds',
|
||||
kind: 'int',
|
||||
label: 'Zeitfenster Vorab‑Erklärung aller Stationen (Sek., optional)',
|
||||
min: 0,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'simultaneous_start',
|
||||
kind: 'bool',
|
||||
label: 'Alle Stationen starten zusammen nach Erklärung',
|
||||
},
|
||||
],
|
||||
station_parcour: [
|
||||
{
|
||||
key: 'allow_free_visit_order',
|
||||
kind: 'bool',
|
||||
label: 'Reihenfolge der Besuche frei (Parcours / Abhaken-Logik später im Coach)',
|
||||
},
|
||||
],
|
||||
pair_superset: [
|
||||
{
|
||||
key: 'switch_seconds',
|
||||
kind: 'int',
|
||||
label: 'Orientierung: Wechselpause A↔B (Sek., optional)',
|
||||
min: 0,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'work_seconds_per_side',
|
||||
kind: 'int',
|
||||
label: 'Arbeit pro Rolle oder Seite (Sek., optional)',
|
||||
min: 5,
|
||||
max: INT_MAX,
|
||||
},
|
||||
],
|
||||
time_domain_interval: [
|
||||
{
|
||||
key: 'work_seconds',
|
||||
kind: 'int',
|
||||
label: 'Intervall: Belastungszeit (Sek.)',
|
||||
min: 5,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'rest_seconds',
|
||||
kind: 'int',
|
||||
label: 'Intervall: Erholungszeit (Sek., optional)',
|
||||
min: 0,
|
||||
max: INT_MAX,
|
||||
},
|
||||
{
|
||||
key: 'interval_rounds',
|
||||
kind: 'int',
|
||||
label: 'Anzahl Wiederholungen / Runden der Domäne (optional)',
|
||||
min: 1,
|
||||
max: 999,
|
||||
},
|
||||
],
|
||||
free_method_block: [],
|
||||
})
|
||||
|
||||
/**
|
||||
* Aktualisiert method_profile unter Beibehaltung nicht-GUI Schlüssel.
|
||||
*/
|
||||
export function updateProfileGuided(archetype, rawJson, key, parsedValue, kind) {
|
||||
const arch = typeof archetype === 'string' ? archetype.trim() : ''
|
||||
const parsed = parseProfileJson(rawJson)
|
||||
if (!parsed.ok) return parsed
|
||||
const next = { ...parsed.obj }
|
||||
|
||||
if (kind === 'bool') {
|
||||
if (parsedValue) next[key] = true
|
||||
else delete next[key]
|
||||
} else if (kind === 'int') {
|
||||
if (parsedValue === null || parsedValue === undefined || parsedValue === '') {
|
||||
delete next[key]
|
||||
} else {
|
||||
const n = typeof parsedValue === 'number' ? parsedValue : parseInt(String(parsedValue), 10)
|
||||
if (!Number.isFinite(n)) delete next[key]
|
||||
else next[key] = n
|
||||
}
|
||||
}
|
||||
|
||||
const outJson = JSON.stringify(next)
|
||||
return { ok: true, obj: next, json: outJson === '{}' ? '{}' : outJson }
|
||||
}
|
||||
|
||||
export function setFullProfileRawJson(rawEditable) {
|
||||
const parsed = parseProfileJson(rawEditable)
|
||||
if (!parsed.ok) return parsed
|
||||
const j = JSON.stringify(parsed.obj)
|
||||
return { ok: true, obj: parsed.obj, json: j === '{}' ? '{}' : j }
|
||||
}
|
||||
|
||||
export { parseProfileJson, INT_MAX }
|
||||
Reference in new issue
Block a user