Enhance Training Framework Programs with Session Duration and Filtering Features
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 39s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m29s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 39s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m29s
- Added SQL aggregations for session duration (min/max) and goal titles in the training framework programs query. - Updated the TrainingPlanningFrameworkImportModal component to include filtering options for focus areas, training types, and target groups. - Implemented session duration display in the TrainingFrameworkProgramsListPage, improving user visibility of program details. - Introduced utility functions for formatting session duration ranges, enhancing the overall user experience in training planning.
This commit is contained in:
1 parent
5a8a212f40
commit
9353909fda
7 files changed
+450
-14
No files matched your search
@@ -1,4 +1,10 @@
|
||||
import React from 'react'
|
||||
import React, { useMemo, useState } from 'react'
|
||||
import {
|
||||
filterFrameworkPrograms,
|
||||
frameworkProgramOptionLabel,
|
||||
frameworkSessionDurationLabel,
|
||||
} from '../../utils/frameworkProgramListHelpers'
|
||||
import { formatDurationDisplay } from '../../utils/trainingDurationUtils'
|
||||
|
||||
/**
|
||||
* Modal: geplante Einheiten aus einem Trainingsrahmenprogramm (Blueprint-Slots) erzeugen.
|
||||
@@ -6,6 +12,9 @@ import React from 'react'
|
||||
export default function TrainingPlanningFrameworkImportModal({
|
||||
open,
|
||||
frameworkProgramsList,
|
||||
catalogFocusAreas = [],
|
||||
catalogTrainingTypes = [],
|
||||
catalogTargetGroups = [],
|
||||
fwImportProgramId,
|
||||
onProgramChange,
|
||||
fwImportLoading,
|
||||
@@ -23,6 +32,41 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
onSubmit,
|
||||
onClose,
|
||||
}) {
|
||||
const [filterQuery, setFilterQuery] = useState('')
|
||||
const [filterFocusIds, setFilterFocusIds] = useState([])
|
||||
const [filterTypeIds, setFilterTypeIds] = useState([])
|
||||
const [filterTargetGroupIds, setFilterTargetGroupIds] = useState([])
|
||||
const [filterDurationMin, setFilterDurationMin] = useState('')
|
||||
|
||||
const filteredPrograms = useMemo(
|
||||
() =>
|
||||
filterFrameworkPrograms(frameworkProgramsList, {
|
||||
query: filterQuery,
|
||||
focusAreaIds: filterFocusIds,
|
||||
trainingTypeIds: filterTypeIds,
|
||||
targetGroupIds: filterTargetGroupIds,
|
||||
durationTargetMin: filterDurationMin === '' ? null : parseInt(filterDurationMin, 10),
|
||||
}),
|
||||
[
|
||||
frameworkProgramsList,
|
||||
filterQuery,
|
||||
filterFocusIds,
|
||||
filterTypeIds,
|
||||
filterTargetGroupIds,
|
||||
filterDurationMin,
|
||||
]
|
||||
)
|
||||
|
||||
const selectedProgramSummary = useMemo(() => {
|
||||
if (!fwImportProgramId) return null
|
||||
return (frameworkProgramsList || []).find((p) => String(p.id) === String(fwImportProgramId))
|
||||
}, [frameworkProgramsList, fwImportProgramId])
|
||||
|
||||
const toggleId = (list, setList, id) => {
|
||||
const s = String(id)
|
||||
setList((prev) => (prev.includes(s) ? prev.filter((x) => x !== s) : [...prev, s]))
|
||||
}
|
||||
|
||||
if (!open) return null
|
||||
|
||||
return (
|
||||
@@ -48,7 +92,7 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
background: 'var(--surface)',
|
||||
borderRadius: '12px',
|
||||
padding: 'clamp(14px, 3vw, 1.75rem)',
|
||||
maxWidth: 'min(620px, 100%)',
|
||||
maxWidth: 'min(680px, 100%)',
|
||||
width: '100%',
|
||||
maxHeight: '90vh',
|
||||
overflowY: 'auto',
|
||||
@@ -60,9 +104,104 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.9rem', marginBottom: '1rem', lineHeight: 1.5 }}>
|
||||
Wähle ein Trainingsrahmenprogramm und eine oder mehrere Sessions. Pro Session entsteht eine{' '}
|
||||
<strong>eigene geplante Einheit</strong> in der aktuellen Gruppe (Kopie des Ablaufs). Die{' '}
|
||||
<strong>Verknüpfung zum Rahmen-Slot</strong> wird gespeichert, damit die Herkunft sichtbar bleibt.
|
||||
<strong>Verknüpfung zum Rahmen-Slot</strong> bleibt sichtbar.
|
||||
</p>
|
||||
|
||||
<details className="planning-filter-help" style={{ marginBottom: '1rem' }}>
|
||||
<summary className="planning-filter-help__summary">Rahmen filtern (optional)</summary>
|
||||
<div className="planning-filter-help__body" style={{ display: 'grid', gap: '10px' }}>
|
||||
<div className="form-row" style={{ marginBottom: 0 }}>
|
||||
<label className="form-label">Suche (Titel, Ziele, Katalog)</label>
|
||||
<input
|
||||
className="form-input"
|
||||
value={filterQuery}
|
||||
onChange={(e) => setFilterQuery(e.target.value)}
|
||||
placeholder="z. B. Gürtel, Koordination …"
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row" style={{ marginBottom: 0 }}>
|
||||
<label className="form-label">Ziel-Session-Dauer (Minuten)</label>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
className="form-input"
|
||||
value={filterDurationMin}
|
||||
onChange={(e) => setFilterDurationMin(e.target.value)}
|
||||
placeholder="z. B. 90"
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
<p className="form-sub" style={{ marginTop: '4px' }}>
|
||||
Zeigt Programme, deren hinterlegte Session-Dauer in etwa passt (±10 Min).
|
||||
</p>
|
||||
</div>
|
||||
{catalogFocusAreas.length > 0 ? (
|
||||
<div>
|
||||
<span className="form-label" style={{ display: 'block', marginBottom: '6px' }}>
|
||||
Fokusbereich
|
||||
</span>
|
||||
<div className="framework-catalog-checkgrid">
|
||||
{catalogFocusAreas.map((fa) => (
|
||||
<label key={fa.id} className="framework-catalog-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={filterFocusIds.includes(String(fa.id))}
|
||||
onChange={() => toggleId(filterFocusIds, setFilterFocusIds, fa.id)}
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
<span>{fa.name}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{catalogTrainingTypes.length > 0 ? (
|
||||
<div>
|
||||
<span className="form-label" style={{ display: 'block', marginBottom: '6px' }}>
|
||||
Trainingsart
|
||||
</span>
|
||||
<div className="framework-catalog-checkgrid">
|
||||
{catalogTrainingTypes.map((t) => (
|
||||
<label key={t.id} className="framework-catalog-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={filterTypeIds.includes(String(t.id))}
|
||||
onChange={() => toggleId(filterTypeIds, setFilterTypeIds, t.id)}
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
<span>{t.name}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{catalogTargetGroups.length > 0 ? (
|
||||
<div>
|
||||
<span className="form-label" style={{ display: 'block', marginBottom: '6px' }}>
|
||||
Zielgruppe
|
||||
</span>
|
||||
<div className="framework-catalog-checkgrid">
|
||||
{catalogTargetGroups.map((tg) => (
|
||||
<label key={tg.id} className="framework-catalog-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={filterTargetGroupIds.includes(String(tg.id))}
|
||||
onChange={() => toggleId(filterTargetGroupIds, setFilterTargetGroupIds, tg.id)}
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
<span>{tg.name}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<p className="form-sub" style={{ margin: 0 }}>
|
||||
{filteredPrograms.length} von {frameworkProgramsList.length} Rahmenprogramm(en) sichtbar.
|
||||
Entwicklungsziele sind freie Texte — die Suche durchsucht auch Ziel-Titel.
|
||||
</p>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div className="form-row">
|
||||
<label className="form-label">Rahmenprogramm</label>
|
||||
<select
|
||||
@@ -72,12 +211,23 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
disabled={fwImportLoading || fwImportSubmitting}
|
||||
>
|
||||
<option value="">Bitte wählen…</option>
|
||||
{frameworkProgramsList.map((fp) => (
|
||||
{filteredPrograms.map((fp) => (
|
||||
<option key={fp.id} value={String(fp.id)}>
|
||||
{(fp.title || '').trim() || `Rahmen #${fp.id}`}
|
||||
{frameworkProgramOptionLabel(fp)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{selectedProgramSummary ? (
|
||||
<p className="form-sub" style={{ marginTop: '6px' }}>
|
||||
Session-Dauer: <strong>{frameworkSessionDurationLabel(selectedProgramSummary)}</strong>
|
||||
{selectedProgramSummary.goal_titles_agg ? (
|
||||
<>
|
||||
{' '}
|
||||
· Ziele: {selectedProgramSummary.goal_titles_agg}
|
||||
</>
|
||||
) : null}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{fwImportLoading ? (
|
||||
@@ -96,6 +246,10 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
const checked = fwImportSelectedSlots.has(slot.id)
|
||||
const label =
|
||||
(slot.title || '').trim() || `Session ${(slot.sort_order ?? 0) + 1}`
|
||||
const slotDur =
|
||||
slot.planned_duration_min != null
|
||||
? formatDurationDisplay(slot.planned_duration_min)
|
||||
: null
|
||||
return (
|
||||
<li key={slot.id} style={{ marginBottom: '10px' }}>
|
||||
<label
|
||||
@@ -116,6 +270,18 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
/>
|
||||
<span style={{ flex: 1, minWidth: 0 }}>
|
||||
<strong>{label}</strong>
|
||||
{slotDur ? (
|
||||
<span
|
||||
style={{
|
||||
marginLeft: '8px',
|
||||
fontSize: '0.82rem',
|
||||
color: 'var(--text2)',
|
||||
fontWeight: 500,
|
||||
}}
|
||||
>
|
||||
· {slotDur}
|
||||
</span>
|
||||
) : null}
|
||||
{!hasBp ? (
|
||||
<span style={{ display: 'block', fontSize: '0.82rem', color: 'var(--danger)' }}>
|
||||
Ohne Session-Ablauf — Übernahme nicht möglich.
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
legacyPlanningUnitDeepLinkTarget,
|
||||
parsePlanningHubQuery,
|
||||
} from '../../utils/planningUnitRoutes'
|
||||
import { formatDurationDisplay } from '../../utils/trainingDurationUtils'
|
||||
|
||||
function TrainingPlanningPageRoot() {
|
||||
const { user } = useAuth()
|
||||
@@ -55,6 +56,9 @@ function TrainingPlanningPageRoot() {
|
||||
|
||||
const [frameworkImportOpen, setFrameworkImportOpen] = useState(false)
|
||||
const [frameworkProgramsList, setFrameworkProgramsList] = useState([])
|
||||
const [fwImportCatalogFocus, setFwImportCatalogFocus] = useState([])
|
||||
const [fwImportCatalogTypes, setFwImportCatalogTypes] = useState([])
|
||||
const [fwImportCatalogTargetGroups, setFwImportCatalogTargetGroups] = useState([])
|
||||
const [fwImportProgramId, setFwImportProgramId] = useState('')
|
||||
const [fwImportDetail, setFwImportDetail] = useState(null)
|
||||
const [fwImportLoading, setFwImportLoading] = useState(false)
|
||||
@@ -271,12 +275,25 @@ function TrainingPlanningPageRoot() {
|
||||
let cancelled = false
|
||||
;(async () => {
|
||||
try {
|
||||
const list = await api.listTrainingFrameworkPrograms()
|
||||
if (!cancelled) setFrameworkProgramsList(Array.isArray(list) ? list : [])
|
||||
const [list, fa, tt, tg] = await Promise.all([
|
||||
api.listTrainingFrameworkPrograms(),
|
||||
api.listFocusAreas({ status: 'active' }),
|
||||
api.listTrainingTypes({ status: 'active' }),
|
||||
api.listTargetGroups({ status: 'active' }),
|
||||
])
|
||||
if (!cancelled) {
|
||||
setFrameworkProgramsList(Array.isArray(list) ? list : [])
|
||||
setFwImportCatalogFocus(Array.isArray(fa) ? fa : [])
|
||||
setFwImportCatalogTypes(Array.isArray(tt) ? tt : [])
|
||||
setFwImportCatalogTargetGroups(Array.isArray(tg) ? tg : [])
|
||||
}
|
||||
} catch (e) {
|
||||
if (!cancelled) {
|
||||
console.error('Rahmenprogramme laden:', e)
|
||||
setFrameworkProgramsList([])
|
||||
setFwImportCatalogFocus([])
|
||||
setFwImportCatalogTypes([])
|
||||
setFwImportCatalogTargetGroups([])
|
||||
}
|
||||
}
|
||||
})()
|
||||
@@ -1033,7 +1050,9 @@ function TrainingPlanningPageRoot() {
|
||||
onClick={() => handleEdit(unit)}
|
||||
title={[
|
||||
planScope === 'club' && unit.group_name ? unit.group_name : '',
|
||||
unit.planned_time_start?.slice(0, 5) || '',
|
||||
unit.planned_duration_min
|
||||
? formatDurationDisplay(unit.planned_duration_min)
|
||||
: unit.planned_time_start?.slice(0, 5) || '',
|
||||
unit.lead_trainer_name?.trim(),
|
||||
unit.planned_focus?.trim(),
|
||||
unit.status === 'completed'
|
||||
@@ -1066,9 +1085,11 @@ function TrainingPlanningPageRoot() {
|
||||
}}
|
||||
>
|
||||
<span style={{ fontWeight: 600 }}>
|
||||
{unit.planned_time_start
|
||||
? `${unit.planned_time_start.slice(0, 5)}`
|
||||
: 'Ganztags'}
|
||||
{unit.planned_duration_min
|
||||
? formatDurationDisplay(unit.planned_duration_min)
|
||||
: unit.planned_time_start
|
||||
? `${unit.planned_time_start.slice(0, 5)}`
|
||||
: 'Ganztags'}
|
||||
</span>
|
||||
{planScope === 'club' && (unit.group_name || '').trim() ? (
|
||||
<span style={{ display: 'block', fontWeight: 500, color: 'var(--text1)' }}>
|
||||
@@ -1158,11 +1179,17 @@ function TrainingPlanningPageRoot() {
|
||||
<h3 style={{ marginBottom: '0.25rem' }}>
|
||||
{unit.planned_date}
|
||||
{unit.planned_duration_min
|
||||
? ` · ${unit.planned_duration_min >= 60 && unit.planned_duration_min % 60 === 0 ? `${unit.planned_duration_min / 60} h` : `${unit.planned_duration_min} Min`}`
|
||||
? ` · ${formatDurationDisplay(unit.planned_duration_min)}`
|
||||
: unit.planned_time_start
|
||||
? ` · ${unit.planned_time_start.slice(0, 5)} - ${unit.planned_time_end?.slice(0, 5)}`
|
||||
? ` · ${unit.planned_time_start.slice(0, 5)}${unit.planned_time_end ? ` – ${unit.planned_time_end.slice(0, 5)}` : ''}`
|
||||
: ''}
|
||||
</h3>
|
||||
{unit.planned_duration_min && unit.planned_time_start ? (
|
||||
<p style={{ fontSize: '0.78rem', color: 'var(--text3)', margin: '0 0 0.35rem' }}>
|
||||
Uhrzeit: {unit.planned_time_start.slice(0, 5)}
|
||||
{unit.planned_time_end ? ` – ${unit.planned_time_end.slice(0, 5)}` : ''}
|
||||
</p>
|
||||
) : null}
|
||||
{planScope === 'club' && (unit.group_name || '').trim() ? (
|
||||
<p
|
||||
style={{
|
||||
@@ -1378,6 +1405,9 @@ function TrainingPlanningPageRoot() {
|
||||
<TrainingPlanningFrameworkImportModal
|
||||
open={frameworkImportOpen}
|
||||
frameworkProgramsList={frameworkProgramsList}
|
||||
catalogFocusAreas={fwImportCatalogFocus}
|
||||
catalogTrainingTypes={fwImportCatalogTypes}
|
||||
catalogTargetGroups={fwImportCatalogTargetGroups}
|
||||
fwImportProgramId={fwImportProgramId}
|
||||
onProgramChange={onFwImportProgramChange}
|
||||
fwImportLoading={fwImportLoading}
|
||||
|
||||
Reference in new issue
Block a user