Refine image validation logic in DiaryView to ensure accurate image handling

This commit enhances the image validation process in DiaryView by adding checks to confirm the presence of valid image IDs in the imageLink and verifying the existence of images in the associated array. This improvement ensures that only actual images are processed, leading to better data integrity and user experience.
This commit is contained in:
Torsten Schulz (local)
2025-11-16 22:06:02 +01:00
parent 1c99fb30a1
commit 9cc9db3a5a

View File

@@ -1019,8 +1019,17 @@ export default {
// gerenderter Code / renderSpec
if (pa.renderCode && pa.renderCode.trim() !== '') return true;
if (pa.renderSpec && Object.keys(pa.renderSpec).length) return true;
// imageLink für normale Bilder
if (pa.imageLink && pa.imageLink.trim() !== '') return true;
// imageLink für normale Bilder - nur wenn es tatsächlich ein Bild gibt
// imageLink enthält eine Image-ID (z.B. /image/123), wenn ein Bild vorhanden ist
// Der Fallback-Pfad ohne Image-ID (/image) wird ignoriert
if (pa.imageLink && pa.imageLink.trim() !== '') {
// Prüfe, ob imageLink eine Image-ID enthält (dann ist es ein echtes Bild)
// Format: /api/predefined-activities/{id}/image/{imageId}
const imageIdMatch = pa.imageLink.match(/\/image\/(\d+)/);
if (imageIdMatch) return true;
// Oder prüfe, ob images Array vorhanden ist (dann gibt es Bilder)
if (Array.isArray(pa.images) && pa.images.length > 0) return true;
}
} catch (e) { }
return false;
},