Enhance diary date activity service to include predefined activity images and improve image validation in DiaryView
This commit updates the DiaryDateActivityService to include associated images for predefined activities, enhancing the data structure. Additionally, it refines the image validation logic in DiaryView to check for both drawing data and standard images, ensuring a more robust handling of image data.
This commit is contained in:
@@ -166,6 +166,12 @@ class DiaryDateActivityService {
|
||||
{
|
||||
model: PredefinedActivity,
|
||||
as: 'groupPredefinedActivity',
|
||||
include: [
|
||||
{
|
||||
model: PredefinedActivityImage,
|
||||
as: 'images'
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -1004,16 +1004,23 @@ export default {
|
||||
if (typeof pa.drawingData === 'string' && pa.drawingData.trim() !== '') return true;
|
||||
if (typeof pa.drawingData === 'object' && Object.keys(pa.drawingData).length > 0) return true;
|
||||
}
|
||||
// Bildliste mit drawingData
|
||||
if (Array.isArray(pa.images) && pa.images.some(img => {
|
||||
if (!img || !img.drawingData) return false;
|
||||
if (typeof img.drawingData === 'string' && img.drawingData.trim() !== '') return true;
|
||||
if (typeof img.drawingData === 'object' && Object.keys(img.drawingData).length > 0) return true;
|
||||
return false;
|
||||
})) return true;
|
||||
// Bildliste - prüfe sowohl auf drawingData als auch auf normale Bilder
|
||||
if (Array.isArray(pa.images) && pa.images.length > 0) {
|
||||
// Prüfe auf Bilder mit drawingData
|
||||
if (pa.images.some(img => {
|
||||
if (!img || !img.drawingData) return false;
|
||||
if (typeof img.drawingData === 'string' && img.drawingData.trim() !== '') return true;
|
||||
if (typeof img.drawingData === 'object' && Object.keys(img.drawingData).length > 0) return true;
|
||||
return false;
|
||||
})) return true;
|
||||
// Prüfe auf normale Bilder (auch ohne drawingData)
|
||||
if (pa.images.some(img => img && (img.imagePath || img.id))) return true;
|
||||
}
|
||||
// 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;
|
||||
} catch (e) { }
|
||||
return false;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user