feat(version): bump to 0.8.110 and update project specifications
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / playwright-tests (push) Successful in 1m15s
Deploy Development / deploy (push) Successful in 41s
Test Suite / pytest-backend (push) Successful in 35s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 12s
Test Suite / playwright-tests (push) Successful in 1m15s
- Updated app version to 0.8.110 and database schema version to 20260512057, reflecting recent enhancements. - Revised project status documentation to include new versioning and next steps for development. - Enhanced the functional specification for training modules and combination exercises, detailing upcoming features and improvements. - Improved technical specifications to align with the latest code changes, ensuring consistency across documentation. - Introduced new UI elements for toast notifications and unsaved changes prompts to enhance user experience. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
81fd7d9b3b
commit
49adb395dd
24 files changed
+1001
-268
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState, useRef, useMemo } from 'react'
|
||||
import React, { useEffect, useState, useRef, useMemo, useCallback } from 'react'
|
||||
import { useNavigate, useParams, Link } from 'react-router-dom'
|
||||
import api, { buildExerciseApiPayload } from '../utils/api'
|
||||
import { resolveExerciseMediaFileUrl, resolveMediaAssetFileUrl } from '../utils/exerciseMediaUrl'
|
||||
@@ -16,9 +16,17 @@ import {
|
||||
import { autoScrollForDragNearEdges } from '../utils/dragAutoScroll'
|
||||
import { SKILL_LEVEL_OPTIONS, normalizeSkillLevelSlug } from '../constants/skillLevels'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { useToast } from '../context/ToastContext'
|
||||
import {
|
||||
activeClubMemberships,
|
||||
getDefaultClubIdForGovernanceForms,
|
||||
getTenantClubDependencyKey,
|
||||
} from '../utils/activeClub'
|
||||
import { COMBINATION_ARCHETYPE_OPTIONS, ARCHETYPE_DEFAULT_REP_SERIES_COUNT, defaultRepSeriesCountForArchetype } from '../constants/combinationArchetypes'
|
||||
import { readSlotProfilesV1, normalizeAdvanceMode, parseComboRepSeriesCountUi } from '../utils/combinationMethodProfileUi'
|
||||
import { GripVertical } from 'lucide-react'
|
||||
import UnsavedChangesPrompt from '../components/UnsavedChangesPrompt'
|
||||
import { useBeforeUnloadWhen, useUnsavedChangesBlocker } from '../hooks/useUnsavedChangesBlocker'
|
||||
|
||||
const INTENSITY_OPTIONS = [
|
||||
{ value: '', label: '—' },
|
||||
@@ -322,6 +330,7 @@ function emptyForm() {
|
||||
training_types_multi: [],
|
||||
target_groups_multi: [],
|
||||
visibility: 'private',
|
||||
club_id: null,
|
||||
status: 'draft',
|
||||
skills: [],
|
||||
exercise_kind: 'simple',
|
||||
@@ -361,6 +370,12 @@ function detailToForm(exercise) {
|
||||
is_primary: !!g.is_primary,
|
||||
})),
|
||||
visibility: exercise.visibility || 'private',
|
||||
club_id:
|
||||
String(exercise.visibility || '').trim().toLowerCase() === 'club' &&
|
||||
exercise.club_id != null &&
|
||||
exercise.club_id !== ''
|
||||
? Number(exercise.club_id)
|
||||
: null,
|
||||
status: exercise.status || 'draft',
|
||||
skills:
|
||||
exercise.skills?.map((s) => ({
|
||||
@@ -455,6 +470,45 @@ function ExerciseFormPage() {
|
||||
const navigate = useNavigate()
|
||||
const { user } = useAuth()
|
||||
const isSuperadmin = user?.role === 'superadmin'
|
||||
const isPlatformAdmin = user?.role === 'admin' || user?.role === 'superadmin'
|
||||
const tenantClubDepKey = useMemo(() => getTenantClubDependencyKey(user), [user])
|
||||
|
||||
const [clubsForGovernanceForms, setClubsForGovernanceForms] = useState([])
|
||||
useEffect(() => {
|
||||
if (!isPlatformAdmin) {
|
||||
setClubsForGovernanceForms([])
|
||||
return undefined
|
||||
}
|
||||
let cancelled = false
|
||||
;(async () => {
|
||||
try {
|
||||
const list = await api.listClubs()
|
||||
if (!cancelled) setClubsForGovernanceForms(Array.isArray(list) ? list : [])
|
||||
} catch {
|
||||
if (!cancelled) setClubsForGovernanceForms([])
|
||||
}
|
||||
})()
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [isPlatformAdmin, tenantClubDepKey])
|
||||
|
||||
const membershipClubRows = useMemo(() => activeClubMemberships(user?.clubs), [user?.clubs])
|
||||
|
||||
/** Plattform-Admin: alle Vereine; sonst nur Mitgliedschafts-Vereine. */
|
||||
const visibilityClubChoices = useMemo(() => {
|
||||
if (isPlatformAdmin && clubsForGovernanceForms.length > 0) {
|
||||
return [...clubsForGovernanceForms].sort((a, b) =>
|
||||
String(a.name || '').localeCompare(String(b.name || ''), 'de'),
|
||||
)
|
||||
}
|
||||
return [...membershipClubRows].sort((a, b) =>
|
||||
String(a.name || '').localeCompare(String(b.name || ''), 'de'),
|
||||
)
|
||||
}, [isPlatformAdmin, clubsForGovernanceForms, membershipClubRows])
|
||||
|
||||
const governanceDefaultClubId = useMemo(() => getDefaultClubIdForGovernanceForms(user), [user])
|
||||
|
||||
const exerciseId = routeId && !Number.isNaN(parseInt(routeId, 10)) ? parseInt(routeId, 10) : null
|
||||
const isEdit = exerciseId != null
|
||||
|
||||
@@ -469,6 +523,11 @@ function ExerciseFormPage() {
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [formDirty, setFormDirty] = useState(false)
|
||||
const [skillPick, setSkillPick] = useState('')
|
||||
|
||||
const toast = useToast()
|
||||
const allowUnloadBlock = Boolean(formDirty && !loading && !saving)
|
||||
useBeforeUnloadWhen(allowUnloadBlock)
|
||||
const blocker = useUnsavedChangesBlocker(allowUnloadBlock)
|
||||
const [variants, setVariants] = useState([])
|
||||
const [variantDraft, setVariantDraft] = useState(() => emptyVariantDraft())
|
||||
const [variantSavingId, setVariantSavingId] = useState(null)
|
||||
@@ -507,15 +566,7 @@ function ExerciseFormPage() {
|
||||
return () => document.removeEventListener('dragover', onDragOverDoc)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (!formDirty) return undefined
|
||||
const warn = (ev) => {
|
||||
ev.preventDefault()
|
||||
ev.returnValue = ''
|
||||
}
|
||||
window.addEventListener('beforeunload', warn)
|
||||
return () => window.removeEventListener('beforeunload', warn)
|
||||
}, [formDirty])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!archiveOpen) return undefined
|
||||
@@ -561,7 +612,7 @@ function ExerciseFormPage() {
|
||||
} catch (e) {
|
||||
if (!cancelled) {
|
||||
console.error(e)
|
||||
alert(
|
||||
toast.error(
|
||||
'Kataloge (Fokus, Stile, Zielgruppen, Fähigkeiten) konnten nicht geladen werden: ' +
|
||||
(e.message || e),
|
||||
)
|
||||
@@ -572,7 +623,7 @@ function ExerciseFormPage() {
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [])
|
||||
}, [toast])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEdit) {
|
||||
@@ -599,7 +650,7 @@ function ExerciseFormPage() {
|
||||
setFormDirty(false)
|
||||
} catch (err) {
|
||||
if (!cancelled) {
|
||||
alert(err.message || 'Übung nicht ladbar')
|
||||
toast.error(err.message || 'Übung nicht ladbar')
|
||||
navigate('/exercises')
|
||||
}
|
||||
} finally {
|
||||
@@ -610,7 +661,7 @@ function ExerciseFormPage() {
|
||||
return () => {
|
||||
cancelled = true
|
||||
}
|
||||
}, [isEdit, exerciseId, navigate])
|
||||
}, [isEdit, exerciseId, navigate, toast])
|
||||
|
||||
useEffect(() => {
|
||||
if (variantEditSelection == null || variantEditSelection === 'new') return
|
||||
@@ -630,6 +681,38 @@ function ExerciseFormPage() {
|
||||
setFormData((prev) => ({ ...prev, [field]: value }))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (formData.visibility !== 'club') return
|
||||
const choices = visibilityClubChoices
|
||||
if (!choices.length) return
|
||||
|
||||
const id =
|
||||
formData.club_id != null && formData.club_id !== '' ? Number(formData.club_id) : NaN
|
||||
const hasValid =
|
||||
Number.isFinite(id) && id > 0 && choices.some((c) => Number(c.id) === id)
|
||||
|
||||
if (hasValid) return
|
||||
|
||||
const fallback = governanceDefaultClubId
|
||||
const next =
|
||||
fallback != null &&
|
||||
Number.isFinite(Number(fallback)) &&
|
||||
choices.some((c) => Number(c.id) === Number(fallback))
|
||||
? Number(fallback)
|
||||
: Number(choices[0].id)
|
||||
|
||||
setFormData((prev) => {
|
||||
if (prev.visibility !== 'club') return prev
|
||||
if (prev.club_id != null && Number(prev.club_id) === next) return prev
|
||||
return { ...prev, club_id: next }
|
||||
})
|
||||
}, [
|
||||
formData.visibility,
|
||||
formData.club_id,
|
||||
visibilityClubChoices,
|
||||
governanceDefaultClubId,
|
||||
])
|
||||
|
||||
const [comboStationPickerIx, setComboStationPickerIx] = useState(null)
|
||||
const [comboDropTargetIx, setComboDropTargetIx] = useState(null)
|
||||
|
||||
@@ -686,7 +769,7 @@ function ExerciseFormPage() {
|
||||
})
|
||||
let nextIds = ordered
|
||||
if (nextIds.length > MAX_COMBO_CANDIDATES_PER_STATION) {
|
||||
window.alert(
|
||||
toast.info(
|
||||
`Pro Station höchstens ${MAX_COMBO_CANDIDATES_PER_STATION} Übungen — üblich eine feste Übung; zwei bis drei nur als kleiner Wechsel‑Pool. Überschüssige Auswahl wurde abgeschnitten.`,
|
||||
)
|
||||
nextIds = nextIds.slice(0, MAX_COMBO_CANDIDATES_PER_STATION)
|
||||
@@ -712,11 +795,11 @@ function ExerciseFormPage() {
|
||||
const addSkillRow = () => {
|
||||
const id = skillPick ? parseInt(skillPick, 10) : null
|
||||
if (!id) {
|
||||
alert('Fähigkeit wählen')
|
||||
toast.error('Fähigkeit wählen')
|
||||
return
|
||||
}
|
||||
if (formData.skills.some((s) => s.skill_id === id)) {
|
||||
alert('Bereits zugeordnet')
|
||||
toast.info('Bereits zugeordnet')
|
||||
return
|
||||
}
|
||||
updateFormField('skills', [
|
||||
@@ -752,121 +835,138 @@ function ExerciseFormPage() {
|
||||
updateFormField('skills', next)
|
||||
}
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
if (!formData.title || formData.title.trim().length < 3) {
|
||||
alert('Titel mindestens 3 Zeichen')
|
||||
return
|
||||
}
|
||||
const payloadBase = {
|
||||
...formData,
|
||||
equipment:
|
||||
typeof formData.equipmentLines === 'string'
|
||||
? formData.equipmentLines
|
||||
.split(/[\n,]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
: [],
|
||||
}
|
||||
let payload
|
||||
try {
|
||||
payload = buildExerciseApiPayload(payloadBase)
|
||||
} catch (err) {
|
||||
alert(err.message)
|
||||
return
|
||||
}
|
||||
setSaving(true)
|
||||
try {
|
||||
if (isEdit) {
|
||||
const saveOnce = (extras = {}) =>
|
||||
api.updateExercise(exerciseId, buildExerciseApiPayload(payloadBase, extras))
|
||||
try {
|
||||
await saveOnce()
|
||||
} catch (firstErr) {
|
||||
if (
|
||||
firstErr.status === 422 &&
|
||||
firstErr.code === 'OFFICIAL_MEDIA_LIFECYCLE' &&
|
||||
firstErr.payload?.media_assets
|
||||
) {
|
||||
alert(
|
||||
'Speichern nicht möglich: mindestens ein verknüpftes Medium ist nicht aktiv (Papierkorb). ' +
|
||||
'Bitte Medium wiederherstellen oder aus der Übung entfernen.',
|
||||
)
|
||||
throw firstErr
|
||||
}
|
||||
if (firstErr.status === 422 && firstErr.code === 'OFFICIAL_MEDIA_CONFIRM_REQUIRED') {
|
||||
const promo = (firstErr.payload.assets_need_visibility_promotion || []).length
|
||||
const miss = (firstErr.payload.assets_missing_copyright || []).length
|
||||
let msg =
|
||||
'Die Übung ist oder wird offiziell. '
|
||||
if (promo > 0) {
|
||||
msg += `${promo} verknüpfte Datei(en) werden dabei plattformweit („offiziell“) freigegeben. `
|
||||
const performSaveAttempt = useCallback(
|
||||
async ({ fromUnsavedDialog = false } = {}) => {
|
||||
if (!formData.title || formData.title.trim().length < 3) {
|
||||
toast.error('Titel mindestens 3 Zeichen')
|
||||
return false
|
||||
}
|
||||
const payloadBase = {
|
||||
...formData,
|
||||
equipment:
|
||||
typeof formData.equipmentLines === 'string'
|
||||
? formData.equipmentLines
|
||||
.split(/[\n,]+/)
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean)
|
||||
: [],
|
||||
}
|
||||
let payload
|
||||
try {
|
||||
payload = buildExerciseApiPayload(payloadBase)
|
||||
} catch (err) {
|
||||
toast.error(err.message)
|
||||
return false
|
||||
}
|
||||
setSaving(true)
|
||||
try {
|
||||
if (isEdit) {
|
||||
const saveOnce = (extras = {}) =>
|
||||
api.updateExercise(exerciseId, buildExerciseApiPayload(payloadBase, extras))
|
||||
try {
|
||||
await saveOnce()
|
||||
} catch (firstErr) {
|
||||
if (
|
||||
firstErr.status === 422 &&
|
||||
firstErr.code === 'OFFICIAL_MEDIA_LIFECYCLE' &&
|
||||
firstErr.payload?.media_assets
|
||||
) {
|
||||
toast.error(
|
||||
'Speichern nicht möglich: mindestens ein verknüpftes Medium ist nicht aktiv (Papierkorb). ' +
|
||||
'Bitte Medium wiederherstellen oder aus der Übung entfernen.',
|
||||
)
|
||||
throw firstErr
|
||||
}
|
||||
if (miss > 0) {
|
||||
msg += `${miss} Datei(en) haben noch keinen ausreichenden Copyright-Vermerk (mind. 3 Zeichen). `
|
||||
}
|
||||
msg += 'Fortfahren?'
|
||||
if (!window.confirm(msg)) throw firstErr
|
||||
let defaultCopyright = ''
|
||||
if (miss > 0) {
|
||||
defaultCopyright = window.prompt(
|
||||
'Copyright-Vermerk für betroffene Dateien ohne Eintrag (mind. 3 Zeichen):',
|
||||
if (firstErr.status === 422 && firstErr.code === 'OFFICIAL_MEDIA_CONFIRM_REQUIRED') {
|
||||
const promo = (firstErr.payload.assets_need_visibility_promotion || []).length
|
||||
const miss = (firstErr.payload.assets_missing_copyright || []).length
|
||||
let msg = 'Die Übung ist oder wird offiziell. '
|
||||
if (promo > 0) {
|
||||
msg += `${promo} verknüpfte Datei(en) werden dabei plattformweit („offiziell“) freigegeben. `
|
||||
}
|
||||
if (miss > 0) {
|
||||
msg += `${miss} Datei(en) haben noch keinen ausreichenden Copyright-Vermerk (mind. 3 Zeichen). `
|
||||
}
|
||||
msg += 'Fortfahren?'
|
||||
if (!window.confirm(msg)) throw firstErr
|
||||
let defaultCopyright = ''
|
||||
if (miss > 0) {
|
||||
defaultCopyright = window.prompt(
|
||||
'Copyright-Vermerk für betroffene Dateien ohne Eintrag (mind. 3 Zeichen):',
|
||||
'© ',
|
||||
)
|
||||
if (!defaultCopyright || String(defaultCopyright).trim().length < 3) {
|
||||
toast.error('Mindestens 3 Zeichen für den Copyright-Vermerk.')
|
||||
throw firstErr
|
||||
}
|
||||
}
|
||||
await saveOnce({
|
||||
promote_attached_media_for_official: true,
|
||||
...(miss > 0 ? { default_official_media_copyright: String(defaultCopyright).trim() } : {}),
|
||||
})
|
||||
} else if (
|
||||
firstErr.status === 422 &&
|
||||
firstErr.code === 'CLUB_MEDIA_COPYRIGHT_REQUIRED' &&
|
||||
firstErr.payload?.media_assets
|
||||
) {
|
||||
const miss = firstErr.payload.media_assets.length
|
||||
const msg =
|
||||
`Vereinsöffentliche Übungen brauchen bei jeder verknüpften Datei einen Copyright-Vermerk (mind. 3 Zeichen). ` +
|
||||
`${miss} Datei(en) sind noch ohne ausreichenden Vermerk. ` +
|
||||
`Beim Speichern einen gemeinsamen Vermerk für diese Dateien setzen?`
|
||||
if (!window.confirm(msg)) throw firstErr
|
||||
const defaultCopyright = window.prompt(
|
||||
'Copyright-Vermerk für die betroffenen Dateien (mind. 3 Zeichen):',
|
||||
'© ',
|
||||
)
|
||||
if (!defaultCopyright || String(defaultCopyright).trim().length < 3) {
|
||||
alert('Mindestens 3 Zeichen für den Copyright-Vermerk.')
|
||||
toast.error('Mindestens 3 Zeichen für den Copyright-Vermerk.')
|
||||
throw firstErr
|
||||
}
|
||||
}
|
||||
await saveOnce({
|
||||
promote_attached_media_for_official: true,
|
||||
...(miss > 0 ? { default_official_media_copyright: String(defaultCopyright).trim() } : {}),
|
||||
})
|
||||
} else if (
|
||||
firstErr.status === 422 &&
|
||||
firstErr.code === 'CLUB_MEDIA_COPYRIGHT_REQUIRED' &&
|
||||
firstErr.payload?.media_assets
|
||||
) {
|
||||
const miss = firstErr.payload.media_assets.length
|
||||
const msg =
|
||||
`Vereinsöffentliche Übungen brauchen bei jeder verknüpften Datei einen Copyright-Vermerk (mind. 3 Zeichen). ` +
|
||||
`${miss} Datei(en) sind noch ohne ausreichenden Vermerk. ` +
|
||||
`Beim Speichern einen gemeinsamen Vermerk für diese Dateien setzen?`
|
||||
if (!window.confirm(msg)) throw firstErr
|
||||
const defaultCopyright = window.prompt(
|
||||
'Copyright-Vermerk für die betroffenen Dateien (mind. 3 Zeichen):',
|
||||
'© ',
|
||||
)
|
||||
if (!defaultCopyright || String(defaultCopyright).trim().length < 3) {
|
||||
alert('Mindestens 3 Zeichen für den Copyright-Vermerk.')
|
||||
await saveOnce({
|
||||
default_club_media_copyright: String(defaultCopyright).trim(),
|
||||
})
|
||||
} else if (firstErr.status === 422 && firstErr.code === 'CLUB_MEDIA_LIFECYCLE') {
|
||||
toast.error(
|
||||
'Speichern nicht möglich: mindestens ein verknüpftes Medium ist nicht aktiv (Papierkorb). Bitte reaktivieren oder entfernen.',
|
||||
)
|
||||
throw firstErr
|
||||
} else {
|
||||
throw firstErr
|
||||
}
|
||||
await saveOnce({
|
||||
default_club_media_copyright: String(defaultCopyright).trim(),
|
||||
})
|
||||
} else if (firstErr.status === 422 && firstErr.code === 'CLUB_MEDIA_LIFECYCLE') {
|
||||
alert(
|
||||
'Speichern nicht möglich: mindestens ein verknüpftes Medium ist nicht aktiv (Papierkorb). Bitte reaktivieren oder entfernen.',
|
||||
)
|
||||
throw firstErr
|
||||
} else {
|
||||
throw firstErr
|
||||
}
|
||||
const ex = await api.getExercise(exerciseId)
|
||||
setMediaList(ex.media || [])
|
||||
setVariants((ex.variants || []).map(apiVariantToRow))
|
||||
setFormDirty(false)
|
||||
toast.success('Gespeichert.')
|
||||
return true
|
||||
}
|
||||
const ex = await api.getExercise(exerciseId)
|
||||
setMediaList(ex.media || [])
|
||||
setVariants((ex.variants || []).map(apiVariantToRow))
|
||||
setFormDirty(false)
|
||||
alert('Gespeichert.')
|
||||
} else {
|
||||
const created = await api.createExercise(payload)
|
||||
navigate(`/exercises/${created.id}/edit`, { replace: true })
|
||||
setFormDirty(false)
|
||||
toast.success('Übung angelegt.')
|
||||
if (!fromUnsavedDialog) {
|
||||
navigate(`/exercises/${created.id}/edit`, { replace: true })
|
||||
}
|
||||
return true
|
||||
} catch (err) {
|
||||
toast.error('Fehler beim Speichern: ' + err.message)
|
||||
return false
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
} catch (err) {
|
||||
alert('Fehler beim Speichern: ' + err.message)
|
||||
} finally {
|
||||
setSaving(false)
|
||||
}
|
||||
},
|
||||
[exerciseId, formData, isEdit, navigate, toast],
|
||||
)
|
||||
|
||||
const handleSubmit = async (e) => {
|
||||
e.preventDefault()
|
||||
await performSaveAttempt({ fromUnsavedDialog: false })
|
||||
}
|
||||
|
||||
const handleUnsavedDialogSave = async () => {
|
||||
const ok = await performSaveAttempt({ fromUnsavedDialog: true })
|
||||
if (ok) blocker.proceed()
|
||||
}
|
||||
|
||||
const refreshMedia = async () => {
|
||||
@@ -888,7 +988,7 @@ function ExerciseFormPage() {
|
||||
setArchiveOpen(false)
|
||||
await refreshMedia()
|
||||
} catch (e) {
|
||||
alert(e.message || String(e))
|
||||
toast.error(e.message || String(e))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -921,7 +1021,7 @@ function ExerciseFormPage() {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
alert(err.message)
|
||||
toast.error(err.message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -940,7 +1040,7 @@ function ExerciseFormPage() {
|
||||
)
|
||||
setMediaList(next)
|
||||
} catch (e) {
|
||||
alert(e.message || String(e))
|
||||
toast.error(e.message || String(e))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -955,7 +1055,7 @@ function ExerciseFormPage() {
|
||||
})
|
||||
await refreshMedia()
|
||||
} catch (e) {
|
||||
alert(e.message || String(e))
|
||||
toast.error(e.message || String(e))
|
||||
} finally {
|
||||
setMediaSavingId(null)
|
||||
}
|
||||
@@ -975,7 +1075,7 @@ function ExerciseFormPage() {
|
||||
const saveVariantRow = async (row) => {
|
||||
const payload = buildVariantPayloadFromRow(row)
|
||||
if (payload.variant_name.length < 3) {
|
||||
alert('Variantenname mindestens 3 Zeichen')
|
||||
toast.error('Variantenname mindestens 3 Zeichen')
|
||||
return
|
||||
}
|
||||
setVariantSavingId(row.id)
|
||||
@@ -983,7 +1083,7 @@ function ExerciseFormPage() {
|
||||
await api.updateExerciseVariant(exerciseId, row.id, payload)
|
||||
await refreshVariants()
|
||||
} catch (e) {
|
||||
alert(e.message || String(e))
|
||||
toast.error(e.message || String(e))
|
||||
} finally {
|
||||
setVariantSavingId(null)
|
||||
}
|
||||
@@ -997,7 +1097,7 @@ function ExerciseFormPage() {
|
||||
if (variantEditSelection === id) setVariantEditSelection(null)
|
||||
await refreshVariants()
|
||||
} catch (e) {
|
||||
alert(e.message || String(e))
|
||||
toast.error(e.message || String(e))
|
||||
} finally {
|
||||
setVariantBusy(false)
|
||||
}
|
||||
@@ -1016,7 +1116,7 @@ function ExerciseFormPage() {
|
||||
await api.reorderExerciseVariants(exerciseId, ids)
|
||||
await refreshVariants()
|
||||
} catch (e) {
|
||||
alert(e.message || String(e))
|
||||
toast.error(e.message || String(e))
|
||||
} finally {
|
||||
setVariantBusy(false)
|
||||
}
|
||||
@@ -1027,7 +1127,7 @@ function ExerciseFormPage() {
|
||||
if (!exerciseId) return
|
||||
const payload = buildVariantPayloadFromRow(variantDraft)
|
||||
if (payload.variant_name.length < 3) {
|
||||
alert('Variantenname mindestens 3 Zeichen')
|
||||
toast.error('Variantenname mindestens 3 Zeichen')
|
||||
return
|
||||
}
|
||||
setVariantBusy(true)
|
||||
@@ -1038,7 +1138,7 @@ function ExerciseFormPage() {
|
||||
if (created?.id != null) setVariantEditSelection(created.id)
|
||||
else setVariantEditSelection(null)
|
||||
} catch (err) {
|
||||
alert(err.message || String(err))
|
||||
toast.error(err.message || String(err))
|
||||
} finally {
|
||||
setVariantBusy(false)
|
||||
}
|
||||
@@ -1072,18 +1172,7 @@ function ExerciseFormPage() {
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ marginLeft: '8px' }}
|
||||
onClick={() => {
|
||||
if (
|
||||
formDirty &&
|
||||
!window.confirm(
|
||||
'Es gibt noch nicht über „Speichern“ gesicherte Änderungen (Texte, Zuordnungen, …).\n\n' +
|
||||
'Zur Ansicht wechseln und diese Änderungen verwerfen?',
|
||||
)
|
||||
) {
|
||||
return
|
||||
}
|
||||
navigate(`/exercises/${exerciseId}`, { state: { fromExerciseEdit: true } })
|
||||
}}
|
||||
onClick={() => navigate(`/exercises/${exerciseId}`, { state: { fromExerciseEdit: true } })}
|
||||
>
|
||||
Ansehen
|
||||
</button>
|
||||
@@ -1832,6 +1921,29 @@ function ExerciseFormPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{formData.visibility === 'club' && visibilityClubChoices.length > 0 ? (
|
||||
<div className="form-row" style={{ marginTop: '10px' }}>
|
||||
<label className="form-label">Verein (Sichtbarkeit)</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={formData.club_id != null && formData.club_id !== '' ? String(formData.club_id) : ''}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value
|
||||
updateFormField('club_id', v === '' ? null : Number(v))
|
||||
}}
|
||||
>
|
||||
{visibilityClubChoices.map((c) => (
|
||||
<option key={c.id} value={String(c.id)}>
|
||||
{(c.name || '').trim() || `Verein #${c.id}`}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<p style={{ margin: '6px 0 0', fontSize: '12px', color: 'var(--text3)', lineHeight: 1.4 }}>
|
||||
Standard ist der aktive Verein aus der Navigation. Bei Plattform-Admins sind alle Vereine wählbar.
|
||||
</p>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div style={{ marginTop: '16px' }}>
|
||||
<button type="submit" className="btn btn-primary" disabled={saving}>
|
||||
{saving ? 'Speichern…' : isEdit ? 'Speichern' : 'Anlegen & weiter'}
|
||||
@@ -2321,6 +2433,12 @@ function ExerciseFormPage() {
|
||||
<code>OPENROUTER_API_KEY</code>, Vorschläge nur nach Trainer-Bestätigung übernehmen (siehe{' '}
|
||||
<code>api.suggestExerciseAi</code>).
|
||||
</p>
|
||||
<UnsavedChangesPrompt
|
||||
blocker={blocker}
|
||||
isBusy={saving}
|
||||
onSave={handleUnsavedDialogSave}
|
||||
onDiscardWithoutSave={() => setFormDirty(false)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user