Implement drag-and-drop functionality for parallel stream sections in TrainingUnitSectionsEditor
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m8s
Deploy Development / deploy (push) Successful in 42s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 1s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m8s
- Added new CSS styles for visual feedback during drag-and-drop operations, enhancing user experience. - Introduced logic to manage section drops into parallel streams, allowing for intuitive reordering of sections. - Implemented utility functions to facilitate the movement of sections within parallel streams, ensuring proper plan location adjustments. - Updated the TrainingUnitSectionsEditor component to utilize the new drag-and-drop features, improving overall functionality and usability.
This commit is contained in:
1 parent
514b64682c
commit
c2efbee4ee
3 files changed
+249
-12
No files matched your search
@@ -842,6 +842,57 @@ export function reorderBlocksImmutableWithPlanLoc(prev, fromI, toBeforeIdx) {
|
||||
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.
|
||||
*/
|
||||
export function reorderBlockIntoParallelStreamEnd(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 planLocTemplate
|
||||
|
||||
if (streamIdx.length) {
|
||||
const last = Math.max(...streamIdx)
|
||||
planLocTemplate = { ...arr[last].planLoc }
|
||||
insertAt = last + 1
|
||||
} else {
|
||||
const phaseIdx = indicesOfParallelPhase(arr, po)
|
||||
if (!phaseIdx.length) return prev
|
||||
const ref = arr[phaseIdx[phaseIdx.length - 1]]
|
||||
planLocTemplate = {
|
||||
...ref.planLoc,
|
||||
parallelStreamOrderIndex: so,
|
||||
streamTitle: null,
|
||||
streamNotes: null,
|
||||
streamAssignedTrainerProfileIds: null,
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
/** Globales insertBeforeIndex, um einen Abschnitt hinter den letzten des Streams einzufügen (z. B. Rahmen-Slots). */
|
||||
export function globalInsertBeforeIndexForParallelStreamEnd(sections, phaseOrderIndex, streamOrderIndex) {
|
||||
const arr = sections || []
|
||||
const po = Number(phaseOrderIndex) || 0
|
||||
const so = Number(streamOrderIndex) || 0
|
||||
const streamIdx = sectionIndicesForParallelStream(arr, po, so)
|
||||
if (streamIdx.length) return Math.max(...streamIdx) + 1
|
||||
const phaseIdx = indicesOfParallelPhase(arr, po)
|
||||
if (!phaseIdx.length) return arr.length
|
||||
return Math.max(...phaseIdx) + 1
|
||||
}
|
||||
|
||||
/** Alle globalen Indizes einer parallelen Phase (alle Streams), sortiert. */
|
||||
export function indicesOfParallelPhase(sections, phaseOrderIndex) {
|
||||
const po = Number(phaseOrderIndex) || 0
|
||||
|
||||
Reference in new issue
Block a user