SplitSession auch für Rahmenprogramme #36

Merged
Lars merged 11 commits from develop into main 2026-05-16 09:02:51 +02:00
Showing only changes of commit 79e748b470 - Show all commits

View File

@ -721,20 +721,47 @@ function stripPlanLoc(sec) {
return rest return rest
} }
export function inheritPlanLocForPhasedSave(sections) { function phaseIndexToInt(v, fallback = 0) {
let prev = { if (v === null || v === undefined || v === '') return fallback
phaseKind: 'whole_group', const n = typeof v === 'number' ? v : Number(v)
phaseOrderIndex: 0, return Number.isFinite(n) ? n : fallback
parallelStreamOrderIndex: null, }
phaseTitle: null,
phaseGuidanceNotes: null, /**
streamTitle: null, * planLoc für Phasen-PUT kanonisieren (Großschreibung, numerische Indizes).
streamNotes: null, * Verhindert u. a. abgebrochene Phasen-Runs bei "0" !== 0 und falsche whole_group-Zweige.
streamAssignedTrainerProfileIds: null, */
function canonicalPlanLocForPhasedSave(pl) {
if (!pl || typeof pl !== 'object') return null
const rawKind = String(pl.phaseKind || '').toLowerCase().trim()
let kind = rawKind === 'parallel' || rawKind === 'whole_group' ? rawKind : null
if (
!kind &&
pl.parallelStreamOrderIndex != null &&
pl.parallelStreamOrderIndex !== ''
) {
kind = 'parallel'
} }
if (!kind) return null
const phaseOrderIndex = phaseIndexToInt(pl.phaseOrderIndex, 0)
let parallelStreamOrderIndex = null
if (kind === 'parallel') {
parallelStreamOrderIndex = phaseIndexToInt(pl.parallelStreamOrderIndex, 0)
}
return {
...pl,
phaseKind: kind,
phaseOrderIndex,
parallelStreamOrderIndex,
}
}
export function inheritPlanLocForPhasedSave(sections) {
let prev = { ...defaultPlanLocWholeGroup(0) }
return (sections || []).map((s) => { return (sections || []).map((s) => {
if (s?.planLoc && s.planLoc.phaseKind) { const canon = canonicalPlanLocForPhasedSave(s?.planLoc)
prev = { ...s.planLoc } if (canon) {
prev = { ...canon }
return { ...s, planLoc: prev } return { ...s, planLoc: prev }
} }
return { ...s, planLoc: { ...prev } } return { ...s, planLoc: { ...prev } }
@ -1127,7 +1154,7 @@ function buildPhasesPayloadFromFlat(sections) {
*/ */
export function buildPlanPayloadForSave(sections) { export function buildPlanPayloadForSave(sections) {
const list = Array.isArray(sections) ? sections : [] const list = Array.isArray(sections) ? sections : []
const anyPhased = list.some((s) => s && s.planLoc && s.planLoc.phaseKind) const anyPhased = list.some((s) => s && canonicalPlanLocForPhasedSave(s.planLoc) != null)
if (!anyPhased) { if (!anyPhased) {
return { sections: buildSectionsPayload(list) } return { sections: buildSectionsPayload(list) }
} }