Palette -> updating multiple nodes of same type on diagram with different values

  1. I am trying to create a palette based canvas.
  2. I have created my own node definitions, each node has a a data property ‘configurations’ which is an array of fixed schema objects(‘name’,‘value’,‘defaultValue’,‘description’)
  3. When I drop two of these nodes onto the canvas, i want to update the configurations of the two nodes separately
  4. when i am updating the 2nd node with the configurations, the first node also assumes the same values, which is undesirable.

How do i make sure that the two nodes have separate configurations ?

Code snippet for adding palette nodes ->
` jQuery.each(activeGenomes, function(key, value) {

    genomePalette.model.addNodeData({
        key: value.id,
        genome: value.name,
        displayname: value.name,
        inputSchema: value.inputSchema,
        outputSchema: value.outputSchema,
        configuration: value.configuration,
        jarName: value.jarName,
        className: value.className,
        fig: "hexagon",
        type: "genome"
    });

});`

Code Snippet for updating values of configs based on user input ->
`function updateNodeConfigurations() {

var clickedNodeKey = subjectBeingConfigured.part.data.key;
genomeCanvas.startTransaction("savenewconfig");

var clickedNode;
jQuery.each(genomeCanvas.model.nodeDataArray, function(key, node) {
console.log("comparing "+node.key+" with "+clickedNodeKey);
    if (node.key === clickedNodeKey){
        clickedNode = node;
        return false;
    }


});
console.log("Subject part data : "+subjectBeingConfigured.part.data.configuration);
console.log("Updating configurations for : " + clickedNode.data);


jQuery.each(clickedNode.configuration, function(key, config) {

    //we are looping over each configuration of the clicked node

    configurationId = '#' + clickedNode.key + '_' + config.name;
    var valueForConfiguration = jQuery(configurationId).val();

    console.log("config old value : " + config.name + " : " + config.value);
    console.log("config new value : " + config.name + " : " + valueForConfiguration);

    config.value = valueForConfiguration;
    //genomeCanvas.model.setDataProperty(clickedNode,"configuration", valueForConfiguration)

    return true;
});

console.log()
genomeCanvas.commitTransaction("savenewconfig");

}`

It appears that you are sharing Objects, including Arrays, between nodes, when you do not want to do so.

Is the data.configuration property the only one that is of type Array? If so, it would be easiest to set these two properties on the Models of both the Palette and the Diagram:

You can find examples of this throughout the samples. One normally sets all of the properties of a model before setting Model.nodeDataArray and GraphLinksModel.linkDataArray.

Great ! your suggestion worked on setting copiesArrays and copiesArrayObjects on the Palette and the Diagram like so:
` //Set model properties on the canvas for enabling copy of array items instead of sharing
genomeCanvasModel.copiesArrayObjects = true;
genomeCanvasModel.copiesArrays = true;

//Set model properties on the genome palette for enabling copy of array items instead of sharing
genomePalette.model.copiesArrayObjects = true;
genomePalette.model.copiesArrays = true;

//Set model properties on the io palette for enabling copy of array items instead of sharing
ioPalette.model.copiesArrayObjects = true;
ioPalette.model.copiesArrays = true;`

Thank you for the prompt reply!