Resolved the conflict Issue in Angular file!

This commit is contained in:
monilprajapati
2024-06-20 22:11:04 +05:30
+132 -42
View File
@@ -4024,48 +4024,138 @@ const releaseToConnectLabel = "Release to Connect"
return; return;
} }
if ((nodedata.trigger_type === "SUBFLOW" || nodedata.trigger_type === "USERINPUT" || nodedata.type === "ACTION") && !nodedata.isStartNode) {
// Check if it already has any non-decorator branches attached to it
/* const branches = cy.elements('edge').jsons()
// Tried looking for the closest node by position. aStar path not working entirely. var branchFound = false
console.log("NODE: ", event.target) var decoratorIds = []
const closestNode = cy.elements().aStar({ for (var branchkey in branches) {
root: nodedata.id, if (branches[branchkey].data.source === nodedata.id || branches[branchkey].data.target === nodedata.id) {
goal: 'node',
directed: false, if (branches[branchkey].data.decorator === true) {
})
// Add the source/destination
if (closestNode !== null && closestNode !== undefined) { if (branches[branchkey].data.source === nodedata.id) {
//console.log("Closest node app: ", closestNode.data.app_name, "Distance: ", minDistance) decoratorIds.push(branches[branchkey].data.target)
} else {
/* decoratorIds.push(branches[branchkey].data.source)
if (decoratorIds.length > 0) { }
console.log("Decorators already exists. If within distance of 15 add to existing, otherwise remove old and add new: ", decoratorIds)
for (var decoratorkey in decoratorIds) { continue
const decoratorEdge = cy.getElementById(decoratorIds[decoratorkey]) }
if (decoratorEdge === null || decoratorEdge === undefined) {
continue branchFound = true
} break
}
const sourceNode = cy.getElementById(decoratorEdge.data.source) }
const targetNode = cy.getElementById(decoratorEdge.data.target)
if (!branchFound) {
const distance = Math.sqrt( //console.log("Found action during drag. Checking closest nodes as it doesn't have a valid branch")
Math.pow(draggedNode.position('x') - sourceNode.position('x'), 2) + var closestNode = null
Math.pow(draggedNode.position('y') - sourceNode.position('y'), 2) var minDistance = 300
)
const draggedNode = event.target
// Check plus minus 15 in distance from mindistance const allnodes = cy.nodes().jsons()
if (distance > minDistance - 15 && distance < minDistance + 15) { for (var nodekey in allnodes) {
console.log("Within distance of 15, add to existing edge") const node = allnodes[nodekey]
} else { if (node.data.id === nodedata.id) {
console.log("Outside distance of 15, remove old edge and add new") continue
} }
} // Decorators
} if (node.data.attachedTo !== undefined) {
*/ continue
}
if (node.position === undefined || node.position === null || node.position.x === undefined || node.position.y === undefined) {
continue
}
if (node.data.type !== "ACTION" && node.data.type !== "TRIGGER") {
continue
}
const distance = Math.sqrt(
Math.pow(draggedNode.position('x') - node.position.x, 2) +
Math.pow(draggedNode.position('y') - node.position.y, 2)
)
if (decoratorIds.includes(node.data.id)) {
//console.log("Found existing decorator for: ", node.data.app_name, "Distance: ", distance)
if (distance > 300) {
// Remove the branch
const edgeToRemove = cy.getElementById(branches[branchkey].data.id)
if (edgeToRemove !== null && edgeToRemove !== undefined) {
//console.log("Removing edge: ", edgeToRemove)
edgeToRemove.remove()
//decoratorIds.splice(decoratorIds.indexOf(node.data.id), 1)
break
}
}
}
if (distance < minDistance) {
minDistance = distance
closestNode = node
}
}
if (closestNode !== null && closestNode !== undefined) {
//console.log("Closest node app: ", closestNode.data.app_name, "Distance: ", minDistance)
/*
if (decoratorIds.length > 0) {
console.log("Decorators already exists. If within distance of 15 add to existing, otherwise remove old and add new: ", decoratorIds)
for (var decoratorkey in decoratorIds) {
const decoratorEdge = cy.getElementById(decoratorIds[decoratorkey])
if (decoratorEdge === null || decoratorEdge === undefined) {
continue
}
const sourceNode = cy.getElementById(decoratorEdge.data.source)
const targetNode = cy.getElementById(decoratorEdge.data.target)
const distance = Math.sqrt(
Math.pow(draggedNode.position('x') - sourceNode.position('x'), 2) +
Math.pow(draggedNode.position('y') - sourceNode.position('y'), 2)
)
// Check plus minus 15 in distance from mindistance
if (distance > minDistance - 15 && distance < minDistance + 15) {
console.log("Within distance of 15, add to existing edge")
} else {
console.log("Outside distance of 15, remove old edge and add new")
}
}
}
*/
if (decoratorIds.length === 0) {
//const edgeCurve = calculateEdgeCurve(draggedNode.position(), closestNode.position)
//currentedge.style('control-point-distance', edgeCurve.distance)
//currentedge.style('control-point-weight', edgeCurve.weight)
const newId = uuidv4()
cy.add({
group: "edges",
data: {
decorator: true,
id: newId,
_id: newId,
source: closestNode.data.id,
target: nodedata.id,
label: releaseToConnectLabel,
conditions: [],
}
})
}
}
}
}
if ( if (
originalLocation.x === 0 && originalLocation.x === 0 &&
originalLocation.y === 0 && originalLocation.y === 0 &&