feat: enhance Exercises and Clubs pages with improved UI and functionality
Deploy Development / deploy (push) Successful in 36s
Test Suite / pytest-backend (push) Successful in 6s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Failing after 28s
Deploy Development / deploy (push) Successful in 36s
Test Suite / pytest-backend (push) Successful in 6s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 7s
Test Suite / playwright-tests (push) Failing after 28s
- Added new utility functions for handling exercise focus areas, style directions, and training types, improving data presentation. - Refactored ExercisesListPage to utilize new card layouts and improved visibility labels for exercises. - Updated ClubsPage and SkillsPage to implement a consistent tab navigation style, enhancing user experience. - Enhanced CSS styles for better responsiveness and visual consistency across various components. - Improved loading states and accessibility features for better user feedback and interaction.
This commit is contained in:
1 parent
68923b0364
commit
5096eec16b
7 files changed
+425
-154
No files matched your search
@@ -1,10 +1,12 @@
|
||||
import React, { useState, useEffect, useMemo, useCallback } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Eye, Pencil, Trash2 } from 'lucide-react'
|
||||
import api from '../utils/api'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { SKILL_LEVEL_OPTIONS } from '../constants/skillLevels'
|
||||
import MultiSelectCombo from '../components/MultiSelectCombo'
|
||||
import ExerciseProgressionGraphPanel from '../components/ExerciseProgressionGraphPanel'
|
||||
import { sanitizeExerciseRichText, coerceApiNameList } from '../utils/sanitizeHtml'
|
||||
|
||||
const PAGE_SIZE = 100
|
||||
const BULK_MAX_IDS = 500
|
||||
@@ -22,6 +24,38 @@ const INITIAL_FILTERS = {
|
||||
status_any: [],
|
||||
}
|
||||
|
||||
const VIS_LABELS = { official: 'Global', club: 'Verein', private: 'Privat' }
|
||||
const STATUS_LABELS = {
|
||||
draft: 'Entwurf',
|
||||
in_review: 'In Prüfung',
|
||||
approved: 'Freigegeben',
|
||||
archived: 'Archiv',
|
||||
}
|
||||
|
||||
function visibilityLabel(v) {
|
||||
return VIS_LABELS[v] || v || '—'
|
||||
}
|
||||
|
||||
function statusLabel(s) {
|
||||
return STATUS_LABELS[s] || s || '—'
|
||||
}
|
||||
|
||||
function exerciseFocusNames(ex) {
|
||||
const fromApi = coerceApiNameList(ex.focus_area_names)
|
||||
if (fromApi.length) return fromApi
|
||||
if (ex.focus_area) return [ex.focus_area]
|
||||
return []
|
||||
}
|
||||
|
||||
function exerciseCardClassName(exercise, userId) {
|
||||
const vis = exercise.visibility || 'private'
|
||||
const visKey = vis === 'official' || vis === 'club' || vis === 'private' ? vis : 'private'
|
||||
const mine = userId != null && Number(exercise.created_by) === Number(userId)
|
||||
return ['card', 'exercise-card', `exercise-card--scope-${visKey}`, mine ? 'exercise-card--mine' : '']
|
||||
.filter(Boolean)
|
||||
.join(' ')
|
||||
}
|
||||
|
||||
function levelOptionShort(levelStr) {
|
||||
const o = LEVEL_FILTER_OPTS.find((x) => String(x.level) === String(levelStr))
|
||||
return o ? String(o.level) : String(levelStr)
|
||||
@@ -569,33 +603,30 @@ function ExercisesListPage() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="exercises-page-toolbar-tabs" role="tablist" aria-label="Übungen Bereiche">
|
||||
<div className="planning-segment-group planning-segment-group--equal exercises-page-mode-switch">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={pageTab === 'list'}
|
||||
className={
|
||||
'planning-segment-group__btn' +
|
||||
(pageTab === 'list' ? ' planning-segment-group__btn--active' : '')
|
||||
}
|
||||
onClick={() => setPageTab('list')}
|
||||
>
|
||||
Liste
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={pageTab === 'progression'}
|
||||
className={
|
||||
'planning-segment-group__btn' +
|
||||
(pageTab === 'progression' ? ' planning-segment-group__btn--active' : '')
|
||||
}
|
||||
onClick={() => setPageTab('progression')}
|
||||
>
|
||||
Progressionsgraphen
|
||||
</button>
|
||||
</div>
|
||||
<div className="exercises-page-toolbar-tabs admin-page-subtabs" role="tablist" aria-label="Übungen Bereiche">
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={pageTab === 'list'}
|
||||
className={
|
||||
'admin-page-subtabs__btn' + (pageTab === 'list' ? ' admin-page-subtabs__btn--active' : '')
|
||||
}
|
||||
onClick={() => setPageTab('list')}
|
||||
>
|
||||
Liste
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={pageTab === 'progression'}
|
||||
className={
|
||||
'admin-page-subtabs__btn' +
|
||||
(pageTab === 'progression' ? ' admin-page-subtabs__btn--active' : '')
|
||||
}
|
||||
onClick={() => setPageTab('progression')}
|
||||
>
|
||||
Progressionsgraphen
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{pageTab === 'progression' ? (
|
||||
@@ -1093,55 +1124,80 @@ function ExercisesListPage() {
|
||||
{hasMore ? ' · es gibt weitere Einträge' : ''}
|
||||
</p>
|
||||
<div className="exercises-list-grid">
|
||||
{exercises.map((exercise) => (
|
||||
<div key={exercise.id} className="card exercise-card">
|
||||
<div className="exercise-card-layout">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selectedIds.has(Number(exercise.id))}
|
||||
onChange={() => toggleSelect(exercise.id)}
|
||||
aria-label={`„${(exercise.title || 'Übung').replace(/"/g, '')}“ auswählen`}
|
||||
className="exercise-card-layout__check"
|
||||
/>
|
||||
<div className="exercise-card__body exercise-card-body-flex">
|
||||
<h3 className="exercise-card-title">
|
||||
<Link to={`/exercises/${exercise.id}`}>
|
||||
{exercise.title}
|
||||
{exercises.map((exercise) => {
|
||||
const focusNames = exerciseFocusNames(exercise)
|
||||
const styleNames = coerceApiNameList(exercise.style_direction_names)
|
||||
const typeNames = coerceApiNameList(exercise.training_type_names)
|
||||
const summaryHtml = exercise.summary
|
||||
? sanitizeExerciseRichText(exercise.summary)
|
||||
: ''
|
||||
return (
|
||||
<div key={exercise.id} className={exerciseCardClassName(exercise, user?.id)}>
|
||||
<div className="exercise-card-layout exercise-card-layout--grow">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selectedIds.has(Number(exercise.id))}
|
||||
onChange={() => toggleSelect(exercise.id)}
|
||||
aria-label={`„${(exercise.title || 'Übung').replace(/"/g, '')}“ auswählen`}
|
||||
className="exercise-card-layout__check"
|
||||
/>
|
||||
<div className="exercise-card__body exercise-card-body-flex">
|
||||
<h3 className="exercise-card-title">
|
||||
<Link to={`/exercises/${exercise.id}`}>
|
||||
{exercise.title}
|
||||
</Link>
|
||||
</h3>
|
||||
<div className="exercise-card-tags">
|
||||
{focusNames.map((name) => (
|
||||
<span key={`fa:${name}`} className="exercise-tag exercise-tag--accent">{name}</span>
|
||||
))}
|
||||
{styleNames.map((name) => (
|
||||
<span key={`sd:${name}`} className="exercise-tag exercise-tag--style">{name}</span>
|
||||
))}
|
||||
{typeNames.map((name) => (
|
||||
<span key={`tt:${name}`} className="exercise-tag exercise-tag--training">{name}</span>
|
||||
))}
|
||||
<span className="exercise-tag exercise-tag--scope">{visibilityLabel(exercise.visibility)}</span>
|
||||
<span className="exercise-tag exercise-tag--meta">{statusLabel(exercise.status)}</span>
|
||||
</div>
|
||||
{summaryHtml ? (
|
||||
<div
|
||||
className="exercise-card-summary exercise-card-summary--rich"
|
||||
dangerouslySetInnerHTML={{ __html: summaryHtml }}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="exercise-card__actions exercise-card__actions--icons">
|
||||
<Link
|
||||
to={`/exercises/${exercise.id}`}
|
||||
className="exercise-card__icon-btn"
|
||||
title="Ansehen"
|
||||
aria-label={`„${(exercise.title || 'Übung').replace(/"/g, '')}“ ansehen`}
|
||||
>
|
||||
<Eye size={18} strokeWidth={2} aria-hidden />
|
||||
</Link>
|
||||
</h3>
|
||||
<div className="exercise-card-tags">
|
||||
{exercise.focus_area && (
|
||||
<span className="exercise-tag exercise-tag--accent">{exercise.focus_area}</span>
|
||||
)}
|
||||
<span className="exercise-tag">{exercise.visibility}</span>
|
||||
<span className="exercise-tag">{exercise.status}</span>
|
||||
</div>
|
||||
{exercise.summary && (
|
||||
<p className="exercise-card-summary">
|
||||
{exercise.summary.length > 160
|
||||
? `${exercise.summary.slice(0, 160)}…`
|
||||
: exercise.summary}
|
||||
</p>
|
||||
)}
|
||||
<Link
|
||||
to={`/exercises/${exercise.id}/edit`}
|
||||
className="exercise-card__icon-btn"
|
||||
title="Bearbeiten"
|
||||
aria-label={`„${(exercise.title || 'Übung').replace(/"/g, '')}“ bearbeiten`}
|
||||
>
|
||||
<Pencil size={18} strokeWidth={2} aria-hidden />
|
||||
</Link>
|
||||
<button
|
||||
type="button"
|
||||
className="exercise-card__icon-btn exercise-card__icon-btn--danger"
|
||||
title="Löschen"
|
||||
aria-label={`„${(exercise.title || 'Übung').replace(/"/g, '')}“ löschen`}
|
||||
onClick={() => handleDelete(exercise)}
|
||||
>
|
||||
<Trash2 size={18} strokeWidth={2} aria-hidden />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="exercise-card__actions">
|
||||
<Link to={`/exercises/${exercise.id}`} className="btn btn-secondary">
|
||||
Ansehen
|
||||
</Link>
|
||||
<Link to={`/exercises/${exercise.id}/edit`} className="btn btn-secondary">
|
||||
Bearbeiten
|
||||
</Link>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-danger btn-small"
|
||||
onClick={() => handleDelete(exercise)}
|
||||
>
|
||||
Löschen
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{hasMore && (
|
||||
<div className="exercises-load-more">
|
||||
|
||||
Reference in new issue
Block a user