Hi,
I am using go js to build flow diagrams, which represent a bot process, for instance, login to netflix and browse through set of movies. This is very primitive use case but flows can be very complex based on how a user builds the diagram.
Below is a sample diagram which automates login to Netflix .
Now say, user wants to delete a normal node like “Sleep for 500ms” or “Click Try Again”, I don’t see any challenge from go js perspective, as we simply delete that node and relink previous node to next node.
The complexity is when user tries to delete any conditions node, with Then/ Else ports. Functionally what we want to achieve is that,
- Delete entire sub tree coming out of Else port
- Relink the sub tree from Then port to previous node.
For instance, in the above diagram, if user deletes “Was login successful?” node, then the diagram should be updated as below:
When I tried to use below code snippet to clean up else branch, it is even deleting nodes that are common for both Then/ Else branches.
const removeConditionNode (diagram, node) => {
diagram.commit(function (d) {
// Some code that gets elsePortId
// Get all immediate nodes connecting out from else port.
const nextNodeOutOfElse = node.findNodesOutOf(elsePortId).value;
// Remove subtree, coming out of else branch.
d.removeParts(nextNodeOutOfElse.findTreeParts());
}
);
}, 'Removing Action node from diagram');
}
So I am looking for any convenient API to delete only those nodes/ edges that are in else branch but are not common in Then branch.
With the current code in place, it leaves the diagram in below state, after deleting the condition node, "Was login successful? "