chore: update versioning and enhance training framework features
- Incremented APP_VERSION to 0.8.10 and DB_SCHEMA_VERSION to 20260505037. - Updated project status and domain model documentation to reflect recent changes. - Enhanced training framework program handling with new slot-blueprint structure. - Introduced API endpoint for creating training units from framework slots. - Improved documentation for training planning and governance concepts.
This commit is contained in:
1 parent
7e21b44604
commit
c4fbabd8f6
12 files changed
+940
-1070
No files matched your search
@@ -3,13 +3,19 @@ import { Link, useNavigate, useParams, useLocation } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import ExercisePickerModal from '../components/ExercisePickerModal'
|
||||
import ExercisePeekModal from '../components/ExercisePeekModal'
|
||||
import TrainingUnitSectionsEditor from '../components/TrainingUnitSectionsEditor'
|
||||
import {
|
||||
defaultSection,
|
||||
normalizeUnitToForm,
|
||||
enrichSectionsWithVariants,
|
||||
buildSectionsPayload,
|
||||
} from '../utils/trainingUnitSectionsForm'
|
||||
|
||||
const DND_FW_SLOT = 'application/x-shinkan-framework-slot'
|
||||
|
||||
/** Unter dieser Breite: 2 Tabs (Stammdaten | Plan); darüber: alles untereinander */
|
||||
const FRAMEWORK_DESKTOP_MIN_PX = 900
|
||||
|
||||
const DND_FW_EX = 'application/x-shinkan-framework-exercise'
|
||||
const DND_FW_SLOT = 'application/x-shinkan-framework-slot'
|
||||
|
||||
function reorderArray(arr, from, to) {
|
||||
if (from === to || from < 0 || from >= arr.length) return [...arr]
|
||||
const next = [...arr]
|
||||
@@ -23,12 +29,21 @@ function emptyGoal() {
|
||||
return { title: '', notes: '' }
|
||||
}
|
||||
|
||||
function emptyExercise() {
|
||||
return { exercise_id: '', exercise_variant_id: '', exercise_title: '', variants: [] }
|
||||
}
|
||||
|
||||
function emptySlot() {
|
||||
return { title: '', notes: '', exercises: [] }
|
||||
return { title: '', notes: '', sections: [defaultSection('Ablauf')] }
|
||||
}
|
||||
|
||||
async function enrichFrameworkSlotSections(slots) {
|
||||
const out = []
|
||||
for (const s of slots || []) {
|
||||
const sec = normalizeUnitToForm({ sections: s.sections, exercises: s.exercises })
|
||||
out.push({
|
||||
...s,
|
||||
sections: await enrichSectionsWithVariants(sec),
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
/** Native-Tooltip für Ziel-Chips (Hover); kurz halten für OS-Tooltip-Limits */
|
||||
@@ -81,52 +96,11 @@ function serverFrameworkToForm(fw) {
|
||||
slots: (fw.slots || []).map((s) => ({
|
||||
title: s.title || '',
|
||||
notes: s.notes || '',
|
||||
exercises: (s.exercises || []).map((ex) => ({
|
||||
exercise_id: ex.exercise_id,
|
||||
exercise_variant_id: ex.exercise_variant_id != null ? String(ex.exercise_variant_id) : '',
|
||||
exercise_title: ex.exercise_title || '',
|
||||
variants: [],
|
||||
})),
|
||||
sections: normalizeUnitToForm({ sections: s.sections, exercises: s.exercises }),
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
async function enrichSlotExercisesWithVariants(formSlots) {
|
||||
const ids = new Set()
|
||||
for (const s of formSlots || []) {
|
||||
for (const it of s.exercises || []) {
|
||||
if (it.exercise_id) ids.add(Number(it.exercise_id))
|
||||
}
|
||||
}
|
||||
const cache = new Map()
|
||||
await Promise.all(
|
||||
[...ids].map(async (id) => {
|
||||
try {
|
||||
const ex = await api.getExercise(id)
|
||||
cache.set(id, {
|
||||
title: ex.title || '',
|
||||
variants: Array.isArray(ex.variants) ? ex.variants : [],
|
||||
})
|
||||
} catch {
|
||||
cache.set(id, { title: '', variants: [] })
|
||||
}
|
||||
})
|
||||
)
|
||||
return (formSlots || []).map((s) => ({
|
||||
...s,
|
||||
exercises: (s.exercises || []).map((it) => {
|
||||
if (!it.exercise_id) return it
|
||||
const c = cache.get(Number(it.exercise_id))
|
||||
if (!c) return it
|
||||
return {
|
||||
...it,
|
||||
exercise_title: it.exercise_title || c.title,
|
||||
variants: it.variants?.length ? it.variants : c.variants,
|
||||
}
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
||||
function buildApiPayload(form) {
|
||||
const goals = (form.goals || [])
|
||||
.map((g, i) => ({
|
||||
@@ -140,23 +114,13 @@ function buildApiPayload(form) {
|
||||
}
|
||||
|
||||
const slots = (form.slots || []).map((s, si) => {
|
||||
const exercises = (s.exercises || [])
|
||||
.map((ex, j) => {
|
||||
if (!ex.exercise_id) return null
|
||||
const vid = ex.exercise_variant_id
|
||||
return {
|
||||
exercise_id: parseInt(ex.exercise_id, 10),
|
||||
exercise_variant_id:
|
||||
vid !== '' && vid != null && !Number.isNaN(Number(vid)) ? parseInt(vid, 10) : null,
|
||||
order_index: j,
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
const secList = s.sections && s.sections.length ? s.sections : [defaultSection('Ablauf')]
|
||||
const sectionsPayload = buildSectionsPayload(secList)
|
||||
return {
|
||||
sort_order: si,
|
||||
title: (s.title || '').trim() || null,
|
||||
notes: (s.notes || '').trim() || null,
|
||||
exercises,
|
||||
sections: sectionsPayload,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -212,11 +176,10 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
const [styleDirections, setStyleDirections] = useState([])
|
||||
const [trainingTypesCatalog, setTrainingTypesCatalog] = useState([])
|
||||
const [targetGroupsCatalog, setTargetGroupsCatalog] = useState([])
|
||||
const [pickerSlotIdx, setPickerSlotIdx] = useState(null)
|
||||
const [sectionPickerCtx, setSectionPickerCtx] = useState(null)
|
||||
const [peekId, setPeekId] = useState(null)
|
||||
const [editingGoalIdx, setEditingGoalIdx] = useState(null)
|
||||
const [goalMenuGi, setGoalMenuGi] = useState(null)
|
||||
const [exerciseMenu, setExerciseMenu] = useState(null)
|
||||
/** Nur schmal: Stammdaten | Plan (Ziele übereinander, darunter Slots) — Desktop: alles sichtbar */
|
||||
const [frameworkTab, setFrameworkTab] = useState('meta')
|
||||
const [desktopLayout, setDesktopLayout] = useState(
|
||||
@@ -237,7 +200,6 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
const onPointerDown = (e) => {
|
||||
const t = e.target
|
||||
if (t.closest?.('.framework-popmenu-anchor')) return
|
||||
setExerciseMenu(null)
|
||||
setGoalMenuGi(null)
|
||||
}
|
||||
document.addEventListener('pointerdown', onPointerDown, true)
|
||||
@@ -289,7 +251,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
const fw = await api.getTrainingFrameworkProgram(fid)
|
||||
if (cancelled) return
|
||||
let next = serverFrameworkToForm(fw)
|
||||
next = { ...next, slots: await enrichSlotExercisesWithVariants(next.slots) }
|
||||
next = { ...next, slots: await enrichFrameworkSlotSections(next.slots) }
|
||||
setForm(next)
|
||||
} catch (e) {
|
||||
alert(e.message || 'Laden fehlgeschlagen')
|
||||
@@ -360,85 +322,6 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
}))
|
||||
}
|
||||
|
||||
const addExerciseToSlot = (sIdx) => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
slots: prev.slots.map((s, i) =>
|
||||
i === sIdx ? { ...s, exercises: [...(s.exercises || []), emptyExercise()] } : s
|
||||
),
|
||||
}))
|
||||
}
|
||||
|
||||
const moveExercise = (sIdx, eIdx, dir) => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
slots: prev.slots.map((s, i) => {
|
||||
if (i !== sIdx) return s
|
||||
const j = eIdx + dir
|
||||
const ex = [...(s.exercises || [])]
|
||||
if (j < 0 || j >= ex.length) return s
|
||||
;[ex[eIdx], ex[j]] = [ex[j], ex[eIdx]]
|
||||
return { ...s, exercises: ex }
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
||||
const removeExercise = (sIdx, eIdx) => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
slots: prev.slots.map((s, i) => {
|
||||
if (i !== sIdx) return s
|
||||
return { ...s, exercises: (s.exercises || []).filter((_, ei) => ei !== eIdx) }
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
||||
const setExerciseChoice = async (sIdx, eIdx, exercise) => {
|
||||
const vid = ''
|
||||
let variants = Array.isArray(exercise.variants) ? exercise.variants : []
|
||||
let title = exercise.title || ''
|
||||
if (!variants.length) {
|
||||
try {
|
||||
const full = await api.getExercise(exercise.id)
|
||||
variants = Array.isArray(full.variants) ? full.variants : []
|
||||
title = full.title || title
|
||||
} catch {
|
||||
variants = []
|
||||
}
|
||||
}
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
slots: prev.slots.map((s, i) => {
|
||||
if (i !== sIdx) return s
|
||||
const exRows = [...(s.exercises || [])]
|
||||
const row = exRows[eIdx] || emptyExercise()
|
||||
exRows[eIdx] = {
|
||||
...row,
|
||||
exercise_id: exercise.id,
|
||||
exercise_variant_id: vid,
|
||||
exercise_title: title,
|
||||
variants,
|
||||
}
|
||||
return { ...s, exercises: exRows }
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
||||
const exerciseField = (sIdx, eIdx, key, val) => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
slots: prev.slots.map((s, i) => {
|
||||
if (i !== sIdx) return s
|
||||
return {
|
||||
...s,
|
||||
exercises: (s.exercises || []).map((ex, ei) =>
|
||||
ei === eIdx ? { ...ex, [key]: val } : ex
|
||||
),
|
||||
}
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
if (!(form.title || '').trim()) {
|
||||
alert('Titel ist Pflichtfeld.')
|
||||
@@ -465,7 +348,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
await api.updateTrainingFrameworkProgram(fid, payload)
|
||||
const refreshed = await api.getTrainingFrameworkProgram(fid)
|
||||
let next = serverFrameworkToForm(refreshed)
|
||||
next = { ...next, slots: await enrichSlotExercisesWithVariants(next.slots) }
|
||||
next = { ...next, slots: await enrichFrameworkSlotSections(next.slots) }
|
||||
setForm(next)
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -487,44 +370,6 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const insertExerciseBefore = (fromS, fromE, toS, toE) => {
|
||||
setForm((prev) => {
|
||||
const slots = prev.slots.map((s) => ({ ...s, exercises: [...(s.exercises || [])] }))
|
||||
if (fromS < 0 || fromS >= slots.length || toS < 0 || toS >= slots.length) return prev
|
||||
const fromList = slots[fromS].exercises
|
||||
if (fromE < 0 || fromE >= fromList.length) return prev
|
||||
const [moved] = fromList.splice(fromE, 1)
|
||||
let insertAt = toE
|
||||
if (fromS === toS && fromE < toE) insertAt -= 1
|
||||
insertAt = Math.max(0, Math.min(insertAt, slots[toS].exercises.length))
|
||||
slots[toS].exercises.splice(insertAt, 0, moved)
|
||||
return { ...prev, slots }
|
||||
})
|
||||
}
|
||||
|
||||
const appendExerciseToSlot = (fromS, fromE, toS) => {
|
||||
setForm((prev) => {
|
||||
const slots = prev.slots.map((s) => ({ ...s, exercises: [...(s.exercises || [])] }))
|
||||
if (fromS < 0 || fromS >= slots.length || toS < 0 || toS >= slots.length) return prev
|
||||
const fromList = slots[fromS].exercises
|
||||
if (fromE < 0 || fromE >= fromList.length) return prev
|
||||
const [moved] = fromList.splice(fromE, 1)
|
||||
slots[toS].exercises.push(moved)
|
||||
return { ...prev, slots }
|
||||
})
|
||||
}
|
||||
|
||||
const onExerciseDragStart = (e, fromS, fromE) => {
|
||||
e.dataTransfer.effectAllowed = 'move'
|
||||
e.dataTransfer.setData(DND_FW_EX, JSON.stringify({ fromS, fromE }))
|
||||
setExerciseMenu(null)
|
||||
}
|
||||
|
||||
const onExerciseDragOver = (e) => {
|
||||
e.preventDefault()
|
||||
e.dataTransfer.dropEffect = 'move'
|
||||
}
|
||||
|
||||
const onSlotDragStart = (e, slotIdx) => {
|
||||
e.stopPropagation()
|
||||
e.dataTransfer.effectAllowed = 'move'
|
||||
@@ -539,17 +384,10 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
const onSlotColumnDrop = (e, targetSi) => {
|
||||
e.preventDefault()
|
||||
const slotRaw = e.dataTransfer.getData(DND_FW_SLOT)
|
||||
if (slotRaw) {
|
||||
const { slotIdx } = JSON.parse(slotRaw)
|
||||
if (slotIdx !== targetSi) {
|
||||
setForm((prev) => ({ ...prev, slots: reorderArray([...prev.slots], slotIdx, targetSi) }))
|
||||
}
|
||||
return
|
||||
}
|
||||
const exRaw = e.dataTransfer.getData(DND_FW_EX)
|
||||
if (exRaw) {
|
||||
const { fromS, fromE } = JSON.parse(exRaw)
|
||||
appendExerciseToSlot(fromS, fromE, targetSi)
|
||||
if (!slotRaw) return
|
||||
const { slotIdx } = JSON.parse(slotRaw)
|
||||
if (slotIdx !== targetSi) {
|
||||
setForm((prev) => ({ ...prev, slots: reorderArray([...prev.slots], slotIdx, targetSi) }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,11 +463,9 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
<div className="card" style={{ marginBottom: '1rem', background: 'var(--surface2)', borderStyle: 'dashed' }}>
|
||||
<p style={{ fontSize: '0.88rem', color: 'var(--text2)', lineHeight: 1.55, margin: 0 }}>
|
||||
<strong style={{ color: 'var(--text1)' }}>Rahmenprogramm (Bibliothek):</strong> Wiederverwendbare Vorlage mit
|
||||
Zielen und Session‑Slots. <strong>Zuordnung zu einer Trainingsgruppe</strong> oder zu{' '}
|
||||
<strong>konkreten Einheiten</strong> erfolgt aus der <strong>Gruppen‑Planung</strong> (Übernahme mit Link /
|
||||
Lineage) — nicht mehr direkt an diesem Datensatz. Pro Slot ist derzeit eine Übungsliste (Stückliste) hinterlegt;
|
||||
die strukturierte Einheitenplanung (Abschnitte wie in der Trainingsplanung) folgt über{' '}
|
||||
<strong>CURR‑010</strong> (Vorlagen‑Modell pro Slot).
|
||||
Zielen und Session‑Slots. <strong>Zuordnung zu Gruppe oder Kalendertermin</strong> erfolgt aus der{' '}
|
||||
<strong>Gruppen‑Planung</strong> („Übernahme“). Pro Slot planst du den Ablauf wie bei einer Trainingsseinheit:{' '}
|
||||
<strong>Abschnitte</strong>, Übungen mit Varianten und Dauer, <strong>Zwischen‑Anmerkungen</strong>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -987,7 +823,7 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
<div className="card framework-plan-slots" style={{ marginBottom: '1.5rem' }}>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px', justifyContent: 'space-between', alignItems: 'center', marginBottom: '0.75rem' }}>
|
||||
<h3 className="card-title" style={{ marginBottom: 0 }}>
|
||||
Session‑Slots & Übungen
|
||||
Session‑Slots & Ablauf
|
||||
</h3>
|
||||
<button type="button" className="btn btn-secondary framework-ctrl framework-ctrl--xs" onClick={addSlot}>
|
||||
+ Slot
|
||||
@@ -996,16 +832,15 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
|
||||
{form.slots.length === 0 ? (
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.9rem' }}>
|
||||
Noch keine Slots — mit <strong>+ Slot</strong> legst du Spalten an (z. B. „Woche 1“) und ordnest Übungen
|
||||
zu. Bei mehreren Spalten erscheint eine horizontale Scroll-Leiste.
|
||||
Noch keine Slots — mit <strong>+ Slot</strong> legst du Spalten an (z. B. „Woche 1“). In jedem Slot
|
||||
strukturierst du wie in der Trainingsplanung: Abschnitte, Übungen, Anmerkungen.
|
||||
</p>
|
||||
) : (
|
||||
<p
|
||||
className="framework-slots-hint"
|
||||
style={{ fontSize: '0.8rem', color: 'var(--text3)', marginBottom: '10px', lineHeight: 1.45 }}
|
||||
>
|
||||
Sessions nebeneinander — nach rechts scrollen bzw. wischen. Reihenfolge mit Griff (⋮⋮ / ☰)
|
||||
per Drag & Drop möglich (Browser-abhängig bei Touch); zusätzlich Pfeile und Menüs nutzbar.
|
||||
Reihenfolge der Spalten per Griff (⋮⋮) ziehen; Inhalt eines Slots wie in der Planung bearbeiten.
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -1079,190 +914,35 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div className="framework-slot-card__exercises">
|
||||
<div className="framework-slot-card__exercises-head">
|
||||
<span className="framework-slot-card__exercises-title">Übungen</span>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary framework-ctrl framework-ctrl--xs"
|
||||
onClick={() => addExerciseToSlot(si)}
|
||||
>
|
||||
+ Übung
|
||||
</button>
|
||||
</div>
|
||||
{(slot.exercises || []).length === 0 ? (
|
||||
<p className="framework-slot-card__empty-hint">
|
||||
Noch keine Übung — <strong>+ Übung</strong> oder Übung mit dem Griff ☰ hierher ziehen.
|
||||
</p>
|
||||
) : null}
|
||||
{(slot.exercises || []).map((ex, ei) => (
|
||||
<div
|
||||
key={ei}
|
||||
className="framework-ex-row"
|
||||
onDragOver={onExerciseDragOver}
|
||||
onDrop={(e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const raw = e.dataTransfer.getData(DND_FW_EX)
|
||||
if (!raw) return
|
||||
const { fromS, fromE } = JSON.parse(raw)
|
||||
if (fromS === si && fromE === ei) return
|
||||
insertExerciseBefore(fromS, fromE, si, ei)
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className="framework-ex-row__grip"
|
||||
draggable
|
||||
onDragStart={(e) => {
|
||||
e.stopPropagation()
|
||||
onExerciseDragStart(e, si, ei)
|
||||
}}
|
||||
aria-hidden
|
||||
>
|
||||
☰
|
||||
</span>
|
||||
<div className="framework-ex-row__body">
|
||||
<div className="framework-ex-row__title-line">
|
||||
{ex.exercise_id ? (
|
||||
<strong className="framework-ex-row__title">
|
||||
{ex.exercise_title || `Übung #${ex.exercise_id}`}
|
||||
</strong>
|
||||
) : (
|
||||
<span className="framework-ex-row__title framework-ex-row__title--muted">
|
||||
Keine Übung gewählt
|
||||
</span>
|
||||
)}
|
||||
{ex.exercise_id ? (
|
||||
<span className="framework-ex-row__id">#{ex.exercise_id}</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="framework-ex-row__row2">
|
||||
{ex.exercise_id && (ex.variants || []).length > 0 ? (
|
||||
<select
|
||||
className="form-input framework-ex-row__variant-select"
|
||||
value={ex.exercise_variant_id}
|
||||
onChange={(e) => exerciseField(si, ei, 'exercise_variant_id', e.target.value)}
|
||||
>
|
||||
<option value="">Variante</option>
|
||||
{(ex.variants || []).map((v) => (
|
||||
<option key={v.id} value={String(v.id)}>
|
||||
{v.variant_name || v.name || `V ${v.id}`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : (
|
||||
<span className="framework-ex-row__variant-spacer" aria-hidden />
|
||||
)}
|
||||
<div className="framework-popmenu-anchor framework-ex-row__menu-anchor">
|
||||
<button
|
||||
type="button"
|
||||
className="framework-ex-row__kebab"
|
||||
aria-label="Übung-Aktionen"
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={
|
||||
exerciseMenu?.slotIdx === si && exerciseMenu?.exIdx === ei ? 'true' : 'false'
|
||||
<div className="framework-slot-card__plan-editor" style={{ marginTop: '0.65rem', minHeight: '120px' }}>
|
||||
<TrainingUnitSectionsEditor
|
||||
heading={`Ablauf · Session ${si + 1}`}
|
||||
sections={slot.sections}
|
||||
showExecutionExtras={false}
|
||||
onSectionsChange={(updater) => {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
slots: prev.slots.map((sl, ii) =>
|
||||
ii !== si
|
||||
? sl
|
||||
: {
|
||||
...sl,
|
||||
sections: updater(
|
||||
sl.sections && sl.sections.length ? sl.sections : [defaultSection('Ablauf')]
|
||||
),
|
||||
}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
setExerciseMenu((prev) =>
|
||||
prev?.slotIdx === si && prev?.exIdx === ei
|
||||
? null
|
||||
: { slotIdx: si, exIdx: ei }
|
||||
)
|
||||
}}
|
||||
>
|
||||
⋮
|
||||
</button>
|
||||
{exerciseMenu?.slotIdx === si && exerciseMenu?.exIdx === ei ? (
|
||||
<ul className="framework-popmenu framework-popmenu--align-end" role="menu">
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
className="framework-popmenu__item"
|
||||
onClick={() => {
|
||||
setPickerSlotIdx({ slotIdx: si, exerciseIdx: ei })
|
||||
setExerciseMenu(null)
|
||||
}}
|
||||
>
|
||||
Übung wählen…
|
||||
</button>
|
||||
</li>
|
||||
{ex.exercise_id ? (
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
className="framework-popmenu__item"
|
||||
onClick={() => {
|
||||
setPeekId(Number(ex.exercise_id))
|
||||
setExerciseMenu(null)
|
||||
}}
|
||||
>
|
||||
Vorschau
|
||||
</button>
|
||||
</li>
|
||||
) : null}
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
className="framework-popmenu__item"
|
||||
onClick={() => {
|
||||
moveExercise(si, ei, -1)
|
||||
setExerciseMenu(null)
|
||||
}}
|
||||
>
|
||||
Nach oben in diesem Slot
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
className="framework-popmenu__item"
|
||||
onClick={() => {
|
||||
moveExercise(si, ei, 1)
|
||||
setExerciseMenu(null)
|
||||
}}
|
||||
>
|
||||
Nach unten in diesem Slot
|
||||
</button>
|
||||
</li>
|
||||
<li>
|
||||
<button
|
||||
type="button"
|
||||
role="menuitem"
|
||||
className="framework-popmenu__item framework-popmenu__item--danger"
|
||||
onClick={() => {
|
||||
removeExercise(si, ei)
|
||||
setExerciseMenu(null)
|
||||
}}
|
||||
>
|
||||
Entfernen
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div
|
||||
className="framework-slot-card__append-drop"
|
||||
onDragOver={onExerciseDragOver}
|
||||
onDrop={(e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
const raw = e.dataTransfer.getData(DND_FW_EX)
|
||||
if (!raw) return
|
||||
const { fromS, fromE } = JSON.parse(raw)
|
||||
appendExerciseToSlot(fromS, fromE, si)
|
||||
),
|
||||
}))
|
||||
}}
|
||||
>
|
||||
Ans Ende ziehen
|
||||
</div>
|
||||
onRequestExercisePick={({ sectionIndex, itemIndex }) =>
|
||||
setSectionPickerCtx({
|
||||
slotIdx: si,
|
||||
sectionIndex,
|
||||
itemIndex,
|
||||
})
|
||||
}
|
||||
onPeekExercise={(id) => setPeekId(id)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
@@ -1288,12 +968,54 @@ export default function TrainingFrameworkProgramEditPage() {
|
||||
</div>
|
||||
|
||||
<ExercisePickerModal
|
||||
open={pickerSlotIdx != null}
|
||||
onClose={() => setPickerSlotIdx(null)}
|
||||
onSelectExercise={(exercise) => {
|
||||
if (!pickerSlotIdx) return
|
||||
setExerciseChoice(pickerSlotIdx.slotIdx, pickerSlotIdx.exerciseIdx, exercise)
|
||||
setPickerSlotIdx(null)
|
||||
open={sectionPickerCtx != null}
|
||||
onClose={() => setSectionPickerCtx(null)}
|
||||
onSelectExercise={async (exercise) => {
|
||||
if (!sectionPickerCtx) return
|
||||
const { slotIdx, sectionIndex: sIdx, itemIndex: iIdx } = sectionPickerCtx
|
||||
let variants = Array.isArray(exercise.variants) ? exercise.variants : []
|
||||
let title = exercise.title || ''
|
||||
if (!variants.length) {
|
||||
try {
|
||||
const full = await api.getExercise(exercise.id)
|
||||
variants = Array.isArray(full.variants) ? full.variants : []
|
||||
title = full.title || title
|
||||
} catch {
|
||||
variants = []
|
||||
}
|
||||
}
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
slots: prev.slots.map((sl, ii) =>
|
||||
ii !== slotIdx
|
||||
? sl
|
||||
: {
|
||||
...sl,
|
||||
sections: (sl.sections && sl.sections.length ? sl.sections : [defaultSection('Ablauf')]).map(
|
||||
(sec, si) =>
|
||||
si !== sIdx
|
||||
? sec
|
||||
: {
|
||||
...sec,
|
||||
items: (sec.items || []).map((row, ji) =>
|
||||
ji !== iIdx
|
||||
? row
|
||||
: row.item_type !== 'exercise'
|
||||
? row
|
||||
: {
|
||||
...row,
|
||||
exercise_id: exercise.id,
|
||||
exercise_variant_id: '',
|
||||
exercise_title: title,
|
||||
variants,
|
||||
}
|
||||
),
|
||||
}
|
||||
),
|
||||
}
|
||||
),
|
||||
}))
|
||||
setSectionPickerCtx(null)
|
||||
}}
|
||||
/>
|
||||
|
||||
|
||||
@@ -4,175 +4,13 @@ import api from '../utils/api'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import ExercisePickerModal from '../components/ExercisePickerModal'
|
||||
import ExercisePeekModal from '../components/ExercisePeekModal'
|
||||
|
||||
function defaultSection(title = 'Hauptteil') {
|
||||
return { title, guidance_notes: '', items: [] }
|
||||
}
|
||||
|
||||
function exerciseRow() {
|
||||
return {
|
||||
item_type: 'exercise',
|
||||
exercise_id: '',
|
||||
exercise_variant_id: '',
|
||||
exercise_title: '',
|
||||
variants: [],
|
||||
planned_duration_min: '',
|
||||
actual_duration_min: '',
|
||||
notes: '',
|
||||
modifications: ''
|
||||
}
|
||||
}
|
||||
|
||||
function noteRow() {
|
||||
return { item_type: 'note', note_body: '' }
|
||||
}
|
||||
|
||||
function normalizeUnitToForm(fullUnit) {
|
||||
if (fullUnit.sections && fullUnit.sections.length) {
|
||||
return fullUnit.sections.map((sec) => ({
|
||||
title: sec.title,
|
||||
guidance_notes: sec.guidance_notes || '',
|
||||
items: (sec.items || []).map((it) => {
|
||||
if (it.item_type === 'note') {
|
||||
return { item_type: 'note', note_body: it.note_body || '' }
|
||||
}
|
||||
return {
|
||||
item_type: 'exercise',
|
||||
exercise_id: it.exercise_id,
|
||||
exercise_variant_id: it.exercise_variant_id ?? '',
|
||||
exercise_title: it.exercise_title || '',
|
||||
variants: [],
|
||||
planned_duration_min:
|
||||
it.planned_duration_min !== null && it.planned_duration_min !== undefined
|
||||
? String(it.planned_duration_min)
|
||||
: '',
|
||||
actual_duration_min:
|
||||
it.actual_duration_min !== null && it.actual_duration_min !== undefined
|
||||
? String(it.actual_duration_min)
|
||||
: '',
|
||||
notes: it.notes ?? '',
|
||||
modifications: it.modifications ?? ''
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
if (fullUnit.exercises && fullUnit.exercises.length) {
|
||||
return [
|
||||
{
|
||||
title: 'Übungen',
|
||||
guidance_notes: '',
|
||||
items: fullUnit.exercises.map((ex) => ({
|
||||
item_type: 'exercise',
|
||||
exercise_id: ex.exercise_id,
|
||||
exercise_variant_id: ex.exercise_variant_id ?? '',
|
||||
exercise_title: ex.exercise_title || '',
|
||||
variants: [],
|
||||
planned_duration_min:
|
||||
ex.planned_duration_min !== null && ex.planned_duration_min !== undefined
|
||||
? String(ex.planned_duration_min)
|
||||
: '',
|
||||
actual_duration_min:
|
||||
ex.actual_duration_min !== null && ex.actual_duration_min !== undefined
|
||||
? String(ex.actual_duration_min)
|
||||
: '',
|
||||
notes: ex.notes ?? '',
|
||||
modifications: ex.modifications ?? ''
|
||||
}))
|
||||
}
|
||||
]
|
||||
}
|
||||
return [defaultSection()]
|
||||
}
|
||||
|
||||
/** Lädt Varianten/Titel nach, wenn Einheit vom Server ohne variants[] im Client-State ist. */
|
||||
async function enrichSectionsWithVariants(sections) {
|
||||
if (!sections?.length) return sections
|
||||
const ids = []
|
||||
for (const sec of sections) {
|
||||
for (const it of sec.items || []) {
|
||||
if (it.item_type === 'note') continue
|
||||
if (it.exercise_id) ids.push(it.exercise_id)
|
||||
}
|
||||
}
|
||||
const unique = [...new Set(ids)]
|
||||
const cache = new Map()
|
||||
await Promise.all(
|
||||
unique.map(async (id) => {
|
||||
try {
|
||||
const ex = await api.getExercise(id)
|
||||
cache.set(id, {
|
||||
title: ex.title || '',
|
||||
variants: Array.isArray(ex.variants) ? ex.variants : [],
|
||||
})
|
||||
} catch {
|
||||
cache.set(id, { title: '', variants: [] })
|
||||
}
|
||||
})
|
||||
)
|
||||
return sections.map((sec) => ({
|
||||
...sec,
|
||||
items: (sec.items || []).map((it) => {
|
||||
if (it.item_type === 'note') return it
|
||||
if (!it.exercise_id) return it
|
||||
const c = cache.get(it.exercise_id)
|
||||
if (!c) return it
|
||||
return {
|
||||
...it,
|
||||
exercise_title: it.exercise_title || c.title,
|
||||
variants:
|
||||
Array.isArray(it.variants) && it.variants.length > 0 ? it.variants : c.variants,
|
||||
}
|
||||
}),
|
||||
}))
|
||||
}
|
||||
|
||||
function parseMin(v) {
|
||||
if (v === '' || v === null || v === undefined) return null
|
||||
const n = parseInt(String(v), 10)
|
||||
return Number.isFinite(n) ? n : null
|
||||
}
|
||||
|
||||
function buildSectionsPayload(sections) {
|
||||
return sections.map((sec, si) => ({
|
||||
order_index: si,
|
||||
title: (sec.title || '').trim() || 'Abschnitt',
|
||||
guidance_notes: sec.guidance_notes?.trim() ? sec.guidance_notes.trim() : null,
|
||||
items: (sec.items || [])
|
||||
.map((it, ii) => {
|
||||
if (it.item_type === 'note') {
|
||||
return {
|
||||
item_type: 'note',
|
||||
order_index: ii,
|
||||
note_body: it.note_body ?? ''
|
||||
}
|
||||
}
|
||||
if (it.exercise_id === '' || it.exercise_id == null || Number.isNaN(Number(it.exercise_id))) {
|
||||
return null
|
||||
}
|
||||
const vid = it.exercise_variant_id
|
||||
return {
|
||||
item_type: 'exercise',
|
||||
order_index: ii,
|
||||
exercise_id: parseInt(it.exercise_id, 10),
|
||||
exercise_variant_id:
|
||||
vid !== '' && vid != null && !Number.isNaN(Number(vid)) ? parseInt(vid, 10) : null,
|
||||
planned_duration_min: parseMin(it.planned_duration_min),
|
||||
actual_duration_min: parseMin(it.actual_duration_min),
|
||||
notes: it.notes?.trim() ? it.notes.trim() : null,
|
||||
modifications: it.modifications?.trim() ? it.modifications.trim() : null
|
||||
}
|
||||
})
|
||||
.filter(Boolean)
|
||||
}))
|
||||
}
|
||||
|
||||
function sectionPlannedMinutes(sec) {
|
||||
return (sec.items || []).reduce((sum, it) => {
|
||||
if (it.item_type !== 'exercise') return sum
|
||||
const m = parseMin(it.planned_duration_min)
|
||||
return sum + (m || 0)
|
||||
}, 0)
|
||||
}
|
||||
import TrainingUnitSectionsEditor from '../components/TrainingUnitSectionsEditor'
|
||||
import {
|
||||
defaultSection,
|
||||
normalizeUnitToForm,
|
||||
enrichSectionsWithVariants,
|
||||
buildSectionsPayload,
|
||||
} from '../utils/trainingUnitSectionsForm'
|
||||
|
||||
function TrainingPlanningPage() {
|
||||
const { user } = useAuth()
|
||||
@@ -435,93 +273,6 @@ function TrainingPlanningPage() {
|
||||
setFormData((prev) => ({ ...prev, [field]: value }))
|
||||
}
|
||||
|
||||
const updateSectionField = (sIdx, field, value) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
sections: prev.sections.map((s, i) => (i === sIdx ? { ...s, [field]: value } : s))
|
||||
}))
|
||||
}
|
||||
|
||||
const addSection = () => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
sections: [...prev.sections, defaultSection(`Abschnitt ${prev.sections.length + 1}`)]
|
||||
}))
|
||||
}
|
||||
|
||||
const removeSection = (sIdx) => {
|
||||
setFormData((prev) => {
|
||||
const next = prev.sections.filter((_, i) => i !== sIdx)
|
||||
return { ...prev, sections: next.length ? next : [defaultSection()] }
|
||||
})
|
||||
}
|
||||
|
||||
const moveSection = (sIdx, dir) => {
|
||||
setFormData((prev) => {
|
||||
const ta = sIdx + dir
|
||||
if (ta < 0 || ta >= prev.sections.length) return prev
|
||||
const copy = [...prev.sections]
|
||||
;[copy[sIdx], copy[ta]] = [copy[ta], copy[sIdx]]
|
||||
return { ...prev, sections: copy }
|
||||
})
|
||||
}
|
||||
|
||||
const addItem = (sIdx, kind) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
sections: prev.sections.map((s, i) => {
|
||||
if (i !== sIdx) return s
|
||||
const row = kind === 'note' ? noteRow() : exerciseRow()
|
||||
return { ...s, items: [...s.items, row] }
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
const updateItem = (sIdx, iIdx, field, value) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
sections: prev.sections.map((s, si) => {
|
||||
if (si !== sIdx) return s
|
||||
return {
|
||||
...s,
|
||||
items: s.items.map((it, ii) => {
|
||||
if (ii !== iIdx) return it
|
||||
const next = { ...it, [field]: value }
|
||||
if (field === 'exercise_id') {
|
||||
next.exercise_variant_id = ''
|
||||
next.exercise_title = ''
|
||||
next.variants = []
|
||||
}
|
||||
return next
|
||||
})
|
||||
}
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
const removeItem = (sIdx, iIdx) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
sections: prev.sections.map((s, i) =>
|
||||
i !== sIdx ? s : { ...s, items: s.items.filter((_, j) => j !== iIdx) }
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
const moveItem = (sIdx, iIdx, dir) => {
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
sections: prev.sections.map((s, si) => {
|
||||
if (si !== sIdx) return s
|
||||
const items = [...s.items]
|
||||
const ta = iIdx + dir
|
||||
if (ta < 0 || ta >= items.length) return s
|
||||
;[items[iIdx], items[ta]] = [items[ta], items[iIdx]]
|
||||
return { ...s, items }
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="app-page" style={{ padding: '2rem 0', textAlign: 'center' }}>
|
||||
@@ -958,316 +709,24 @@ function TrainingPlanningPage() {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{formData.sections.map((sec, sIdx) => {
|
||||
const planMin = sectionPlannedMinutes(sec)
|
||||
return (
|
||||
<div
|
||||
key={`sec-${sIdx}`}
|
||||
style={{
|
||||
marginBottom: '1.25rem',
|
||||
padding: '1rem',
|
||||
background: 'var(--surface2)',
|
||||
borderRadius: '10px',
|
||||
border: '1px solid var(--border, rgba(0,0,0,0.08))'
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem', marginBottom: '0.75rem' }}>
|
||||
<input
|
||||
className="form-input"
|
||||
style={{ flex: '2 1 220px', marginBottom: 0 }}
|
||||
value={sec.title}
|
||||
onChange={(e) => updateSectionField(sIdx, 'title', e.target.value)}
|
||||
placeholder="Abschnittstitel (z. B. Aufwärmen)"
|
||||
/>
|
||||
<div style={{ display: 'flex', gap: '4px', alignSelf: 'center' }}>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Abschnitt hoch"
|
||||
onClick={() => moveSection(sIdx, -1)}
|
||||
disabled={sIdx === 0}
|
||||
style={{ padding: '4px 10px', opacity: sIdx === 0 ? 0.35 : 1 }}
|
||||
>
|
||||
▲
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Abschnitt runter"
|
||||
onClick={() => moveSection(sIdx, 1)}
|
||||
disabled={sIdx === formData.sections.length - 1}
|
||||
style={{
|
||||
padding: '4px 10px',
|
||||
opacity: sIdx === formData.sections.length - 1 ? 0.35 : 1
|
||||
}}
|
||||
>
|
||||
▼
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" className="btn" onClick={() => removeSection(sIdx)}>
|
||||
Abschnitt entfernen
|
||||
</button>
|
||||
</div>
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={2}
|
||||
value={sec.guidance_notes}
|
||||
onChange={(e) => updateSectionField(sIdx, 'guidance_notes', e.target.value)}
|
||||
placeholder="Hinweise zum Abschnitt (Aufbau, Zielrichtung der Gruppe, Material …)"
|
||||
/>
|
||||
{planMin > 0 && (
|
||||
<p style={{ fontSize: '0.8rem', color: 'var(--text2)', marginTop: '0.35rem' }}>
|
||||
Geplant in diesem Abschnitt: ca. {planMin} Min. (Übungen)
|
||||
</p>
|
||||
)}
|
||||
<TrainingUnitSectionsEditor
|
||||
hideHeading
|
||||
sections={formData.sections}
|
||||
onSectionsChange={(updater) =>
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
sections: updater(prev.sections),
|
||||
}))
|
||||
}
|
||||
onRequestExercisePick={({ sectionIndex, itemIndex }) => {
|
||||
setExercisePickerTarget({ sIdx: sectionIndex, iIdx: itemIndex })
|
||||
setExercisePickerOpen(true)
|
||||
}}
|
||||
onPeekExercise={(id) => setPlanningPeekExerciseId(id)}
|
||||
showExecutionExtras={!!editingUnit}
|
||||
/>
|
||||
|
||||
{(sec.items || []).map((it, iIdx) =>
|
||||
it.item_type === 'note' ? (
|
||||
<div key={`note-${sIdx}-${iIdx}`} style={{ marginTop: '0.75rem' }}>
|
||||
<div style={{ fontSize: '0.78rem', color: 'var(--text2)', marginBottom: '4px' }}>
|
||||
Zwischen-Anmerkung
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '6px', alignItems: 'start' }}>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', paddingTop: '4px' }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => moveItem(sIdx, iIdx, -1)}
|
||||
disabled={iIdx === 0}
|
||||
style={{ padding: '2px', opacity: iIdx === 0 ? 0.3 : 1 }}
|
||||
>
|
||||
▲
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => moveItem(sIdx, iIdx, 1)}
|
||||
disabled={iIdx === sec.items.length - 1}
|
||||
style={{
|
||||
padding: '2px',
|
||||
opacity: iIdx === sec.items.length - 1 ? 0.3 : 1
|
||||
}}
|
||||
>
|
||||
▼
|
||||
</button>
|
||||
</div>
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={2}
|
||||
style={{ flex: 1 }}
|
||||
value={it.note_body}
|
||||
onChange={(e) => updateItem(sIdx, iIdx, 'note_body', e.target.value)}
|
||||
placeholder="Hinweise (Gruppen teilen, Hallenführung, Auf- und Abbau …)"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
style={{ background: 'var(--danger)', color: 'white', border: 'none' }}
|
||||
onClick={() => removeItem(sIdx, iIdx)}
|
||||
>
|
||||
✗
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
key={`ex-${sIdx}-${iIdx}`}
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: '32px minmax(0, 1fr) minmax(0, 72px) 40px',
|
||||
gap: '6px',
|
||||
alignItems: 'start',
|
||||
marginTop: '0.75rem',
|
||||
paddingTop: '0.5rem',
|
||||
borderTop: '1px solid rgba(0,0,0,0.06)',
|
||||
minWidth: 0
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', paddingTop: '6px' }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => moveItem(sIdx, iIdx, -1)}
|
||||
disabled={iIdx === 0}
|
||||
style={{ padding: '2px', opacity: iIdx === 0 ? 0.3 : 1 }}
|
||||
>
|
||||
▲
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => moveItem(sIdx, iIdx, 1)}
|
||||
disabled={iIdx === sec.items.length - 1}
|
||||
style={{
|
||||
padding: '2px',
|
||||
opacity: iIdx === sec.items.length - 1 ? 0.3 : 1
|
||||
}}
|
||||
>
|
||||
▼
|
||||
</button>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '6px', minWidth: 0 }}>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
gap: '8px',
|
||||
flexWrap: 'wrap',
|
||||
alignItems: 'center'
|
||||
}}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ margin: 0, whiteSpace: 'nowrap' }}
|
||||
onClick={() => {
|
||||
setExercisePickerTarget({ sIdx, iIdx })
|
||||
setExercisePickerOpen(true)
|
||||
}}
|
||||
>
|
||||
Übung suchen…
|
||||
</button>
|
||||
{it.exercise_id ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ margin: 0, whiteSpace: 'nowrap', fontSize: '0.8rem', padding: '6px 10px' }}
|
||||
onClick={() => setPlanningPeekExerciseId(it.exercise_id)}
|
||||
>
|
||||
Katalog kurz zeigen
|
||||
</button>
|
||||
) : null}
|
||||
{(it.exercise_title || it.exercise_id) && (
|
||||
<span
|
||||
style={{
|
||||
fontSize: '0.875rem',
|
||||
flex: 1,
|
||||
minWidth: 0,
|
||||
wordBreak: 'break-word'
|
||||
}}
|
||||
title={
|
||||
it.exercise_title ||
|
||||
(it.exercise_id ? `Übung #${it.exercise_id}` : '')
|
||||
}
|
||||
>
|
||||
{it.exercise_title ||
|
||||
(it.exercise_id ? `Übung #${it.exercise_id}` : '')}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{(() => {
|
||||
const variantOpts = Array.isArray(it.variants) ? it.variants : []
|
||||
return (
|
||||
<select
|
||||
className="form-input"
|
||||
value={
|
||||
it.exercise_variant_id === '' || it.exercise_variant_id == null
|
||||
? ''
|
||||
: String(it.exercise_variant_id)
|
||||
}
|
||||
onChange={(e) => {
|
||||
const raw = e.target.value
|
||||
updateItem(
|
||||
sIdx,
|
||||
iIdx,
|
||||
'exercise_variant_id',
|
||||
raw === '' ? '' : parseInt(raw, 10)
|
||||
)
|
||||
}}
|
||||
disabled={!it.exercise_id || variantOpts.length === 0}
|
||||
style={{ margin: 0, fontSize: '0.875rem' }}
|
||||
>
|
||||
<option value="">
|
||||
{variantOpts.length === 0
|
||||
? 'Keine Varianten'
|
||||
: 'Stammübung'}
|
||||
</option>
|
||||
{variantOpts.map((v) => (
|
||||
<option key={v.id} value={v.id}>
|
||||
{v.variant_name || `Variante #${v.id}`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)
|
||||
})()}
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={editingUnit ? 2 : 1}
|
||||
value={it.notes || ''}
|
||||
onChange={(e) => updateItem(sIdx, iIdx, 'notes', e.target.value)}
|
||||
placeholder="Kurze Anmerkung zur Übung"
|
||||
style={{ fontSize: '0.875rem' }}
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
type="number"
|
||||
className="form-input"
|
||||
min={1}
|
||||
value={it.planned_duration_min}
|
||||
onChange={(e) =>
|
||||
updateItem(sIdx, iIdx, 'planned_duration_min', e.target.value)
|
||||
}
|
||||
placeholder="min"
|
||||
title="Geplante Dauer (Minuten)"
|
||||
style={{ margin: 0 }}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
style={{
|
||||
padding: '0.5rem',
|
||||
background: 'var(--danger)',
|
||||
color: 'white',
|
||||
border: 'none'
|
||||
}}
|
||||
onClick={() => removeItem(sIdx, iIdx)}
|
||||
>
|
||||
✗
|
||||
</button>
|
||||
{editingUnit && (
|
||||
<label
|
||||
className="form-label"
|
||||
style={{
|
||||
gridColumn: '2 / -1',
|
||||
marginTop: 4,
|
||||
display: 'block',
|
||||
fontSize: '0.8rem'
|
||||
}}
|
||||
>
|
||||
Ist-Dauer / Anpassungen
|
||||
<input
|
||||
type="number"
|
||||
className="form-input"
|
||||
min={1}
|
||||
value={it.actual_duration_min}
|
||||
onChange={(e) =>
|
||||
updateItem(sIdx, iIdx, 'actual_duration_min', e.target.value)
|
||||
}
|
||||
placeholder="IST min"
|
||||
style={{ maxWidth: '120px' }}
|
||||
/>
|
||||
<textarea
|
||||
className="form-input"
|
||||
rows={2}
|
||||
value={it.modifications || ''}
|
||||
onChange={(e) =>
|
||||
updateItem(sIdx, iIdx, 'modifications', e.target.value)
|
||||
}
|
||||
placeholder="Abweichungen beim Durchführen"
|
||||
style={{ marginTop: '6px', fontSize: '0.875rem' }}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
)}
|
||||
|
||||
<div style={{ marginTop: '0.85rem', display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => addItem(sIdx, 'exercise')}>
|
||||
+ Übung
|
||||
</button>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => addItem(sIdx, 'note')}>
|
||||
+ Anmerkung
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
|
||||
<button type="button" className="btn btn-secondary" onClick={addSection} style={{ marginBottom: '1.75rem' }}>
|
||||
+ Abschnitt hinzufügen
|
||||
</button>
|
||||
<div style={{ marginBottom: '1.75rem' }} />
|
||||
|
||||
{editingUnit && (
|
||||
<>
|
||||
|
||||
Reference in new issue
Block a user