From 3be82dc8c20c7450fa418c7220909ec83bd9b6f3 Mon Sep 17 00:00:00 2001 From: Lars Date: Sat, 21 Mar 2026 19:46:11 +0100 Subject: [PATCH] feat: inline editing for activity mappings (improved UX) - Edit form now appears at the position of the item being edited - No scrolling needed - stays at same location - Matches ActivityPage inline editing behavior - Visual indicator: Accent border when editing - Create form still appears at top (separate from list) Benefits: - Better UX - no need to scroll to top - Easier to find edited item after saving - Consistent with rest of app Co-Authored-By: Claude Opus 4.6 --- .../src/pages/AdminActivityMappingsPage.jsx | 212 ++++++++++++------ 1 file changed, 146 insertions(+), 66 deletions(-) diff --git a/frontend/src/pages/AdminActivityMappingsPage.jsx b/frontend/src/pages/AdminActivityMappingsPage.jsx index c1a5c7b..ebf8414 100644 --- a/frontend/src/pages/AdminActivityMappingsPage.jsx +++ b/frontend/src/pages/AdminActivityMappingsPage.jsx @@ -195,22 +195,18 @@ export default function AdminActivityMappingsPage() { {/* Create new button */} - {!editingId && ( - - )} + - {/* Edit form */} - {editingId && formData && ( -
-
- {editingId === 'new' ? '➕ Neues Mapping' : '✏️ Mapping bearbeiten'} -
+ {/* New mapping form (only shown when creating) */} + {editingId === 'new' && formData && ( +
+
➕ Neues Mapping
@@ -220,8 +216,8 @@ export default function AdminActivityMappingsPage() { value={formData.activity_type} onChange={e => setFormData({ ...formData, activity_type: e.target.value })} placeholder="z.B. Traditionelles Krafttraining" - disabled={editingId !== 'new'} style={{ width: '100%' }} + autoFocus />
Groß-/Kleinschreibung beachten! Muss exakt mit CSV übereinstimmen. @@ -289,65 +285,149 @@ export default function AdminActivityMappingsPage() {
)} - {/* List */} + {/* List with inline editing */} {mappings.length === 0 ? (
Keine Mappings gefunden
) : (
- {mappings.map(mapping => ( -
-
-
{mapping.icon}
-
-
- {mapping.activity_type} + {mappings.map(mapping => { + const isEditing = editingId === mapping.id + + return ( +
+ {isEditing && formData ? ( + /* Inline edit form */ +
+
+ ✏️ Mapping bearbeiten +
+ +
+
+
Activity Type (nicht änderbar)
+ +
+ +
+
Training Type *
+ +
+ +
+
Profil-ID (leer = global)
+ setFormData({ ...formData, profile_id: e.target.value })} + placeholder="Leer lassen für globales Mapping" + style={{ width: '100%' }} + /> +
+ +
+ + +
+
-
- → {mapping.training_type_name_de} - {mapping.profile_id && <> · User-spezifisch} - {!mapping.profile_id && <> · Global} - {mapping.source && <> · {mapping.source}} + ) : ( + /* Normal view */ +
+
{mapping.icon}
+
+
+ {mapping.activity_type} +
+
+ → {mapping.training_type_name_de} + {mapping.profile_id && <> · User-spezifisch} + {!mapping.profile_id && <> · Global} + {mapping.source && <> · {mapping.source}} +
+
+ +
-
- - + )}
-
- ))} + ) + })}
)}