Parlellsession- Plan #35

Merged
Lars merged 34 commits from develop into main 2026-05-15 22:04:53 +02:00
2 changed files with 45 additions and 1 deletions
Showing only changes of commit 5e5350d5ac - Show all commits

View File

@ -27,6 +27,18 @@ function storageStepKey(unitId, mergedPicks) {
return `sj_coach_step_${unitId}_${coachBranchPicksStepStorageSuffix(mergedPicks)}` return `sj_coach_step_${unitId}_${coachBranchPicksStepStorageSuffix(mergedPicks)}`
} }
function clearCoachStepStorageForUnit(unitId) {
const pref = `sj_coach_step_${unitId}_`
try {
for (let i = sessionStorage.length - 1; i >= 0; i -= 1) {
const k = sessionStorage.key(i)
if (k && k.startsWith(pref)) sessionStorage.removeItem(k)
}
} catch {
/* ignore */
}
}
function storageDeltasKey(unitId) { function storageDeltasKey(unitId) {
return `sj_coach_deltas_${unitId}` return `sj_coach_deltas_${unitId}`
} }
@ -614,9 +626,12 @@ export default function TrainingCoachPage() {
sessionStorage.removeItem(storageDeltasKey(idNum)) sessionStorage.removeItem(storageDeltasKey(idNum))
sessionStorage.removeItem(storageDebriefKey(idNum)) sessionStorage.removeItem(storageDebriefKey(idNum))
sessionStorage.removeItem(coachBranchPicksStorageKey(idNum)) sessionStorage.removeItem(coachBranchPicksStorageKey(idNum))
clearCoachStepStorageForUnit(idNum)
} catch { } catch {
/* ignore */ /* ignore */
} }
setSearchParams({}, { replace: true })
setStep(0)
setDeltas({}) setDeltas({})
setBranchPicks({}) setBranchPicks({})
setStreamChoiceHint(null) setStreamChoiceHint(null)

View File

@ -5,6 +5,7 @@
import { import {
buildPlanPayloadForSave, buildPlanPayloadForSave,
cloneJsonSerializablePlanningProfile, cloneJsonSerializablePlanningProfile,
defaultPlanLocWholeGroup,
inheritPlanLocForPhasedSave, inheritPlanLocForPhasedSave,
phaseRunsFromSections, phaseRunsFromSections,
sectionIndicesForParallelStream, sectionIndicesForParallelStream,
@ -94,6 +95,16 @@ function planLocBySectionIdFromPhases(phases) {
return byId return byId
} }
function maxPhaseOrderIndexFromNestedPhases(phases) {
let m = -1
if (!Array.isArray(phases)) return m
for (const ph of phases) {
const po = Number(ph.order_index ?? ph.orderIndex ?? 0)
if (Number.isFinite(po)) m = Math.max(m, po)
}
return m
}
export function sectionsWithPlanLocForDisplay(unit) { export function sectionsWithPlanLocForDisplay(unit) {
const sorted = sortedSections(unit) const sorted = sortedSections(unit)
const byId = planLocBySectionIdFromPhases(unit?.phases) const byId = planLocBySectionIdFromPhases(unit?.phases)
@ -105,7 +116,25 @@ export function sectionsWithPlanLocForDisplay(unit) {
if (s.planLoc && s.planLoc.phaseKind) return s if (s.planLoc && s.planLoc.phaseKind) return s
return { ...s } return { ...s }
}) })
return inheritPlanLocForPhasedSave(merged) const inherited = inheritPlanLocForPhasedSave(merged)
const maxPhPo = maxPhaseOrderIndexFromNestedPhases(unit?.phases)
return inherited.map((s) => {
const sid = s.id != null ? Number(s.id) : NaN
if (!Number.isFinite(sid) || byId.has(sid)) return s
const pl = s.planLoc
if (pl?.phaseKind === 'parallel') {
const po = maxPhPo >= 0 ? maxPhPo + 1 : 0
return {
...s,
planLoc: {
...defaultPlanLocWholeGroup(po),
phaseTitle: pl.phaseTitle ?? null,
phaseGuidanceNotes: pl.phaseGuidanceNotes ?? null,
},
}
}
return s
})
} }
/** /**