Enhance TrainingUnitSectionsEditor with improved section visibility logic
All checks were successful
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 37s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m22s

- Added logic to determine visibility of drop bands for sections in parallel phases, enhancing user experience during reordering.
- Updated the reorderBlocksImmutableWithPlanLoc function to better handle plan location adjustments based on section types and their positions.
- Improved handling of section indices for parallel streams, ensuring accurate representation of active streams and their corresponding sections.
This commit is contained in:
Lars 2026-05-15 10:14:17 +02:00
parent c2efbee4ee
commit 4902771772
2 changed files with 34 additions and 3 deletions

View File

@ -1173,8 +1173,28 @@ export default function TrainingUnitSectionsEditor({
enableParallelPhaseControls &&
pl?.phaseKind === 'parallel' &&
(pl.parallelStreamOrderIndex ?? 0) !== activeParallelStream
const firstGlobalIdxThisPhase =
parallelPhaseOrder != null
? firstSectionIndexByParallelPhase.get(parallelPhaseOrder)
: null
const firstVisibleIdxActiveStream =
parallelPhaseOrder != null && streamOrdersForParallelPhase.length
? sectionIndicesForParallelStream(
list,
parallelPhaseOrder,
activeParallelStream
)[0]
: null
const hideDropBandBeforeOrphanFirstVisible =
parallelPhaseOrder != null &&
firstVisibleIdxActiveStream != null &&
sIdx === firstVisibleIdxActiveStream &&
firstGlobalIdxThisPhase != null &&
sIdx !== firstGlobalIdxThisPhase
const showSectionDropBandBefore =
pl?.phaseKind !== 'parallel' || !hideParallelSection
(pl?.phaseKind !== 'parallel' || !hideParallelSection) &&
!hideDropBandBeforeOrphanFirstVisible
const bandActiveBefore = (bx) =>
enableSectionDragReorder &&

View File

@ -814,7 +814,19 @@ export function reorderBlocksImmutableWithPlanLoc(prev, fromI, toBeforeIdx) {
const above = insertAt > 0 ? arr[insertAt - 1] : undefined
let planLocNext = null
if (below?.planLoc?.phaseKind) {
const belowKind = below?.planLoc?.phaseKind
const aboveKind = above?.planLoc?.phaseKind
if (
belowKind === 'parallel' &&
(!above || aboveKind === 'whole_group')
) {
if (aboveKind === 'whole_group') {
planLocNext = { ...above.planLoc }
} else {
planLocNext = defaultPlanLocWholeGroup(0)
}
} else if (belowKind) {
planLocNext = { ...below.planLoc }
} else if (insertAt === arr.length) {
if (!above) {
@ -875,7 +887,6 @@ export function reorderBlockIntoParallelStreamEnd(prev, fromI, phaseOrderIndex,
insertAt = phaseIdx[phaseIdx.length - 1] + 1
}
if (fromI < insertAt) insertAt -= 1
insertAt = Math.max(0, Math.min(insertAt, arr.length))
arr.splice(insertAt, 0, { ...moved, planLoc: { ...planLocTemplate } })
return arr