diff --git a/src/pages/ContentCreation.jsx b/src/pages/ContentCreation.jsx
index d37e313..f18dec0 100644
--- a/src/pages/ContentCreation.jsx
+++ b/src/pages/ContentCreation.jsx
@@ -1606,6 +1606,7 @@ export default function ContentCreation() {
const [loadingPairs, setLoadingPairs] = useState(false);
const [markingDone, setMarkingDone] = useState(false);
+ const [deletingPicture, setDeletingPicture] = useState(false);
const currentPicture = pictures[pictureIndex] || null;
const selectedObjectId = typeof mode === 'string' && mode !== 'add' ? mode : null;
@@ -1614,15 +1615,21 @@ export default function ContentCreation() {
? { ...selectedObject, _index: objects.indexOf(selectedObject) }
: null;
- // Load all pictures
+ // Load all pictures (published sind fertig und werden hier nicht mehr bearbeitet)
useEffect(() => {
setLoadingPictures(true);
apiFetch('/pictures?limit=500')
- .then(data => setPictures(Array.isArray(data) ? data : []))
+ .then(data => setPictures(Array.isArray(data) ? data.filter(p => p.status !== 'published') : []))
.catch(() => setPictures([]))
.finally(() => setLoadingPictures(false));
}, []);
+ // Index im gültigen Bereich halten, wenn die Liste schrumpft
+ useEffect(() => {
+ if (pictureIndex > 0 && pictureIndex >= pictures.length)
+ setPictureIndex(Math.max(0, pictures.length - 1));
+ }, [pictures.length, pictureIndex]);
+
// Load objects when picture changes
useEffect(() => {
if (!currentPicture) return;
@@ -1720,10 +1727,27 @@ export default function ContentCreation() {
if (!currentPicture) return;
try {
await apiPatch('/pictures', currentPicture.id, { status: newStatus });
- setPictures(prev => prev.map((p, i) => i === pictureIndex ? { ...p, status: newStatus } : p));
+ if (newStatus === 'published') {
+ // Veröffentlichte Bilder verschwinden aus der Bearbeitungs-Ansicht
+ setPictures(prev => prev.filter((_, i) => i !== pictureIndex));
+ } else {
+ setPictures(prev => prev.map((p, i) => i === pictureIndex ? { ...p, status: newStatus } : p));
+ }
} catch (e) { alert('Fehler: ' + e.message); }
}
+ async function handleDeletePicture() {
+ if (!currentPicture) return;
+ const ok = window.confirm('Bild endgültig löschen? Entfernt das Bild (S3 + Datenbank) inklusive aller Objekte und Pairs.');
+ if (!ok) return;
+ setDeletingPicture(true);
+ try {
+ await apiDelete('/pictures', currentPicture.id);
+ setPictures(prev => prev.filter((_, i) => i !== pictureIndex));
+ } catch (e) { alert('Fehler: ' + e.message); }
+ finally { setDeletingPicture(false); }
+ }
+
async function handleObjectStatusChange(objectId, newStatus) {
try {
await apiPatch('/objects', objectId, { status: newStatus });
@@ -1756,7 +1780,7 @@ export default function ContentCreation() {
function reloadPictures() {
apiFetch('/pictures?limit=500')
- .then(data => setPictures(Array.isArray(data) ? data : []))
+ .then(data => setPictures(Array.isArray(data) ? data.filter(p => p.status !== 'published') : []))
.catch(() => {});
}
@@ -1800,6 +1824,12 @@ export default function ContentCreation() {
{currentPicture.objects_created && (
✓ Objekte
)}
+
>
)}