Enhance Training Framework Programs List with Filtering and Styling Improvements
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 37s
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 1m20s
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 37s
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 1m20s
- Introduced a new filter block for training framework programs, allowing users to refine their selections based on focus areas, training types, and target groups. - Updated the TrainingFrameworkProgramsListPage to integrate the filter block and manage filter states effectively. - Enhanced CSS styles for the filter block and program list, improving layout and spacing for better user experience. - Removed unused filter-related logic from the TrainingPlanningFrameworkImportModal, streamlining the component's functionality.
This commit is contained in:
1 parent
9c3494a7ea
commit
9d122d4808
4 files changed
+376
-260
No files matched your search
@@ -1,12 +1,10 @@
|
||||
import React, { useEffect, useMemo, useState } from 'react'
|
||||
import FrameworkProgramsFilterBlock from './FrameworkProgramsFilterBlock'
|
||||
import {
|
||||
collectDistinctSessionDurationsMinutes,
|
||||
EMPTY_FRAMEWORK_IMPORT_FILTERS,
|
||||
filterFrameworkPrograms,
|
||||
frameworkProgramOptionLabel,
|
||||
frameworkSessionDurationLabel,
|
||||
hasActiveFrameworkImportFilters,
|
||||
summarizeFrameworkImportFilters,
|
||||
} from '../../utils/frameworkProgramListHelpers'
|
||||
import { formatDurationDisplay } from '../../utils/trainingDurationUtils'
|
||||
|
||||
@@ -46,28 +44,11 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
}
|
||||
}, [open])
|
||||
|
||||
const distinctDurations = useMemo(
|
||||
() => collectDistinctSessionDurationsMinutes(frameworkProgramsList),
|
||||
[frameworkProgramsList]
|
||||
)
|
||||
|
||||
const filteredPrograms = useMemo(
|
||||
() => filterFrameworkPrograms(frameworkProgramsList, filters),
|
||||
[frameworkProgramsList, filters]
|
||||
)
|
||||
|
||||
const filterActive = hasActiveFrameworkImportFilters(filters)
|
||||
const filterSummaryParts = useMemo(
|
||||
() =>
|
||||
summarizeFrameworkImportFilters(filters, {
|
||||
focusAreas: catalogFocusAreas,
|
||||
trainingTypes: catalogTrainingTypes,
|
||||
targetGroups: catalogTargetGroups,
|
||||
}),
|
||||
[filters, catalogFocusAreas, catalogTrainingTypes, catalogTargetGroups]
|
||||
)
|
||||
|
||||
const totalCount = (frameworkProgramsList || []).length
|
||||
const matchCount = filteredPrograms.length
|
||||
|
||||
useEffect(() => {
|
||||
@@ -81,19 +62,6 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
return (frameworkProgramsList || []).find((p) => String(p.id) === String(fwImportProgramId))
|
||||
}, [frameworkProgramsList, fwImportProgramId])
|
||||
|
||||
const updateFilter = (patch) => setFilters((prev) => ({ ...prev, ...patch }))
|
||||
|
||||
const clearFilters = () => setFilters({ ...EMPTY_FRAMEWORK_IMPORT_FILTERS })
|
||||
|
||||
const toggleId = (key, id) => {
|
||||
const s = String(id)
|
||||
setFilters((prev) => {
|
||||
const cur = prev[key] || []
|
||||
const next = cur.includes(s) ? cur.filter((x) => x !== s) : [...cur, s]
|
||||
return { ...prev, [key]: next }
|
||||
})
|
||||
}
|
||||
|
||||
if (!open) return null
|
||||
|
||||
return (
|
||||
@@ -108,230 +76,18 @@ export default function TrainingPlanningFrameworkImportModal({
|
||||
<strong>eigene geplante Einheit</strong> in der aktuellen Gruppe (Kopie des Ablaufs).
|
||||
</p>
|
||||
|
||||
<div className="fw-import-results-bar">
|
||||
<div className="fw-import-results-bar__count">
|
||||
<strong className="fw-import-results-bar__num">{matchCount}</strong>
|
||||
<span>
|
||||
{' '}
|
||||
von {totalCount} Rahmenprogramm{totalCount === 1 ? '' : 'en'}
|
||||
</span>
|
||||
{matchCount === 0 && totalCount > 0 ? (
|
||||
<span className="fw-import-results-bar__warn"> — kein Treffer</span>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="fw-import-results-bar__actions">
|
||||
{filterActive ? (
|
||||
<span className="fw-import-filter-badge" title={filterSummaryParts.join(' · ')}>
|
||||
Filter aktiv
|
||||
</span>
|
||||
) : null}
|
||||
{filterActive ? (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary framework-ctrl framework-ctrl--xs"
|
||||
disabled={fwImportSubmitting}
|
||||
onClick={clearFilters}
|
||||
>
|
||||
Filter zurücksetzen
|
||||
</button>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary framework-ctrl framework-ctrl--xs"
|
||||
disabled={fwImportSubmitting}
|
||||
onClick={() => setFilterPanelOpen((v) => !v)}
|
||||
aria-expanded={filterPanelOpen}
|
||||
>
|
||||
{filterPanelOpen ? 'Filter einklappen' : 'Filter anzeigen'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{!filterPanelOpen && filterActive && filterSummaryParts.length > 0 ? (
|
||||
<ul className="fw-import-filter-chips" aria-label="Aktive Filter">
|
||||
{filterSummaryParts.map((part) => (
|
||||
<li key={part} className="fw-import-filter-chip">
|
||||
{part}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
|
||||
{filterPanelOpen ? (
|
||||
<div className="fw-import-filter-panel">
|
||||
<div className="fw-import-filter-panel__grid">
|
||||
<div className="form-row fw-import-filter-panel__search">
|
||||
<label className="form-label">Suche (Titel, Ziele, Katalog)</label>
|
||||
<input
|
||||
className="form-input"
|
||||
value={filters.query}
|
||||
onChange={(e) => updateFilter({ query: e.target.value })}
|
||||
placeholder="z. B. Gürtel, Koordination …"
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<fieldset className="fw-import-duration-fieldset">
|
||||
<legend className="form-label">Ziel-Session-Dauer</legend>
|
||||
<div className="fw-import-duration-mode" role="radiogroup" aria-label="Dauer-Filtermodus">
|
||||
{[
|
||||
{ id: 'any', label: 'Alle' },
|
||||
{ id: 'range', label: 'Zeitspanne' },
|
||||
{ id: 'preset', label: 'Vorhandene Zeiten' },
|
||||
].map((opt) => (
|
||||
<label key={opt.id} className="fw-import-duration-mode__opt">
|
||||
<input
|
||||
type="radio"
|
||||
name="fw-duration-mode"
|
||||
checked={filters.durationMode === opt.id}
|
||||
disabled={fwImportSubmitting || (opt.id === 'preset' && distinctDurations.length === 0)}
|
||||
onChange={() =>
|
||||
updateFilter({
|
||||
durationMode: opt.id,
|
||||
...(opt.id === 'any'
|
||||
? { durationRangeFrom: '', durationRangeTo: '', durationPresetMin: null }
|
||||
: {}),
|
||||
})
|
||||
}
|
||||
/>
|
||||
<span>{opt.label}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{filters.durationMode === 'range' ? (
|
||||
<div className="responsive-grid-2 fw-import-duration-range">
|
||||
<div className="form-row" style={{ marginBottom: 0 }}>
|
||||
<label className="form-label">Von (Minuten)</label>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
className="form-input"
|
||||
value={filters.durationRangeFrom}
|
||||
onChange={(e) =>
|
||||
updateFilter({ durationMode: 'range', durationRangeFrom: e.target.value })
|
||||
}
|
||||
placeholder="z. B. 60"
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row" style={{ marginBottom: 0 }}>
|
||||
<label className="form-label">Bis (Minuten)</label>
|
||||
<input
|
||||
type="number"
|
||||
min={0}
|
||||
className="form-input"
|
||||
value={filters.durationRangeTo}
|
||||
onChange={(e) =>
|
||||
updateFilter({ durationMode: 'range', durationRangeTo: e.target.value })
|
||||
}
|
||||
placeholder="z. B. 90"
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{filters.durationMode === 'preset' ? (
|
||||
distinctDurations.length === 0 ? (
|
||||
<p className="form-sub" style={{ margin: '8px 0 0' }}>
|
||||
In der Bibliothek sind noch keine Session-Dauern hinterlegt. Nutze „Zeitspanne“ oder lege
|
||||
Dauer pro Session im Rahmenprogramm fest.
|
||||
</p>
|
||||
) : (
|
||||
<div className="fw-import-duration-presets">
|
||||
{distinctDurations.map((min) => {
|
||||
const on = filters.durationPresetMin === min
|
||||
return (
|
||||
<button
|
||||
key={min}
|
||||
type="button"
|
||||
className={
|
||||
'btn framework-ctrl framework-ctrl--xs' +
|
||||
(on ? ' fw-import-duration-preset--on' : ' btn-secondary')
|
||||
}
|
||||
disabled={fwImportSubmitting}
|
||||
onClick={() =>
|
||||
updateFilter({
|
||||
durationMode: 'preset',
|
||||
durationPresetMin: on ? null : min,
|
||||
durationRangeFrom: '',
|
||||
durationRangeTo: '',
|
||||
})
|
||||
}
|
||||
>
|
||||
{formatDurationDisplay(min)}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
</fieldset>
|
||||
|
||||
{catalogFocusAreas.length > 0 ? (
|
||||
<div className="fw-import-catalog-block">
|
||||
<span className="form-label">Fokusbereich</span>
|
||||
<div className="framework-catalog-checkgrid">
|
||||
{catalogFocusAreas.map((fa) => (
|
||||
<label key={fa.id} className="framework-catalog-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={(filters.focusAreaIds || []).includes(String(fa.id))}
|
||||
onChange={() => toggleId('focusAreaIds', fa.id)}
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
<span>{fa.name}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{catalogTrainingTypes.length > 0 ? (
|
||||
<div className="fw-import-catalog-block">
|
||||
<span className="form-label">Trainingsart</span>
|
||||
<div className="framework-catalog-checkgrid">
|
||||
{catalogTrainingTypes.map((t) => (
|
||||
<label key={t.id} className="framework-catalog-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={(filters.trainingTypeIds || []).includes(String(t.id))}
|
||||
onChange={() => toggleId('trainingTypeIds', t.id)}
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
<span>{t.name}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{catalogTargetGroups.length > 0 ? (
|
||||
<div className="fw-import-catalog-block">
|
||||
<span className="form-label">Zielgruppe</span>
|
||||
<div className="framework-catalog-checkgrid">
|
||||
{catalogTargetGroups.map((tg) => (
|
||||
<label key={tg.id} className="framework-catalog-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={(filters.targetGroupIds || []).includes(String(tg.id))}
|
||||
onChange={() => toggleId('targetGroupIds', tg.id)}
|
||||
disabled={fwImportSubmitting}
|
||||
/>
|
||||
<span>{tg.name}</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="form-sub fw-import-filter-panel__hint">
|
||||
Entwicklungsziele sind freie Texte — die Suche durchsucht auch Ziel-Titel. Bei der Dauer werden nur
|
||||
Programme mit hinterlegter Session-Dauer berücksichtigt.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
<FrameworkProgramsFilterBlock
|
||||
programs={frameworkProgramsList}
|
||||
filters={filters}
|
||||
onFiltersChange={setFilters}
|
||||
panelOpen={filterPanelOpen}
|
||||
onPanelOpenChange={setFilterPanelOpen}
|
||||
catalogFocusAreas={catalogFocusAreas}
|
||||
catalogTrainingTypes={catalogTrainingTypes}
|
||||
catalogTargetGroups={catalogTargetGroups}
|
||||
disabled={fwImportSubmitting}
|
||||
durationRadioName="fw-duration-mode"
|
||||
/>
|
||||
|
||||
<div className="form-row fw-import-program-select">
|
||||
<label className="form-label">
|
||||
|
||||
Reference in new issue
Block a user