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
@@ -451,7 +451,7 @@ export function buildExerciseApiPayload(formData, extras = {}) {
|
||||
.filter((x) => x && x.target_group_id)
|
||||
.map((x) => ({ target_group_id: Number(x.target_group_id), is_primary: !!x.is_primary }))
|
||||
|
||||
return {
|
||||
const payload = {
|
||||
title: (formData.title || '').trim(),
|
||||
summary: formData.summary || null,
|
||||
goal: goalHtml.trim() ? goalHtml : null,
|
||||
@@ -478,8 +478,65 @@ export function buildExerciseApiPayload(formData, extras = {}) {
|
||||
visibility: formData.visibility || 'private',
|
||||
status: formData.status || 'draft',
|
||||
club_id: formData.club_id ?? null,
|
||||
exercise_kind:
|
||||
String(formData.exercise_kind || 'simple').toLowerCase() === 'combination'
|
||||
? 'combination'
|
||||
: 'simple',
|
||||
...extras,
|
||||
}
|
||||
|
||||
const isCombo = payload.exercise_kind === 'combination'
|
||||
|
||||
if (isCombo) {
|
||||
let mpObj = {}
|
||||
const mpRaw = typeof formData.method_profile_json === 'string' ? formData.method_profile_json.trim() : ''
|
||||
if (mpRaw) {
|
||||
try {
|
||||
const parsed = JSON.parse(mpRaw)
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
throw new Error('Ablaufprofil muss ein JSON-Objekt sein.')
|
||||
}
|
||||
mpObj = parsed
|
||||
} catch (e) {
|
||||
if (e instanceof SyntaxError) {
|
||||
throw new Error('Ablaufprofil (JSON): Syntax ungültig.')
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
const slotRows = Array.isArray(formData.combination_slots) ? formData.combination_slots : []
|
||||
const combination_slots = []
|
||||
for (let i = 0; i < slotRows.length; i += 1) {
|
||||
const row = slotRows[i] || {}
|
||||
const ix =
|
||||
row.slot_index === '' || row.slot_index == null ? i : parseInt(row.slot_index, 10)
|
||||
if (Number.isNaN(ix) || ix < 0 || ix > 99) {
|
||||
throw new Error(`Station Index ungültig (Zeile ${i + 1}).`)
|
||||
}
|
||||
const idsText = typeof row.idsText === 'string' ? row.idsText : ''
|
||||
const candidate_exercise_ids = idsText
|
||||
.split(/[\s,;]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
.map((s) => parseInt(s, 10))
|
||||
.filter((n) => Number.isFinite(n))
|
||||
combination_slots.push({
|
||||
slot_index: ix,
|
||||
title: (typeof row.title === 'string' && row.title.trim()) || null,
|
||||
candidate_exercise_ids,
|
||||
})
|
||||
}
|
||||
|
||||
payload.method_archetype = (formData.method_archetype || '').trim() || null
|
||||
payload.method_profile = mpObj
|
||||
payload.combination_slots = combination_slots
|
||||
} else {
|
||||
payload.method_archetype = null
|
||||
payload.method_profile = {}
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
export async function uploadExerciseMedia(exerciseId, formData) {
|
||||
|
||||
Reference in new issue
Block a user