Enhance TrainingCoachPage and trainingPlanUtils with split rejoin functionality
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m8s
Deploy Development / deploy (push) Successful in 39s
Test Suite / pytest-backend (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m8s
- Updated TrainingCoachPage to implement a prompt for users to rejoin parallel phases, improving user guidance during training sessions. - Refactored step management logic to ensure accurate navigation through the timeline, utilizing safe step calculations. - Introduced new utility functions in trainingPlanUtils for building save payloads and determining when to prompt for split rejoin, optimizing data handling. - Enhanced state management for split rejoin prompts, ensuring a seamless user experience during training.
This commit is contained in:
1 parent
352237bbb9
commit
73ac2218c7
2 files changed
+208
-50
No files matched your search
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
buildPlanPayloadForSave,
|
||||
cloneJsonSerializablePlanningProfile,
|
||||
inheritPlanLocForPhasedSave,
|
||||
phaseRunsFromSections,
|
||||
@@ -455,6 +456,40 @@ export function durationOverridesMapFromDeltas(unit, deltas) {
|
||||
return out
|
||||
}
|
||||
|
||||
/** PUT-Body für Coach-Speichern: `phases` wenn Plan Phasen hat, sonst `sections` (wie Planungseditor). */
|
||||
export function buildCoachSavePlanPayload(unit, durationOverridesByItemId = {}) {
|
||||
const withLoc = sectionsWithPlanLocForDisplay(unit)
|
||||
const withDur = withLoc.map((sec) => ({
|
||||
...sec,
|
||||
items: sortedItems(sec).map((it) => {
|
||||
if (it.item_type !== 'exercise' || it.id == null) return it
|
||||
const o = durationOverridesByItemId[String(it.id)]
|
||||
const av = o?.actual_duration_min
|
||||
if (av !== undefined && av !== '' && av !== null && Number.isFinite(Number(av))) {
|
||||
return { ...it, actual_duration_min: Number(av) }
|
||||
}
|
||||
return it
|
||||
}),
|
||||
}))
|
||||
return buildPlanPayloadForSave(withDur)
|
||||
}
|
||||
|
||||
/**
|
||||
* Nach dem letzten Block eines Streams: Rückfrage, wenn die parallele Phase mehrere Gruppen hat.
|
||||
*/
|
||||
export function coachShouldPromptSplitRejoin(unit, lastTimelineEntry) {
|
||||
const rm = lastTimelineEntry?.runMeta
|
||||
if (!rm || rm.kind !== 'parallel' || rm.streamOrder == null) return null
|
||||
const model = buildPlanRunViewModelFromSections(sectionsWithPlanLocForDisplay(unit))
|
||||
const run = model.runs.find((r) => r.kind === 'parallel' && r.phaseOrderIndex === rm.phaseOrderIndex)
|
||||
if (!run?.streams || run.streams.length <= 1) return null
|
||||
return {
|
||||
phaseOrderIndex: run.phaseOrderIndex,
|
||||
phaseTitle: run.phaseTitle,
|
||||
streams: run.streams,
|
||||
}
|
||||
}
|
||||
|
||||
export function summarizeTimelineEntry(ent) {
|
||||
if (!ent) return ''
|
||||
if (ent.entryKind === COACH_ENTRY_BRANCH_GATE) {
|
||||
|
||||
Reference in new issue
Block a user