feat: Training Types → Focus Area Hierarchie
Migration 013: - Adds focus_area_id to training_types (context-specific types) - Migrates existing data to Karate focus area - Seeds focus-area-specific training types: * Karate: Dan-Vorbereitung * Gewaltschutz: Präventivkurse, Intensivtraining, Spezialkurse * Fitness: Gesundheitssport, Funktionelles Training - Updates unique constraint to (name, focus_area_id) Backend (catalogs.py): - list_training_types: Added focus_area_id filter, LEFT JOIN focus_areas - create_training_type: Added focus_area_id parameter - update_training_type: Added focus_area_id parameter - Enriched responses with focus_area_name and focus_area_icon Frontend (AdminCatalogsPage): - Added Fokusbereich dropdown to create form - Added Fokusbereich dropdown to edit form - Display shows focus_area_icon and focus_area_name - Training types now context-specific to focus areas Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9f44cff77b
commit
fe5d29e40e
3 files changed
+212
-10
No files matched your search
@@ -24,7 +24,7 @@ export default function AdminCatalogsPage() {
|
||||
// Training Types (Breitensport, Leistungssport, etc.)
|
||||
const [trainingTypes, setTrainingTypes] = useState([])
|
||||
const [editingTT, setEditingTT] = useState(null)
|
||||
const [newTT, setNewTT] = useState({ name: '', abbreviation: '', description: '' })
|
||||
const [newTT, setNewTT] = useState({ name: '', abbreviation: '', description: '', focus_area_id: null })
|
||||
|
||||
// Skill Categories
|
||||
const [skillCategories, setSkillCategories] = useState([])
|
||||
@@ -201,7 +201,7 @@ export default function AdminCatalogsPage() {
|
||||
async function createTrainingType() {
|
||||
try {
|
||||
await api.createTrainingType(newTT)
|
||||
setNewTT({ name: '', abbreviation: '', description: '' })
|
||||
setNewTT({ name: '', abbreviation: '', description: '', focus_area_id: null })
|
||||
loadData()
|
||||
} catch (e) {
|
||||
setError(e.message)
|
||||
@@ -679,6 +679,19 @@ export default function AdminCatalogsPage() {
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Fokusbereich</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={newTT.focus_area_id || ''}
|
||||
onChange={e => setNewTT({ ...newTT, focus_area_id: e.target.value ? parseInt(e.target.value) : null })}
|
||||
>
|
||||
<option value="">- Fokusbereich auswählen -</option>
|
||||
{focusAreas.map(fa => (
|
||||
<option key={fa.id} value={fa.id}>{fa.icon} {fa.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<button className="btn btn-primary" onClick={createTrainingType}>Anlegen</button>
|
||||
</div>
|
||||
|
||||
@@ -712,6 +725,19 @@ export default function AdminCatalogsPage() {
|
||||
rows={3}
|
||||
/>
|
||||
</div>
|
||||
<div className="form-row">
|
||||
<label className="form-label">Fokusbereich</label>
|
||||
<select
|
||||
className="form-input"
|
||||
value={editingTT.focus_area_id || ''}
|
||||
onChange={e => setEditingTT({ ...editingTT, focus_area_id: e.target.value ? parseInt(e.target.value) : null })}
|
||||
>
|
||||
<option value="">- Fokusbereich auswählen -</option>
|
||||
{focusAreas.map(fa => (
|
||||
<option key={fa.id} value={fa.id}>{fa.icon} {fa.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: '8px' }}>
|
||||
<button className="btn btn-primary" onClick={() => updateTrainingType(tt.id, editingTT)}>Speichern</button>
|
||||
<button className="btn" onClick={() => setEditingTT(null)}>Abbrechen</button>
|
||||
@@ -724,6 +750,12 @@ export default function AdminCatalogsPage() {
|
||||
{tt.abbreviation && <span style={{ marginLeft: '8px', fontSize: '14px', color: 'var(--text2)' }}>({tt.abbreviation})</span>}
|
||||
</h3>
|
||||
{tt.description && <p style={{ margin: '8px 0', color: 'var(--text2)' }}>{tt.description}</p>}
|
||||
{tt.focus_area_name && (
|
||||
<p style={{ margin: '8px 0', fontSize: '14px' }}>
|
||||
<span style={{ color: 'var(--text2)' }}>Fokusbereich: </span>
|
||||
<span style={{ color: 'var(--accent)' }}>{tt.focus_area_icon} {tt.focus_area_name}</span>
|
||||
</p>
|
||||
)}
|
||||
<div style={{ display: 'flex', gap: '8px', marginTop: '12px' }}>
|
||||
<button className="btn" onClick={() => setEditingTT(tt)}>Bearbeiten</button>
|
||||
<button className="btn" onClick={() => deleteTrainingType(tt.id)}>Löschen</button>
|
||||
|
||||
Reference in new issue
Block a user