feat(training-planning): enhance training module integration and UI
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 39s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 56s
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 39s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 11s
Test Suite / playwright-tests (push) Successful in 56s
- Introduced a new function to handle optional source training module IDs, ensuring proper validation and integration. - Updated the backend to include source training module ID and title in section items, allowing for better tracking of module origins. - Enhanced the frontend to display module bands in the Training Unit Sections Editor, improving user experience by indicating the source of exercises and notes. - Added functionality to insert training modules at specified positions within sections, providing users with more control over their training plans. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
c1243651bb
commit
e41908af73
6 files changed
+385
-83
No files matched your search
@@ -10,6 +10,12 @@ import {
|
||||
const DND_TU_ITEM = 'application/x-shinkan-training-unit-item'
|
||||
const DND_TU_SECTION = 'application/x-shinkan-training-section-v1'
|
||||
|
||||
function normalizedPlanningModuleChainId(raw) {
|
||||
if (raw == null || raw === '') return null
|
||||
const n = typeof raw === 'number' ? raw : Number(raw)
|
||||
return Number.isFinite(n) && n >= 1 ? n : null
|
||||
}
|
||||
|
||||
function dtHasType(e, mime) {
|
||||
const t = e?.dataTransfer?.types
|
||||
if (!t || !mime) return false
|
||||
@@ -521,15 +527,29 @@ export default function TrainingUnitSectionsEditor({
|
||||
}
|
||||
: {}
|
||||
|
||||
const prevIt = iIdx > 0 ? sec.items[iIdx - 1] : null
|
||||
const curMn = normalizedPlanningModuleChainId(it.source_training_module_id)
|
||||
const showModuleBand =
|
||||
curMn != null && curMn !== normalizedPlanningModuleChainId(prevIt?.source_training_module_id)
|
||||
const modBandTitle =
|
||||
(it.source_module_title || '').trim() ||
|
||||
(curMn != null ? `Modul #${curMn}` : '')
|
||||
|
||||
if (it.item_type === 'note') {
|
||||
const notePv = truncatePreview(it.note_body || '', 260)
|
||||
const noteHasText = Boolean((it.note_body || '').trim())
|
||||
return (
|
||||
<div
|
||||
key={`note-${sIdx}-${iIdx}`}
|
||||
className={`${rowCommon} tu-item-row--note`}
|
||||
{...dndRowProps}
|
||||
>
|
||||
<Fragment key={`it-${sIdx}-${iIdx}`}>
|
||||
{showModuleBand ? (
|
||||
<div
|
||||
className="tu-planning-module-band"
|
||||
role="group"
|
||||
aria-label={`Baustein ${modBandTitle}`}
|
||||
>
|
||||
Baustein: {modBandTitle}
|
||||
</div>
|
||||
) : null}
|
||||
<div className={`${rowCommon} tu-item-row--note`} {...dndRowProps}>
|
||||
{enableItemDragReorder ? (
|
||||
<span
|
||||
className="tu-row-grip"
|
||||
@@ -596,6 +616,7 @@ export default function TrainingUnitSectionsEditor({
|
||||
✗
|
||||
</button>
|
||||
</div>
|
||||
</Fragment>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -611,11 +632,17 @@ export default function TrainingUnitSectionsEditor({
|
||||
: Number(it.exercise_variant_id)
|
||||
|
||||
return (
|
||||
<div
|
||||
key={`ex-${sIdx}-${iIdx}`}
|
||||
className={`${rowCommon} tu-item-row--exercise`}
|
||||
{...dndRowProps}
|
||||
>
|
||||
<Fragment key={`it-${sIdx}-${iIdx}`}>
|
||||
{showModuleBand ? (
|
||||
<div
|
||||
className="tu-planning-module-band"
|
||||
role="group"
|
||||
aria-label={`Baustein ${modBandTitle}`}
|
||||
>
|
||||
Baustein: {modBandTitle}
|
||||
</div>
|
||||
) : null}
|
||||
<div className={`${rowCommon} tu-item-row--exercise`} {...dndRowProps}>
|
||||
<div className="tu-item-row__mainline">
|
||||
{enableItemDragReorder ? (
|
||||
<span
|
||||
@@ -793,6 +820,7 @@ export default function TrainingUnitSectionsEditor({
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</Fragment>
|
||||
)
|
||||
})}
|
||||
|
||||
|
||||
Reference in new issue
Block a user