Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unable remove connection based on a condition. #680

Closed
Ashvi213 opened this issue Apr 20, 2023 · 2 comments
Closed

unable remove connection based on a condition. #680

Ashvi213 opened this issue Apr 20, 2023 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@Ashvi213
Copy link

Hi,

I have 4 nodes in drawflow namely
this.nodes = [
{ name: 'node1' },
{ name: 'node2' },
{ name: 'node3' },
];
i am creating connection like this
this.editor.on('connectionCreated', (connection: any)

my connection object is {
"output_id": "1",
"input_id": "2",
"output_class": "output_1",
"input_class": "input_1"
}

My scenarios:

  1. need to allow connection from node1 to node2 only
  2. If I tried to connect to node3 i need to remove that connection

so for removing connection

const sourceNode = this.editor.drawflow.drawflow[this.editor.module].data[sourceNodeId].data.name;
const targetNode = this.editor.drawflow.drawflow[this.editor.module].data[targetNodeId].data.name;
if (sourceNode === 'node1') {
if (['node2'].includes(targetNode)) {
console.log('Allow connection');
} else {
const outputNode = this.editor.getNodeFromId(connection.output_id);
const inputNode = this.editor.getNodeFromId(connection.input_id);
this.editor.removeSingleConnection(outputNode, inputNode,connection.output_class, connection.input_class);
}
}

but connection is not getting removed showing error.

thanks in advance

@jerosoler jerosoler self-assigned this Apr 20, 2023
@jerosoler jerosoler added the question Further information is requested label Apr 20, 2023
@jerosoler
Copy link
Owner

@Ashvi213
Copy link
Author

Thank u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants