feat(training-unit-editor): integrate new summary function and enhance combination exercise display
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 56s

- Introduced `summarizeSlotProfileBrief` utility for concise slot profile summaries, improving the display of combination exercises.
- Updated `CombinationCoachSlots` and `ExercisePeekModal` components to utilize the new summary function for better user experience.
- Enhanced `TrainingUnitSectionsEditor` to manage combination slots more effectively, including improved title handling and display options.
- Adjusted `TrainingPlanningPage` to support additional peek context for combination exercises, streamlining the planning process.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 4.6 committed 2026-05-13 14:11:53 +02:00
1 parent 805ad3c5a5
commit 5dc93d9a8c
6 files changed
+298 -59

No files matched your search

@@ -242,6 +242,47 @@ export function readSlotProfilesV1(profileObj) {
}).filter(Boolean)
}
/** Kurztext für Listen/strip (Coach „Plan:“ — gleiche Logik). */
export function summarizeSlotProfileBrief(r) {
if (!r) return null
const adv = r.advance_mode || 'timed'
const bits = []
if (adv === 'timed') {
bits.push('Zeit')
if (r.load_sec != null) bits.push(`${r.load_sec}s Arbeit`)
} else if (adv === 'rep') {
bits.push('Ziel‑Wdh.')
const nSer = r.rep_series_count != null && r.rep_series_count >= 1 ? r.rep_series_count : 1
if (r.consecutive_reps != null) {
if (nSer >= 2) bits.push(`${nSer} Serien à ${r.consecutive_reps}×`)
else bits.push(`${r.consecutive_reps}×`)
}
} else {
bits.push('Coach')
const nSerMan = r.rep_series_count != null && r.rep_series_count >= 2 ? r.rep_series_count : 1
if (r.consecutive_reps != null) {
if (nSerMan >= 2) bits.push(`${nSerMan} Serien à Richtwert ${r.consecutive_reps}×`)
else bits.push(`Richtwert ${r.consecutive_reps}×`)
} else if (r.rep_series_count != null && r.rep_series_count >= 2) {
bits.push(`${r.rep_series_count} Serien`)
}
}
if (r.intra_rep_rest_sec != null) {
if (adv === 'timed') bits.push(`Pause ${r.intra_rep_rest_sec}s`)
else if (adv === 'rep' && r.rep_series_count != null && r.rep_series_count >= 2)
bits.push(`Pause zw. Serien ${r.intra_rep_rest_sec}s`)
else if (
adv === 'manual' &&
r.rep_series_count != null &&
r.rep_series_count >= 2
) {
bits.push(`Pause zw. Serien ${r.intra_rep_rest_sec}s`)
}
}
if (r.transition_after_sec != null) bits.push(`Wechsel ${r.transition_after_sec}s`)
return bits.join(' · ')
}
function normalizeOptionalNonNegInt(v) {
if (v === '' || v === undefined || v === null) return undefined
const n = typeof v === 'number' ? v : parseInt(String(v), 10)
+43 -1
View File
@@ -276,6 +276,48 @@ export async function enrichSectionsWithVariants(sections) {
}
})
)
const titleById = new Map()
for (const id of unique) {
const row = cache.get(id)
const t = (row?.title || '').trim()
if (t) titleById.set(Number(id), t)
}
const comboCandidateExtra = new Set()
for (const id of unique) {
const row = cache.get(id)
if (String(row?.exercise_kind || '').toLowerCase().trim() !== 'combination') continue
for (const slot of row.combination_slots || []) {
for (const raw of slot.candidate_exercise_ids || []) {
const n = typeof raw === 'number' ? raw : parseInt(String(raw), 10)
if (Number.isFinite(n) && !titleById.has(n)) comboCandidateExtra.add(n)
}
}
}
await Promise.all(
[...comboCandidateExtra].map(async (cid) => {
try {
const ex = await api.getExercise(cid)
titleById.set(cid, ((ex.title || '').trim() || `Übung #${cid}`))
} catch {
titleById.set(cid, `Übung #${cid}`)
}
}),
)
function comboMemberTitleByIdForSlots(slots) {
const o = {}
for (const slot of slots || []) {
for (const raw of slot.candidate_exercise_ids || []) {
const n = typeof raw === 'number' ? raw : parseInt(String(raw), 10)
if (!Number.isFinite(n)) continue
const key = String(n)
if (!o[key]) o[key] = titleById.get(n) || `Übung #${n}`
}
}
return o
}
return sections.map((sec) => ({
...sec,
items: (sec.items || []).map((it) => {
@@ -306,7 +348,7 @@ export async function enrichSectionsWithVariants(sections) {
exercise_club_id: c.club_id,
exercise_created_by: c.created_by,
exercise_status: c.status,
...(isCombo ? { combination_slots: c.combination_slots || [] } : {}),
...(isCombo ? { combination_slots: c.combination_slots || [], combo_member_title_by_id: comboMemberTitleByIdForSlots(c.combination_slots || []) } : {}),
}
}),
}))