Update version to 0.8.147 and add functionality to save exercises as training modules
Test Suite / playwright-tests (push) Waiting to run
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Has been cancelled
Test Suite / playwright-tests (push) Waiting to run
Deploy Development / deploy (push) Successful in 38s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Has been cancelled
- Incremented app version to 0.8.147 and updated changelog to reflect the new version. - Introduced a new modal for saving exercises as training modules within the training planning interface. - Enhanced the TrainingPlanningPageRoot component to manage the new save module functionality, including state management for the modal. - Updated the TrainingPlanningUnitFormModal to include an option for saving exercises as a module, improving user experience in training planning.
This commit is contained in:
1 parent
7693139242
commit
a51f794945
5 files changed
+467
-6
No files matched your search
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Übungspositionen aus GET /api/training-units/:id für die Modul-Erstellung (Reihenfolge = Timeline).
|
||||
* @param {object} unit – hydratisierte Trainingseinheit mit `phases` und/oder `sections`
|
||||
* @returns {Array<{ exercise_id: number, exercise_variant_id: number|null, planned_duration_min: number|null, notes: string|null, exercise_title?: string, contextLabel: string }>}
|
||||
*/
|
||||
export function collectExercisePlacementsForModule(unit) {
|
||||
if (!unit || typeof unit !== 'object') return []
|
||||
|
||||
const rows = []
|
||||
|
||||
const pushFromSection = (sec, ctx) => {
|
||||
const st = (sec?.title || '').trim()
|
||||
for (const it of sec?.items || []) {
|
||||
if ((it?.item_type || 'exercise') !== 'exercise') continue
|
||||
const eid = it.exercise_id
|
||||
if (!eid) continue
|
||||
const labelParts = [ctx, st].filter(Boolean)
|
||||
rows.push({
|
||||
exercise_id: Number(eid),
|
||||
exercise_variant_id:
|
||||
it.exercise_variant_id != null && it.exercise_variant_id !== ''
|
||||
? Number(it.exercise_variant_id)
|
||||
: null,
|
||||
planned_duration_min:
|
||||
it.planned_duration_min != null && it.planned_duration_min !== ''
|
||||
? Number(it.planned_duration_min)
|
||||
: null,
|
||||
notes: it.notes != null && String(it.notes).trim() ? String(it.notes).trim() : null,
|
||||
exercise_title: (it.exercise_title || '').trim() || `Übung #${eid}`,
|
||||
contextLabel: labelParts.length ? labelParts.join(' · ') : '',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const phases = Array.isArray(unit.phases) ? unit.phases : []
|
||||
for (const ph of phases) {
|
||||
const pk = String(ph?.phase_kind || '').toLowerCase()
|
||||
const phaseCtx = (ph?.title || '').trim()
|
||||
if (pk === 'parallel') {
|
||||
for (const st of ph.streams || []) {
|
||||
const streamCtx = [phaseCtx, (st?.title || '').trim()].filter(Boolean).join(' · ')
|
||||
for (const sec of st?.sections || []) {
|
||||
pushFromSection(sec, streamCtx)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const sec of ph?.sections || []) {
|
||||
pushFromSection(sec, phaseCtx)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!rows.length && Array.isArray(unit.sections)) {
|
||||
for (const sec of unit.sections) {
|
||||
pushFromSection(sec, '')
|
||||
}
|
||||
}
|
||||
|
||||
return rows
|
||||
}
|
||||
Reference in new issue
Block a user