Refactor Training Framework Programs List Page with Enhanced Styling and New Utility Functions
Test Suite / playwright-tests (push) Waiting to run
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Has been cancelled
Test Suite / playwright-tests (push) Waiting to run
Deploy Development / deploy (push) Successful in 40s
Test Suite / pytest-backend (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Has been cancelled
- Updated the TrainingFrameworkProgramsListPage to utilize new CSS classes for improved layout and styling. - Removed deprecated components and functions, streamlining the codebase for better maintainability. - Introduced utility functions for splitting aggregated strings, enhancing data handling for framework program attributes. - Enhanced the user interface with loading and empty state indicators, improving overall user experience.
This commit is contained in:
1 parent
9d122d4808
commit
a4548f5587
6 files changed
+617
-219
No files matched your search
@@ -2,90 +2,16 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import api from '../utils/api'
|
||||
import NavStateLink from '../components/NavStateLink'
|
||||
import FrameworkProgramsFilterBlock from '../components/planning/FrameworkProgramsFilterBlock'
|
||||
import FrameworkProgramListCard from '../components/planning/FrameworkProgramListCard'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { buildFrameworkProgramsListReturnContext } from '../utils/navReturnContext'
|
||||
import {
|
||||
EMPTY_FRAMEWORK_IMPORT_FILTERS,
|
||||
filterFrameworkPrograms,
|
||||
frameworkSessionDurationLabel,
|
||||
hasActiveFrameworkImportFilters,
|
||||
} from '../utils/frameworkProgramListHelpers'
|
||||
|
||||
function dashIfEmpty(val) {
|
||||
const s = (val ?? '').toString().trim()
|
||||
return s.length ? s : '—'
|
||||
}
|
||||
|
||||
function FrameworkSummaryMeta({ r }) {
|
||||
const trainingTypes =
|
||||
typeof r.training_type_names_agg === 'string' ? r.training_type_names_agg.trim() : ''
|
||||
const targetGroups =
|
||||
typeof r.target_group_names_agg === 'string' ? r.target_group_names_agg.trim() : ''
|
||||
const styleDir =
|
||||
typeof r.style_direction_names_agg === 'string'
|
||||
? r.style_direction_names_agg.trim()
|
||||
: typeof r.style_direction_name === 'string'
|
||||
? r.style_direction_name.trim()
|
||||
: ''
|
||||
const focus =
|
||||
typeof r.focus_area_names_agg === 'string'
|
||||
? r.focus_area_names_agg.trim()
|
||||
: typeof r.focus_area_name === 'string'
|
||||
? r.focus_area_name.trim()
|
||||
: ''
|
||||
|
||||
const rowStyle = {
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'minmax(6.5rem, 32%) 1fr',
|
||||
gap: '0.25rem 0.75rem',
|
||||
alignItems: 'start',
|
||||
marginTop: '0.35rem',
|
||||
lineHeight: 1.45,
|
||||
}
|
||||
|
||||
const durationLabel = frameworkSessionDurationLabel(r)
|
||||
const goals =
|
||||
typeof r.goal_titles_agg === 'string' ? r.goal_titles_agg.trim() : ''
|
||||
|
||||
return (
|
||||
<dl style={{ margin: '0.5rem 0 0', padding: 0, fontSize: '0.875rem', color: 'var(--text2)' }}>
|
||||
<div style={rowStyle}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)' }}>Session-Dauer</dt>
|
||||
<dd style={{ margin: 0 }}>{durationLabel}</dd>
|
||||
</div>
|
||||
{goals ? (
|
||||
<div style={rowStyle}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)' }}>Entwicklungsziele</dt>
|
||||
<dd style={{ margin: 0 }}>{goals}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
<div style={rowStyle}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)' }}>Fokusbereich</dt>
|
||||
<dd style={{ margin: 0 }}>{dashIfEmpty(focus)}</dd>
|
||||
</div>
|
||||
<div style={rowStyle}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)' }}>Stilrichtungen</dt>
|
||||
<dd style={{ margin: 0 }}>{dashIfEmpty(styleDir)}</dd>
|
||||
</div>
|
||||
<div style={rowStyle}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)' }}>Trainingsarten</dt>
|
||||
<dd style={{ margin: 0 }}>{trainingTypes.length ? trainingTypes : '—'}</dd>
|
||||
</div>
|
||||
<div style={rowStyle}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)' }}>Zielgruppen</dt>
|
||||
<dd style={{ margin: 0 }}>{targetGroups.length ? targetGroups : '—'}</dd>
|
||||
</div>
|
||||
<div style={{ ...rowStyle, marginTop: '0.5rem' }}>
|
||||
<dt style={{ margin: 0, fontWeight: 600, color: 'var(--text3)' }}>Kurzbeschreibung</dt>
|
||||
<dd style={{ margin: 0, whiteSpace: 'pre-wrap' }}>
|
||||
{(r.description && String(r.description).trim()) || '—'}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
)
|
||||
}
|
||||
|
||||
export default function TrainingFrameworkProgramsListPage() {
|
||||
const { user } = useAuth()
|
||||
const tenantClubDepKey = useMemo(() => getTenantClubDependencyKey(user), [user])
|
||||
@@ -145,154 +71,99 @@ export default function TrainingFrameworkProgramsListPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
alignItems: 'flex-start',
|
||||
justifyContent: 'space-between',
|
||||
gap: '1rem',
|
||||
marginBottom: '1.25rem',
|
||||
}}
|
||||
<div className="fw-prog-page">
|
||||
<header className="fw-prog-page__header">
|
||||
<div className="fw-prog-page__intro">
|
||||
<h1 className="page-title fw-prog-page__title">Trainingsrahmenprogramme</h1>
|
||||
<p className="fw-prog-page__lead">
|
||||
Vorlagen für Entwicklungsziele und Sessions — die Übernahme in Gruppentermine erfolgt in der
|
||||
Trainingsplanung.
|
||||
</p>
|
||||
<details className="planning-filter-help fw-prog-page__help">
|
||||
<summary className="planning-filter-help__summary">Mehr zur Übernahme in die Planung</summary>
|
||||
<div className="planning-filter-help__body">
|
||||
Unter <strong>Planung</strong> wählst du eine Gruppe und übernimmst Slots aus einem Rahmenprogramm in
|
||||
echte Termine. So bleibt die Bibliothek wiederverwendbar, ohne dass Einzelgruppen fest verdrahtet sind.
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<NavStateLink
|
||||
to="/planning/framework-programs/new"
|
||||
returnContext={frameworkListReturn}
|
||||
className="btn btn-primary fw-prog-page__cta"
|
||||
>
|
||||
<div>
|
||||
<h1 className="page-title" style={{ marginBottom: '0.35rem' }}>
|
||||
Trainingsrahmenprogramme
|
||||
</h1>
|
||||
<p style={{ color: 'var(--text2)', fontSize: '0.95rem', maxWidth: '36rem', margin: 0 }}>
|
||||
Vorlagen für Ziele und Sessions — die Verknüpfung mit Gruppenterminen erfolgt in der
|
||||
Trainingsplanung (Registerkarte oben).
|
||||
</p>
|
||||
<details className="planning-filter-help" style={{ marginTop: '10px', maxWidth: '36rem' }}>
|
||||
<summary className="planning-filter-help__summary">Mehr zur Übernahme in die Planung</summary>
|
||||
<div className="planning-filter-help__body">
|
||||
Unter <strong>Planung</strong> wählst du eine Gruppe und übernimmst Slots aus einem Rahmenprogramm in
|
||||
echte Termine. So bleibt die Bibliothek wiederverwendbar, ohne dass Einzelgruppen fest verdrahtet sind.
|
||||
</div>
|
||||
</details>
|
||||
Rahmenprogramm anlegen
|
||||
</NavStateLink>
|
||||
</header>
|
||||
|
||||
{error ? (
|
||||
<div className="card fw-prog-page__error" role="alert">
|
||||
{error}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{loading ? (
|
||||
<div className="fw-prog-page__loading card">
|
||||
<div className="spinner" aria-hidden="true" />
|
||||
<p>Rahmenprogramme werden geladen…</p>
|
||||
</div>
|
||||
) : rows.length === 0 ? (
|
||||
<div className="card fw-prog-page__empty">
|
||||
<div className="fw-prog-page__empty-icon" aria-hidden="true">
|
||||
📋
|
||||
</div>
|
||||
<h2 className="fw-prog-page__empty-title">Noch keine Rahmenprogramme</h2>
|
||||
<p className="fw-prog-page__empty-text">
|
||||
Lege ein neues Programm an — mit Titel, mindestens einem Entwicklungsziel und optional Sessions samt
|
||||
Übungsablauf.
|
||||
</p>
|
||||
<NavStateLink
|
||||
to="/planning/framework-programs/new"
|
||||
returnContext={frameworkListReturn}
|
||||
className="btn btn-primary"
|
||||
style={{ textDecoration: 'none', whiteSpace: 'nowrap' }}
|
||||
className="btn btn-primary btn-full"
|
||||
>
|
||||
Rahmenprogramm anlegen
|
||||
Erstes Rahmenprogramm anlegen
|
||||
</NavStateLink>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<FrameworkProgramsFilterBlock
|
||||
programs={rows}
|
||||
filters={filters}
|
||||
onFiltersChange={setFilters}
|
||||
panelOpen={filterPanelOpen}
|
||||
onPanelOpenChange={setFilterPanelOpen}
|
||||
catalogFocusAreas={catalogFocusAreas}
|
||||
catalogTrainingTypes={catalogTrainingTypes}
|
||||
catalogTargetGroups={catalogTargetGroups}
|
||||
durationRadioName="fw-list-duration-mode"
|
||||
className="fw-prog-filter-block--list"
|
||||
/>
|
||||
|
||||
{error && (
|
||||
<div className="card" style={{ borderLeft: '4px solid var(--danger)', marginBottom: '1rem' }}>
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{loading ? (
|
||||
<div style={{ textAlign: 'center', padding: '2rem' }}>
|
||||
<div className="spinner" />
|
||||
<p>Laden…</p>
|
||||
</div>
|
||||
) : rows.length === 0 ? (
|
||||
<div className="card">
|
||||
<p style={{ color: 'var(--text2)', marginBottom: '1rem' }}>
|
||||
Noch kein Rahmenprogramm gespeichert. Lege ein neues an — mit Titel, mindestens einem Ziel und optional
|
||||
Slots samt Übungen.
|
||||
</p>
|
||||
<NavStateLink
|
||||
to="/planning/framework-programs/new"
|
||||
returnContext={frameworkListReturn}
|
||||
className="btn btn-primary btn-full"
|
||||
style={{ textDecoration: 'none' }}
|
||||
>
|
||||
Rahmenprogramm anlegen
|
||||
</NavStateLink>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<FrameworkProgramsFilterBlock
|
||||
programs={rows}
|
||||
filters={filters}
|
||||
onFiltersChange={setFilters}
|
||||
panelOpen={filterPanelOpen}
|
||||
onPanelOpenChange={setFilterPanelOpen}
|
||||
catalogFocusAreas={catalogFocusAreas}
|
||||
catalogTrainingTypes={catalogTrainingTypes}
|
||||
catalogTargetGroups={catalogTargetGroups}
|
||||
durationRadioName="fw-list-duration-mode"
|
||||
className="fw-prog-filter-block--list"
|
||||
/>
|
||||
|
||||
{filteredRows.length === 0 ? (
|
||||
<div className="card" style={{ marginTop: '1rem' }}>
|
||||
<p style={{ color: 'var(--text2)', margin: 0 }}>
|
||||
{filterActive
|
||||
? 'Kein Rahmenprogramm passt zu den gewählten Filtern. Passe die Kriterien an oder setze den Filter zurück.'
|
||||
: 'Keine Einträge.'}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<ul className="framework-programs-list">
|
||||
{filteredRows.map((r) => (
|
||||
<li key={r.id} className="card">
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
alignItems: 'flex-start',
|
||||
justifyContent: 'space-between',
|
||||
gap: '0.75rem',
|
||||
}}
|
||||
>
|
||||
<div style={{ minWidth: 0, flex: '1 1 220px' }}>
|
||||
<NavStateLink
|
||||
to={`/planning/framework-programs/${r.id}`}
|
||||
returnContext={frameworkListReturn}
|
||||
style={{ fontWeight: 600, fontSize: '1.05rem', color: 'var(--text1)' }}
|
||||
>
|
||||
{r.title || `Rahmen #${r.id}`}
|
||||
</NavStateLink>
|
||||
<div style={{ fontSize: '0.85rem', color: 'var(--text2)', marginTop: '0.35rem' }}>
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
marginRight: '8px',
|
||||
padding: '2px 8px',
|
||||
borderRadius: '6px',
|
||||
background: 'var(--surface2)',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text1)',
|
||||
}}
|
||||
>
|
||||
{frameworkSessionDurationLabel(r)}
|
||||
</span>
|
||||
<span>
|
||||
{(r.goals_count ?? '—') + ' Ziele · '}
|
||||
{(r.slots_count ?? '—') + ' Slots'}
|
||||
</span>
|
||||
</div>
|
||||
<FrameworkSummaryMeta r={r} />
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.5rem' }}>
|
||||
<NavStateLink
|
||||
to={`/planning/framework-programs/${r.id}`}
|
||||
returnContext={frameworkListReturn}
|
||||
className="btn btn-secondary"
|
||||
style={{ textDecoration: 'none' }}
|
||||
>
|
||||
Bearbeiten
|
||||
</NavStateLink>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => handleDelete(r.id, r.title)}>
|
||||
Löschen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
{filteredRows.length === 0 ? (
|
||||
<div className="card fw-prog-page__empty fw-prog-page__empty--filter">
|
||||
<h2 className="fw-prog-page__empty-title">Kein Treffer</h2>
|
||||
<p className="fw-prog-page__empty-text">
|
||||
{filterActive
|
||||
? 'Kein Rahmenprogramm passt zu den gewählten Filtern. Passe die Kriterien an oder setze den Filter zurück.'
|
||||
: 'Keine Einträge.'}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<ul className="fw-prog-list" aria-label="Rahmenprogramme">
|
||||
{filteredRows.map((r) => (
|
||||
<li key={r.id}>
|
||||
<FrameworkProgramListCard
|
||||
row={r}
|
||||
returnContext={frameworkListReturn}
|
||||
onDelete={handleDelete}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -119,13 +119,14 @@ export default function TrainingModulesListPage() {
|
||||
</p>
|
||||
</div>
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '8px' }}>
|
||||
<Link
|
||||
<NavStateLink
|
||||
to={`/planning/training-modules/${r.id}`}
|
||||
returnContext={modulesListReturn}
|
||||
className="btn btn-secondary"
|
||||
style={{ textDecoration: 'none' }}
|
||||
to={`/planning/training-modules/${r.id}`}
|
||||
>
|
||||
Bearbeiten
|
||||
</Link>
|
||||
</NavStateLink>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => handleDelete(r.id, r.title)}>
|
||||
Löschen
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user