Mehrere Auswahlen in einem Objekt speichern

- Neues JSON-Feld 'selections' in Directus objects-Collection
- Alle Auswahlen (bbox/polygon) landen in einem einzigen Objekt
- Erste Auswahl bleibt weiterhin in bbox/polygon für Kompatibilität
- GET-Proxy liefert selections-Feld mit aus

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-25 21:23:22 +02:00
parent 8219a5445c
commit 807c733770
4 changed files with 14 additions and 15 deletions

View File

@@ -88,24 +88,21 @@ export default function DrawIt() {
if (!currentPicture || !token || currentSelections.length === 0) return
setSaving(true)
try {
// Save one object per selection
const newObjs: DirectusObject[] = []
for (const sel of currentSelections) {
const obj = await createDirectusObject({
picture: currentPicture.id,
bbox: sel.mode === 'rect' ? (sel.bbox ?? null) : null,
polygon: sel.mode === 'polygon' ? (sel.polygon ?? null) : null,
user_notes: userNotes.trim() || null,
parent: parentId,
}, token)
newObjs.push({ ...obj, visible: true })
}
setObjects(prev => [...prev, ...newObjs])
const first = currentSelections[0]
const obj = await createDirectusObject({
picture: currentPicture.id,
bbox: first.mode === 'rect' ? (first.bbox ?? null) : null,
polygon: first.mode === 'polygon' ? (first.polygon ?? null) : null,
selections: currentSelections,
user_notes: userNotes.trim() || null,
parent: parentId,
}, token)
setObjects(prev => [...prev, { ...obj, visible: true }])
setCurrentSelections([])
setUserNotes('')
setParentId(null)
canvasRef.current?.resetSelection()
showStatus(`${newObjs.length} Objekt(e) gespeichert.`)
showStatus('Objekt gespeichert.')
} catch (e) {
showStatus(e instanceof Error ? e.message : 'Fehler beim Speichern.', true)
} finally {