Skip to content
Snippets Groups Projects
Commit e3e41c32 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Handle missing neighbor data when switching to another element

parent a528f152
No related branches found
No related tags found
1 merge request!1152Handle missing neighbor data when switching to another element
......@@ -220,7 +220,7 @@ export default {
})
},
isNeighbor (id) {
const neighbors = this.neighbors[this.id] && this.neighbors[this.id].results.map(n => n.element.id)
const neighbors = this.neighbors[this.id]?.results.map(n => n.element.id)
return neighbors && neighbors.includes(this.id) && neighbors.includes(id)
}
},
......
......@@ -473,17 +473,17 @@ export default {
return this.getType(this.element.type)
},
totalChildrenCount () {
return this.elementId && this.childrenPagination[this.elementId] && this.childrenPagination[this.elementId].count
return this.elementId && this.childrenPagination[this.elementId]?.count
},
firstParentId () {
// Returns the first parent element of this element. Used to redirect to a parent when deleting the element
if (!this.elementId || !this.neighbors[this.elementId] || !this.neighbors[this.elementId].results) return null
if (!this.elementId || !this.neighbors[this.elementId]?.results) return null
const neighbor = this.neighbors[this.elementId].results.find(n => n.element && n.element.id === this.elementId)
// Prevent errors on null parents since ListElementNeighbors can return null parents for paths with 'ghost elements'
return [...neighbor?.parents].reverse().find(parent => parent !== null)?.id
},
elementDirectParents () {
if (!this.elementId || !this.neighbors[this.elementId] || !this.neighbors[this.elementId].results) return null
if (!this.elementId || !this.neighbors[this.elementId]?.results) return null
// Fetch all direct parents of this element.
const firstParents = this.neighbors[this.elementId].results.filter(n => n.element && n.element.id === this.elementId).map(n => n.parents[n.parents.length - 1])
// Prevent returning duplicated parents by filtering out identical objects.
......
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