My project utilizes a palette and a standard diagram. The standard diagram is a “view” of some collection nodes in a graph database master model. It is not the entire graph database. It is a subset of a master model. Upon clicking on a given node in the standard diagram, the palette is filled with all links connecting to that node from the master model. The user can then drag nodes from the palette into the diagram to “inflate” those nodes in the standard diagram’s view.
My issue is with the key auto-incrementing when attempting to import a node from the palette if it already exists in the standard diagram.
A small example to better illustrate the problem:
The “full” master model has these connections:
Forgive the link labels, this is made up data.
… in these pictures, the palette is on the left, the standard diagram on the right.
Let’s say a user has only the “Dad owns Child” link in view.
Selecting the dad node, you can see the “is parallel to” link to Mom in the palette:
Selecting the Child node, you can see the “is owned by” connection to both parents.
With the Child node selected, if I drag the Mom node onto the diagram, the “Mom Owns Child” link is displayed.
At this point, I am happy that the “Dad Is Parallel To Mom” link is not displayed. I want it to be possible to have nodes on the diagram with connections in the master model, but not necessarily display all those connections. This is working well thus far.
The problem comes when I try to pull the pre-existing “Dad Is Parallel To Mom” link from the master model. This could be done from either parent, in theory, were it to work.
So, again, selecting the Dad node, you can see the “is parallel to” link to Mom in the palette:
My plan was to enable the user to drag the “Mom” node out, have my code recognize the fact that the Mom node is already in the view, and draw the pre-existing “Is Parallel To” connection between the two nodes already in the view.
What actually happens is the key associated with the Mom node I pull from the Palette auto-increments to be the next available key, and my code freaks out because no Node with this new key exists in the master model.
Clearly GoJS is doing some sort of “does an object with this key already exist” detection. I’d like to have a signal that says “hey, a node with this key already exists” when I try to drop a node from the palette onto the diagram. Then I could easily find the pre-existing node in the diagram and draw the link between the two.
What I cannot figure out is a way to obtain a signal that the node I’m dropping from the palette already exists in the diagram. By the type I drop the node, “event.subject.data.key” has already incremented.
There are some workarounds I could use, but they are not as “clean” as a simple “this key already exists” check would be & it seems like that is something that should be possible. I just don’t know the inner workings of GoJS well enough yet.
Is there a way to determine if a key was auto-incremented upon drop from the palette?
As always, help is appreciated. Thank you. - Aaron