Enhance TrainingUnitSectionsEditor with new section management features
Deploy Development / deploy (push) Successful in 37s
Test Suite / pytest-backend (push) Successful in 35s
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 1m7s
Deploy Development / deploy (push) Successful in 37s
Test Suite / pytest-backend (push) Successful in 35s
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 1m7s
- Introduced functions to add and manage parallel phases and sections, allowing for more flexible training unit configurations. - Implemented logic to handle the addition of whole group sections and parallel streams, improving the user experience in the editor. - Added utility functions for reordering sections and checking for content within parallel stream buckets. - Updated state management to ensure proper handling of section titles and removal of streams, enhancing overall functionality.
This commit is contained in:
1 parent
0a203aaf75
commit
2e761161ef
2 files changed
+355
-121
No files matched your search
@@ -139,7 +139,51 @@ export function sectionIndicesForParallelStream(sections, phaseOrderIndex, strea
|
||||
return out
|
||||
}
|
||||
|
||||
/** Reihenfolge innerhalb eines Stream-Buckets (globale Indizes) ändern. */
|
||||
/** Abschnitte an den angegebenen globalen Indizes entfernen (mindestens ein Abschnitt bleibt). */
|
||||
export function reorderWithoutIndices(prev, removeGlobalIndices) {
|
||||
const set = new Set(removeGlobalIndices || [])
|
||||
const next = (prev || []).filter((_, i) => !set.has(i))
|
||||
return next.length ? next : [defaultSection()]
|
||||
}
|
||||
|
||||
/**
|
||||
* Ob in den Abschnitten eines Stream-Buckets planerisch etwas steht (Übungen, Text-Anmerkungen).
|
||||
* Trennlinien-Marker (---) zählen nicht als Inhalt.
|
||||
*/
|
||||
export function parallelStreamBucketHasContent(sections, globalIndices, separatorBody = '---') {
|
||||
for (const gi of globalIndices || []) {
|
||||
const sec = (sections || [])[gi]
|
||||
if (!sec) continue
|
||||
for (const it of sec.items || []) {
|
||||
if ((it.item_type || '') === 'note') {
|
||||
const b = (it.note_body || '').trim()
|
||||
if (b && b !== separatorBody) return true
|
||||
} else {
|
||||
if (it.exercise_id) return true
|
||||
if ((it.exercise_title || '').trim()) return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/** Parallele Phase auflösen: alle Abschnitte dieser Phase werden Ganzgruppe (gleicher phaseOrderIndex). */
|
||||
export function dissolveParallelPhaseToWholeGroup(sections, phaseOrderIndex) {
|
||||
const po = Number(phaseOrderIndex) || 0
|
||||
return (sections || []).map((s) => {
|
||||
const L = s?.planLoc
|
||||
if (L?.phaseKind !== 'parallel' || (L.phaseOrderIndex ?? 0) !== po) return s
|
||||
return {
|
||||
...s,
|
||||
planLoc: {
|
||||
...defaultPlanLocWholeGroup(po),
|
||||
phaseTitle: L.phaseTitle ?? null,
|
||||
phaseGuidanceNotes: L.phaseGuidanceNotes ?? null,
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function reorderWithinBucketIndices(prev, bucketGlobalIndicesSorted, oldPos, newPos) {
|
||||
const sortedIdx = [...bucketGlobalIndicesSorted].sort((a, b) => a - b)
|
||||
if (oldPos === newPos || oldPos < 0 || newPos < 0 || oldPos >= sortedIdx.length || newPos >= sortedIdx.length) {
|
||||
|
||||
Reference in new issue
Block a user