Skip to content
Snippets Groups Projects
Commit 97af7806 authored by Lars Kollmann's avatar Lars Kollmann
Browse files

#370 add nullchecks to prevent errors when entity is null

parent a5e4a3c8
No related branches found
No related tags found
2 merge requests!377merge develop in to master,!348Resolve "Umzug der gen.Filter"
Pipeline #421467 passed
......@@ -221,23 +221,29 @@ export default class SharedTable extends Vue {
let imageRefsUrl: Array<{}> = [];
const sectionInfo: Array<{}> = [];
for (const userEdge of item.users.collection) {
observers.push(userEdge.username);
if (item.users) {
for (const userEdge of item.users.collection) {
observers.push(userEdge.username);
}
observers.join(", ");
}
observers.join(", ");
item.sectionEvents.collection.forEach((event) => {
imageRefsUrl = [];
if (event.imageRefs.collection.length) {
event.imageRefs.collection.forEach((imageRef) => {
imageRef.thumbnailRefs.collection.filter((thumbnailRef) => {
if (thumbnailRef.url.includes("medium")) {
imageRefsUrl.push({imageRefUrl: imageRef.url, thumbnailRefUrl: thumbnailRef.url});
}
if (item.sectionEvents) {
item.sectionEvents.collection.forEach((event) => {
imageRefsUrl = [];
if (event.imageRefs.collection.length) {
event.imageRefs.collection.forEach((imageRef) => {
imageRef.thumbnailRefs.collection.filter((thumbnailRef) => {
if (thumbnailRef.url.includes("medium")) {
imageRefsUrl.push({imageRefUrl: imageRef.url, thumbnailRefUrl: thumbnailRef.url});
}
});
});
});
sectionInfo.push({sectionComment: event.comment, sectionName: event.section.name, sectionLabel: event.section.label, imageUrl: imageRefsUrl});
}
});
sectionInfo.push({sectionComment: event.comment, sectionName: event.section.name, sectionLabel: event.section.label, imageUrl: imageRefsUrl});
}
});
}
const newItem = {
id: item.id.replace(/^\D+/g, ""),
inspectionId: item.id.replace(/^\D+/g, ""),
......@@ -301,7 +307,7 @@ export default class SharedTable extends Vue {
for (const item of this.data.data.observations.collection) {
const developmentalStageId = item.developmentalStage.id.replace( /^\D+/g, "");
const imageRefsUrl: Array<{}> = [];
if (item.imageRefs.collection.length) {
if (this.hasImageRefs(item)) {
item.imageRefs.collection.forEach((image) => {
image.thumbnailRefs.collection.filter((thumbnailRef) => {
if (thumbnailRef.url.includes("medium")) {
......@@ -522,15 +528,19 @@ export default class SharedTable extends Vue {
}
}
private isValidInspectionData(data: AxiosResponse) {
private isValidInspectionData(data: AxiosResponse): boolean {
return data && data.data && data.data.inspections && data.data.inspections.collection;
}
private isValidApplyFiltersData(data: AxiosResponse) {
private isValidApplyFiltersData(data: AxiosResponse): boolean {
return data && data.data && data.data.applyFilters && data.data.applyFilters.collection;
}
private isValidObservationsData(data: AxiosResponse) {
private isValidObservationsData(data: AxiosResponse): boolean {
return data && data.data && data.data.observations && data.data.observations.collection;
}
private hasImageRefs(item: any): boolean {
return item.imageRefs && item.imageRefs.collection && item.imageRefs.collection.length;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment