Enhance navigation and return context in exercise and training module components
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 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m17s
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 12s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m17s
- Introduced a new `PageReturnLink` component for consistent back navigation across pages. - Updated `SaveSelectedExercisesAsModuleModal` and `SaveExercisesAsModuleModal` to utilize `navigateWithAppReturn`, preserving navigation context when redirecting after saving. - Enhanced `TrainingModuleEditPage` and `TrainingUnitEditPage` with improved return context handling, allowing users to navigate back to their previous locations seamlessly. - Added CSS styles for the new return link to improve visual consistency and user experience.
This commit is contained in:
1 parent
14b005e9b8
commit
6e6270b717
10 files changed
+440
-15
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import React from 'react'
|
||||
import { useLocation, useNavigate } from 'react-router-dom'
|
||||
import { goNavReturn, resolveNavReturnTarget } from '../utils/navReturnContext'
|
||||
|
||||
/**
|
||||
* Einheitlicher Zurück-Link für Editor-/Detailseiten (PWA-sicher).
|
||||
*/
|
||||
export default function PageReturnLink({
|
||||
fallbackPath,
|
||||
fallbackLabel,
|
||||
className = 'page-return-link',
|
||||
style,
|
||||
}) {
|
||||
const location = useLocation()
|
||||
const navigate = useNavigate()
|
||||
const target = resolveNavReturnTarget(location, {
|
||||
path: fallbackPath,
|
||||
label: fallbackLabel,
|
||||
})
|
||||
|
||||
if (!target?.path || !target?.label) return null
|
||||
|
||||
const handleClick = (e) => {
|
||||
e.preventDefault()
|
||||
goNavReturn(navigate, location, {
|
||||
path: fallbackPath,
|
||||
label: fallbackLabel,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<a href={target.path} className={className} style={style} onClick={handleClick}>
|
||||
← {target.label}
|
||||
</a>
|
||||
)
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import ExerciseListSearchBar from './ExerciseListSearchBar'
|
||||
import ExerciseListBulkToolbar from './ExerciseListBulkToolbar'
|
||||
import SaveSelectedExercisesAsModuleModal from './SaveSelectedExercisesAsModuleModal'
|
||||
import ExercisePeekModal from '../ExercisePeekModal'
|
||||
import { buildExercisesListReturnContext } from '../../utils/navReturnContext'
|
||||
import { buildExerciseListFilterChips } from '../../utils/exerciseListFilterChips'
|
||||
import { applyDashboardExerciseListUrl, buildExerciseListQueryBase } from '../../utils/exerciseListQuery'
|
||||
import { readExerciseListSessionState, writeExerciseListSessionState } from '../../utils/exerciseListSessionState'
|
||||
@@ -296,6 +297,8 @@ function ExercisesListPageRoot() {
|
||||
|
||||
const selectedExercisesInListOrder = selectedExercisesDisplay
|
||||
|
||||
const exercisesModuleReturnContext = useMemo(() => buildExercisesListReturnContext(), [])
|
||||
|
||||
const bulkVisibilityOptions = useMemo(() => {
|
||||
const base = [
|
||||
{ id: '', label: '— nicht ändern —' },
|
||||
@@ -595,6 +598,7 @@ function ExercisesListPageRoot() {
|
||||
open={saveModuleModalOpen}
|
||||
onClose={() => setSaveModuleModalOpen(false)}
|
||||
selectedExercises={selectedExercisesInListOrder}
|
||||
returnContext={exercisesModuleReturnContext}
|
||||
onSuccess={clearSelection}
|
||||
/>
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useAuth } from '../../context/AuthContext'
|
||||
import { activeClubMemberships, getDefaultClubIdForGovernanceForms } from '../../utils/activeClub'
|
||||
import { hydrateExercisePlanningRow } from '../../utils/trainingUnitSectionsForm'
|
||||
import { buildRowsPayload, moduleItemToPayload } from '../../utils/exerciseListSelection'
|
||||
import { navigateWithAppReturn } from '../../utils/navReturnContext'
|
||||
|
||||
/**
|
||||
* Erstellt ein Trainingsmodul aus per Checkbox ausgewählten Übungen (Reihenfolge = Auswahlreihenfolge).
|
||||
@@ -18,6 +19,8 @@ export default function SaveSelectedExercisesAsModuleModal({
|
||||
onClose,
|
||||
/** @type {Array<{ id: number, title?: string }>} */
|
||||
selectedExercises,
|
||||
/** Return-Kontext für Modul-Editor (z. B. Übungsliste) */
|
||||
returnContext,
|
||||
onSuccess,
|
||||
}) {
|
||||
const navigate = useNavigate()
|
||||
@@ -153,7 +156,7 @@ export default function SaveSelectedExercisesAsModuleModal({
|
||||
]
|
||||
await api.updateTrainingModule(mid, { items: merged })
|
||||
toast.success(`${newItemsPayload.length} Übung(en) an Modul angefügt.`)
|
||||
navigate(`/planning/training-modules/${mid}`)
|
||||
navigateWithAppReturn(navigate, `/planning/training-modules/${mid}`, returnContext)
|
||||
onSuccess?.()
|
||||
onClose()
|
||||
return
|
||||
@@ -184,7 +187,7 @@ export default function SaveSelectedExercisesAsModuleModal({
|
||||
})
|
||||
toast.success('Trainingsmodul gespeichert.')
|
||||
if (created?.id) {
|
||||
navigate(`/planning/training-modules/${created.id}`)
|
||||
navigateWithAppReturn(navigate, `/planning/training-modules/${created.id}`, returnContext)
|
||||
}
|
||||
onSuccess?.()
|
||||
onClose()
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useToast } from '../../context/ToastContext'
|
||||
import { useAuth } from '../../context/AuthContext'
|
||||
import { activeClubMemberships } from '../../utils/activeClub'
|
||||
import { collectExercisePlacementsForModule } from '../../utils/trainingPlanModuleFromUnit'
|
||||
import { navigateWithAppReturn } from '../../utils/navReturnContext'
|
||||
|
||||
/**
|
||||
* Erstellt ein Trainingsmodul aus den Übungen einer gespeicherten Trainingseinheit (Mehrfachauswahl).
|
||||
@@ -16,6 +17,7 @@ export default function SaveExercisesAsModuleModal({
|
||||
onClose,
|
||||
unitId,
|
||||
planningModalClubId,
|
||||
returnContext,
|
||||
onSuccess,
|
||||
}) {
|
||||
const navigate = useNavigate()
|
||||
@@ -134,7 +136,7 @@ export default function SaveExercisesAsModuleModal({
|
||||
})
|
||||
toast.success('Trainingsmodul gespeichert.')
|
||||
if (created?.id) {
|
||||
navigate(`/planning/training-modules/${created.id}`)
|
||||
navigateWithAppReturn(navigate, `/planning/training-modules/${created.id}`, returnContext)
|
||||
}
|
||||
onSuccess?.()
|
||||
onClose()
|
||||
|
||||
Reference in new issue
Block a user