Polygon-Schließen per Button + M2M-Setup-Route entfernt
- Polygon kann nun mit ≥2 Punkten über den Button geschlossen werden - Button zeigt "Polygon schließen & hinzufügen" solange Polygon offen ist - Automatisches Schließen (Verbindung zum Startpunkt) beim Klick - Einmalige Setup-Route /api/directus/setup-m2m entfernt (nicht mehr benötigt) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -309,6 +309,20 @@ function drawImageAndSelection() {
|
||||
}
|
||||
}
|
||||
|
||||
function updateAddSelectionBtn() {
|
||||
if (!addSelectionBtn) return;
|
||||
if (mode === "polygon") {
|
||||
const canClose = polygonPoints.length >= 2 && !isPolygonClosed && currentFilename;
|
||||
const canAdd = isPolygonClosed && polygonPoints.length >= 3 && currentFilename;
|
||||
addSelectionBtn.disabled = !(canClose || canAdd);
|
||||
if (canClose && !canAdd) {
|
||||
addSelectionBtn.textContent = "🔒 Polygon schließen & hinzufügen";
|
||||
} else {
|
||||
addSelectionBtn.textContent = "➕ Auswahl hinzufügen";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function resetSelection() {
|
||||
isDragging = false;
|
||||
startX = startY = currentX = currentY = 0;
|
||||
@@ -316,6 +330,7 @@ function resetSelection() {
|
||||
isPolygonClosed = false;
|
||||
if (addSelectionBtn) {
|
||||
addSelectionBtn.disabled = true;
|
||||
addSelectionBtn.textContent = "➕ Auswahl hinzufügen";
|
||||
}
|
||||
drawImageAndSelection();
|
||||
}
|
||||
@@ -381,10 +396,15 @@ function addCurrentSelection() {
|
||||
},
|
||||
};
|
||||
} else if (mode === "polygon") {
|
||||
if (!isPolygonClosed || polygonPoints.length < 3) {
|
||||
setStatus("Bitte Polygon mit Doppelklick schließen (mind. 3 Punkte).", true);
|
||||
if (polygonPoints.length < 3) {
|
||||
setStatus("Polygon braucht mindestens 3 Punkte.", true);
|
||||
return;
|
||||
}
|
||||
// Automatisch schließen falls noch nicht geschlossen
|
||||
if (!isPolygonClosed) {
|
||||
isPolygonClosed = true;
|
||||
drawImageAndSelection();
|
||||
}
|
||||
selection = {
|
||||
mode: "polygon",
|
||||
polygon: polygonPoints.map((p) => ({
|
||||
@@ -814,6 +834,7 @@ if (canvas) {
|
||||
}
|
||||
polygonPoints.push({ x, y });
|
||||
isDragging = true;
|
||||
updateAddSelectionBtn();
|
||||
}
|
||||
drawImageAndSelection();
|
||||
});
|
||||
@@ -839,15 +860,14 @@ if (canvas) {
|
||||
const h = Math.abs(currentY - startY);
|
||||
if (addSelectionBtn) {
|
||||
addSelectionBtn.disabled = w <= 0 || h <= 0 || !currentFilename;
|
||||
addSelectionBtn.textContent = "➕ Auswahl hinzufügen";
|
||||
}
|
||||
} else if (mode === "polygon") {
|
||||
// Doppelklick = Polygon schließen
|
||||
if (e.detail === 2 && polygonPoints.length >= 3) {
|
||||
isPolygonClosed = true;
|
||||
if (addSelectionBtn) {
|
||||
addSelectionBtn.disabled = !currentFilename;
|
||||
}
|
||||
}
|
||||
updateAddSelectionBtn();
|
||||
}
|
||||
drawImageAndSelection();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user