Implement visual enhancements and logic for section drop bands in TrainingUnitSectionsEditor
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m20s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m20s
- Added CSS styles for visual representation of section drop bands, differentiating between split and whole group regions. - Introduced a new function to determine the appropriate drop band class based on section types, improving user experience during section reordering. - Enhanced drag-and-drop functionality to support parallel phase management, allowing for more intuitive section placement within the editor. - Updated utility functions to handle the movement of parallel phase runs, ensuring proper plan location adjustments during reordering.
This commit is contained in:
1 parent
a0a0be8bef
commit
514b64682c
3 files changed
+211
-13
No files matched your search
@@ -26,6 +26,9 @@ import {
|
||||
reorderBlocksImmutableWithPlanLoc,
|
||||
movePhaseRunUpByPhaseOrder,
|
||||
movePhaseRunDownByPhaseOrder,
|
||||
moveParallelPhaseRunToInsertBefore,
|
||||
afterSectionReorderParallelGuard,
|
||||
indicesOfParallelPhase,
|
||||
exerciseRow,
|
||||
noteRow,
|
||||
sectionPlannedMinutes,
|
||||
@@ -75,6 +78,31 @@ function dtHasType(e, mime) {
|
||||
return Array.from(t).includes(mime)
|
||||
}
|
||||
|
||||
/** Visuelle Zuordnung der Einfügezeile zu Split- vs. Ganzgruppen-Bereich (nur Darstellung). */
|
||||
function sectionDropBandRegionClass(sections, beforeIdx, enableParallel) {
|
||||
if (!enableParallel) return ''
|
||||
const n = sections?.length ?? 0
|
||||
const below = beforeIdx < n ? sections[beforeIdx] : null
|
||||
const above = beforeIdx > 0 ? sections[beforeIdx - 1] : null
|
||||
const po = (s) => s?.planLoc?.phaseOrderIndex ?? 0
|
||||
const aboveP = above?.planLoc?.phaseKind === 'parallel'
|
||||
const belowP = below?.planLoc?.phaseKind === 'parallel'
|
||||
const aboveW = above?.planLoc?.phaseKind === 'whole_group'
|
||||
const belowW = below?.planLoc?.phaseKind === 'whole_group'
|
||||
|
||||
if (aboveP && belowP && po(above) === po(below)) {
|
||||
return ' tu-section-dropband--region-split'
|
||||
}
|
||||
if (aboveW && belowW) return ' tu-section-dropband--region-whole'
|
||||
if (aboveP && belowW) return ' tu-section-dropband--region-split-to-whole'
|
||||
if (aboveW && belowP) return ' tu-section-dropband--region-whole-to-split'
|
||||
if (!above && belowP) return ' tu-section-dropband--region-split'
|
||||
if (!below && aboveP) return ' tu-section-dropband--region-split-to-whole'
|
||||
if (!above && belowW) return ' tu-section-dropband--region-whole'
|
||||
if (!below && aboveW) return ' tu-section-dropband--region-whole'
|
||||
return ' tu-section-dropband--region-neutral'
|
||||
}
|
||||
|
||||
function truncatePreview(text, max = 160) {
|
||||
const t = (text || '').replace(/\s+/g, ' ').trim()
|
||||
if (t.length <= max) return t
|
||||
@@ -298,7 +326,13 @@ export default function TrainingUnitSectionsEditor({
|
||||
streamAssignedTrainerProfileIds: null,
|
||||
}
|
||||
const base = defaultSection(`Abschnitt ${prev.length + 1}`)
|
||||
return [...prev, { ...base, planLoc: tmpl }]
|
||||
const inPhaseIdx = indicesOfParallelPhase(prev, po)
|
||||
const insertAfter = inPhaseIdx.length ? Math.max(...inPhaseIdx) : prev.length - 1
|
||||
return [
|
||||
...prev.slice(0, insertAfter + 1),
|
||||
{ ...base, planLoc: tmpl },
|
||||
...prev.slice(insertAfter + 1),
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
@@ -633,6 +667,25 @@ export default function TrainingUnitSectionsEditor({
|
||||
|
||||
const clearSectionDnD = () => setDropSectionBand(null)
|
||||
|
||||
const onParallelPhaseDragStart = (e, phaseOrderIndex) => {
|
||||
if (!enableSectionDragReorder || !enableParallelPhaseControls) return
|
||||
e.stopPropagation()
|
||||
try {
|
||||
e.dataTransfer.effectAllowed = 'move'
|
||||
e.dataTransfer.setData(
|
||||
DND_TU_SECTION,
|
||||
JSON.stringify({
|
||||
fromSlot: sectionToSlot,
|
||||
fromSectionIdx: null,
|
||||
phaseRunMove: { phaseOrderIndex },
|
||||
})
|
||||
)
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
setDropSectionBand(null)
|
||||
}
|
||||
|
||||
const onSectionDragStart = (e, sIdx) => {
|
||||
if (!enableSectionDragReorder) return
|
||||
e.stopPropagation()
|
||||
@@ -683,7 +736,19 @@ export default function TrainingUnitSectionsEditor({
|
||||
return
|
||||
}
|
||||
const fromSi = data.fromSectionIdx
|
||||
const phaseRunMove = data.phaseRunMove
|
||||
const fromSlot = typeof data.fromSlot === 'number' ? data.fromSlot : -1
|
||||
|
||||
if (phaseRunMove != null && phaseRunMove.phaseOrderIndex != null) {
|
||||
patch((prev) => {
|
||||
const po = Number(phaseRunMove.phaseOrderIndex) || 0
|
||||
let next = moveParallelPhaseRunToInsertBefore(prev, po, insertBeforeIdx)
|
||||
if (enableParallelPhaseControls) next = afterSectionReorderParallelGuard(prev, next)
|
||||
return next
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (typeof fromSi !== 'number') return
|
||||
|
||||
if (
|
||||
@@ -701,10 +766,11 @@ export default function TrainingUnitSectionsEditor({
|
||||
}
|
||||
|
||||
patch((prev) => {
|
||||
if (enableParallelPhaseControls) {
|
||||
return reorderBlocksImmutableWithPlanLoc(prev, fromSi, insertBeforeIdx)
|
||||
}
|
||||
return reorderBlocksImmutable(prev, fromSi, insertBeforeIdx)
|
||||
let next = enableParallelPhaseControls
|
||||
? reorderBlocksImmutableWithPlanLoc(prev, fromSi, insertBeforeIdx)
|
||||
: reorderBlocksImmutable(prev, fromSi, insertBeforeIdx)
|
||||
if (enableParallelPhaseControls) next = afterSectionReorderParallelGuard(prev, next)
|
||||
return next
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1048,7 +1114,11 @@ export default function TrainingUnitSectionsEditor({
|
||||
<Fragment key={`secFrag-${sIdx}`}>
|
||||
{enableSectionDragReorder ? (
|
||||
<div
|
||||
className={'tu-section-dropband' + (bandActiveBefore(sIdx) ? ' tu-section-dropband--active' : '')}
|
||||
className={
|
||||
'tu-section-dropband' +
|
||||
sectionDropBandRegionClass(list, sIdx, enableParallelPhaseControls) +
|
||||
(bandActiveBefore(sIdx) ? ' tu-section-dropband--active' : '')
|
||||
}
|
||||
title="Abschnitt hier einfügen"
|
||||
onDragOver={(e) => {
|
||||
if (!enableSectionDragReorder) return
|
||||
@@ -1083,6 +1153,19 @@ export default function TrainingUnitSectionsEditor({
|
||||
marginBottom: '10px',
|
||||
}}
|
||||
>
|
||||
{enableSectionDragReorder ? (
|
||||
<span
|
||||
className="tu-sec-drag-grip"
|
||||
draggable
|
||||
onDragStart={(e) => onParallelPhaseDragStart(e, parallelPhaseOrder)}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-label="Parallele Phase ziehen"
|
||||
title="Gesamte parallele Phase an neue Planposition ziehen"
|
||||
>
|
||||
<GripVertical size={16} strokeWidth={2} aria-hidden />
|
||||
</span>
|
||||
) : null}
|
||||
<label
|
||||
className="form-label"
|
||||
style={{ fontSize: '0.78rem', marginBottom: 0, flex: '0 0 auto' }}
|
||||
@@ -2022,6 +2105,7 @@ export default function TrainingUnitSectionsEditor({
|
||||
<div
|
||||
className={
|
||||
'tu-section-dropband tu-section-dropband--end' +
|
||||
sectionDropBandRegionClass(list, list.length, enableParallelPhaseControls) +
|
||||
(dropSectionBand &&
|
||||
dropSectionBand.slot === sectionToSlot &&
|
||||
dropSectionBand.beforeIdx === list.length
|
||||
|
||||
Reference in new issue
Block a user