Refactor TrainingUnitSectionsEditor to support new parallel stream functionality
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 41s
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 40s
Test Suite / pytest-backend (push) Successful in 41s
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
- Renamed functions and parameters to clarify the handling of sections within parallel streams, enhancing code readability. - Updated drag-and-drop event handlers to accommodate additional parameters for managing sections in parallel streams. - Introduced a new utility function to reorder sections as the first entry in a parallel stream, improving section management. - Enhanced the visual representation of drop zones for sections, ensuring a better user experience during reordering operations.
This commit is contained in:
1 parent
72e8f31cff
commit
3005f1cb3e
2 files changed
+97
-23
No files matched your search
@@ -905,6 +905,58 @@ export function reorderSectionAsFirstInParallelPhase(prev, fromI, phaseOrderInde
|
||||
return arr
|
||||
}
|
||||
|
||||
/** Abschnitt als ersten Eintrag eines parallelen Streams setzen (planLoc wie erster Abschnitt dieses Streams, bzw. leerer Stream wie reorderBlockIntoParallelStreamEnd). */
|
||||
export function reorderSectionAsFirstInParallelStream(prev, fromI, phaseOrderIndex, streamOrderIndex) {
|
||||
const po = Number(phaseOrderIndex) || 0
|
||||
const so = Number(streamOrderIndex) || 0
|
||||
const len = prev?.length ?? 0
|
||||
if (fromI < 0 || fromI >= len) return prev
|
||||
|
||||
const arr = [...prev]
|
||||
const [moved] = arr.splice(fromI, 1)
|
||||
|
||||
const streamIdx = sectionIndicesForParallelStream(arr, po, so)
|
||||
let insertAt
|
||||
let headTpl
|
||||
let skipFromIAdjust = false
|
||||
|
||||
if (streamIdx.length) {
|
||||
const first = Math.min(...streamIdx)
|
||||
headTpl = { ...arr[first].planLoc }
|
||||
insertAt = first
|
||||
} else {
|
||||
const phaseIdx = indicesOfParallelPhase(arr, po)
|
||||
if (!phaseIdx.length) {
|
||||
const ml = moved?.planLoc
|
||||
if (ml?.phaseKind !== 'parallel' || (ml.phaseOrderIndex ?? 0) !== po) return prev
|
||||
headTpl = {
|
||||
...ml,
|
||||
parallelStreamOrderIndex: so,
|
||||
streamTitle: null,
|
||||
streamNotes: null,
|
||||
streamAssignedTrainerProfileIds: null,
|
||||
}
|
||||
insertAt = Math.min(fromI, arr.length)
|
||||
skipFromIAdjust = true
|
||||
} else {
|
||||
const ref = arr[phaseIdx[phaseIdx.length - 1]]
|
||||
headTpl = {
|
||||
...ref.planLoc,
|
||||
parallelStreamOrderIndex: so,
|
||||
streamTitle: null,
|
||||
streamNotes: null,
|
||||
streamAssignedTrainerProfileIds: null,
|
||||
}
|
||||
insertAt = phaseIdx[phaseIdx.length - 1] + 1
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipFromIAdjust && fromI < insertAt) insertAt -= 1
|
||||
insertAt = Math.max(0, Math.min(insertAt, arr.length))
|
||||
arr.splice(insertAt, 0, { ...moved, planLoc: { ...headTpl } })
|
||||
return arr
|
||||
}
|
||||
|
||||
/**
|
||||
* Abschnitt ans Ende eines parallelen Streams setzen (planLoc wie dieser Stream).
|
||||
* Leerer Stream: Einfügen hinter den letzten Abschnitt der zugehörigen parallelen Phase, planLoc vom Referenz-Abschnitt mit angepasstem streamIndex.
|
||||
|
||||
Reference in new issue
Block a user