Enhance section movement functionality in TrainingUnitSectionsEditor
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 38s
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 1m8s
Test Suite / pytest-backend (pull_request) Successful in 34s
Test Suite / lint-backend (pull_request) Successful in 0s
Test Suite / build-frontend (pull_request) Successful in 12s
Test Suite / k6 /health Baseline (pull_request) Successful in 33s
Test Suite / playwright-tests (pull_request) Successful in 1m8s

- Updated the onMoveSectionsAcrossSlots function to support additional parameters for improved section movement across slots, including handling for parallel phase indices and insertion points.
- Refined logic for moving sections between slots, ensuring proper handling of parallel streams and enhancing the overall section management experience.
This commit is contained in:
Lars committed 2026-05-16 08:34:30 +02:00
1 parent 7d2661a8e8
commit 8c07cf36ee
2 files changed
+156 -16

No files matched your search

@@ -245,7 +245,7 @@ function reorderBlocksImmutable(blocks, fromI, toBeforeIdx) {
/**
* @param {(updater: (prev: Array) => Array) => void} props.onSectionsChange — wie React setState
* @param {(p: { fromSlot: number, fromSectionIdx: number, toSlot: number, toSectionIdx: number, toParallelStream?: { po: number, so: number } }) => void} [props.onMoveSectionsAcrossSlots] — Rahmenprogramm: Abschnitt zwischen Slots verschieben
* @param {(p: { fromSlot: number, fromSectionIdx?: number, toSlot: number, toSectionIdx: number, toParallelStream?: { po: number, so: number }, parallelPhaseRunOrderIndex?: number, insertBeforeParallelInTarget?: number, firstInParallelStreamInTarget?: { po: number, so: number } }) => void} [props.onMoveSectionsAcrossSlots] — Rahmenprogramm: Abschnitt(e) zwischen Slots verschieben
*/
export default function TrainingUnitSectionsEditor({
sections,
@@ -807,6 +807,22 @@ export default function TrainingUnitSectionsEditor({
if (parsed.kind === 'phaseRun') {
const dragPo = Number(parsed.phaseRunMove.phaseOrderIndex) || 0
if (dragPo === targetPo) return
const fs = typeof parsed.fromSlot === 'number' ? parsed.fromSlot : -1
if (
typeof onMoveSectionsAcrossSlots === 'function' &&
sectionToSlot >= 0 &&
fs >= 0 &&
fs !== sectionToSlot
) {
const ins = indicesOfParallelPhase(list, targetPo)[0] ?? list.length
onMoveSectionsAcrossSlots({
fromSlot: fs,
toSlot: sectionToSlot,
toSectionIdx: ins,
parallelPhaseRunOrderIndex: dragPo,
})
return
}
patch((prev) => {
const idxs = indicesOfParallelPhase(prev, targetPo)
const fg = idxs.length ? idxs[0] : -1
@@ -818,7 +834,17 @@ export default function TrainingUnitSectionsEditor({
return
}
if (parsed.kind === 'crossSlot') return
if (parsed.kind === 'crossSlot') {
if (typeof onMoveSectionsAcrossSlots !== 'function') return
onMoveSectionsAcrossSlots({
fromSlot: parsed.fromSlot,
fromSectionIdx: parsed.fromSi,
toSlot: sectionToSlot,
toSectionIdx: 0,
insertBeforeParallelInTarget: targetPo,
})
return
}
const { fromSi } = parsed
patch((prev) => {
@@ -854,6 +880,23 @@ export default function TrainingUnitSectionsEditor({
if (parsed.kind === 'phaseRun') {
const dragPo = Number(parsed.phaseRunMove.phaseOrderIndex) || 0
if (dragPo === targetPo) return
const fs = typeof parsed.fromSlot === 'number' ? parsed.fromSlot : -1
if (
typeof onMoveSectionsAcrossSlots === 'function' &&
sectionToSlot >= 0 &&
fs >= 0 &&
fs !== sectionToSlot
) {
const si = sectionIndicesForParallelStream(list, targetPo, targetSo)
const ins = si.length ? si[0] : indicesOfParallelPhase(list, targetPo)[0] ?? list.length
onMoveSectionsAcrossSlots({
fromSlot: fs,
toSlot: sectionToSlot,
toSectionIdx: ins,
parallelPhaseRunOrderIndex: dragPo,
})
return
}
patch((prev) => {
const idxs = indicesOfParallelPhase(prev, targetPo)
const fg = idxs.length ? idxs[0] : -1
@@ -865,7 +908,17 @@ export default function TrainingUnitSectionsEditor({
return
}
if (parsed.kind === 'crossSlot') return
if (parsed.kind === 'crossSlot') {
if (typeof onMoveSectionsAcrossSlots !== 'function') return
onMoveSectionsAcrossSlots({
fromSlot: parsed.fromSlot,
fromSectionIdx: parsed.fromSi,
toSlot: sectionToSlot,
toSectionIdx: 0,
firstInParallelStreamInTarget: { po: targetPo, so: targetSo },
})
return
}
const { fromSi } = parsed
patch((prev) => {
@@ -898,9 +951,24 @@ export default function TrainingUnitSectionsEditor({
const fromSlot = typeof data.fromSlot === 'number' ? data.fromSlot : -1
if (phaseRunMove != null && phaseRunMove.phaseOrderIndex != null) {
const po = Number(phaseRunMove.phaseOrderIndex) || 0
if (
typeof onMoveSectionsAcrossSlots === 'function' &&
sectionToSlot >= 0 &&
fromSlot >= 0 &&
fromSlot !== sectionToSlot
) {
onMoveSectionsAcrossSlots({
fromSlot,
toSlot: sectionToSlot,
toSectionIdx: insertBeforeIdx,
parallelPhaseRunOrderIndex: po,
})
return
}
patch((prev) => {
const po = Number(phaseRunMove.phaseOrderIndex) || 0
let next = moveParallelPhaseRunToInsertBefore(prev, po, insertBeforeIdx)
const poLocal = Number(phaseRunMove.phaseOrderIndex) || 0
let next = moveParallelPhaseRunToInsertBefore(prev, poLocal, insertBeforeIdx)
if (enableParallelPhaseControls) next = afterSectionReorderParallelGuard(prev, next)
return next
})