jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.7k stars 728 forks source link

Nodes with the same ID #674

Open pninaru opened 1 year ago

pninaru commented 1 year ago

Hi, I'm using drawflow and trying to add new nodes to my drawflow. the first node is added with id= 1, the second node with id = 2. from the third node the id is 2 for all nodes. What can be the reason for it?

jerosoler commented 1 year ago

Show your code.

This example shows you the codes: 1,2,3?

    const editor = new Drawflow(id);
    editor.start();
    const nodeIdA = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
    const nodeIdB = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
    const nodeIdC = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
    console.log(nodeIdA);
    console.log(nodeIdB);
    console.log(nodeIdC);
pninaru commented 1 year ago

I wrote the code in Angular.

And I created the addNode function once for each type That is, if I now drag an event of type A then it goes to the function of addNode - A

and creates an amount of nodes according to my choice. And also when I switch to drag button type B it still gives me ID =2 What could be the reason?

‫בתאריך יום ה׳, 23 במרץ 2023 ב-11:32 מאת ‪Jero Soler‬‏ <‪ @.***‬‏>:‬

Show your code.

This example shows you the codes: 1,2,3?

const editor = new Drawflow(id);
editor.start();
const nodeIdA = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
const nodeIdB = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
const nodeIdC = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
console.log(nodeIdA);
console.log(nodeIdB);
console.log(nodeIdC);

— Reply to this email directly, view it on GitHub https://github.com/jerosoler/Drawflow/issues/674#issuecomment-1480864882, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6VDS5NQF4HCRVW3NF7TOC3W5QKDRANCNFSM6AAAAAAWE5MXMI . You are receiving this because you authored the thread.Message ID: @.***>

jerosoler commented 1 year ago

I don't know what could be the reason, if it doesn't show its code.

pninaru commented 1 year ago

addNodeToDrawFlow(name, pos_x, pos_y) {

switch (name) {

  case 'template':
    var template = `
      <div>
        <div class="title-box">EX</div>
        <div class="body">new</div>
      </div>
      `;
    this.editor.*addNode*('template', 1, 1, pos_x, pos_y, 'template', {

}, template, false);

    break;

ngOnInit() this.editor.on('nodeCreated', (id) => { let outName = this.editor.getNodeFromId(id).name; this.nodes.push(new IdNameModel(id, outName)); if (this.nodes.length > 1) { let inputName = this.editor.getNodeFromId(this.nodes[this.nodes.length - 1].id).name; this.editor.addConnection(id, this.nodes[this.nodes.length-1].id, outName, inputName); } })

‫בתאריך יום ה׳, 23 במרץ 2023 ב-11:57 מאת אתי כהן @.***‬‏>:‬

I wrote the code in Angular.

And I created the addNode function once for each type That is, if I now drag an event of type A then it goes to the function of addNode - A

and creates an amount of nodes according to my choice. And also when I switch to drag button type B it still gives me ID =2 What could be the reason?

‫בתאריך יום ה׳, 23 במרץ 2023 ב-11:32 מאת ‪Jero Soler‬‏ <‪ @.***‬‏>:‬

Show your code.

This example shows you the codes: 1,2,3?

const editor = new Drawflow(id);
editor.start();
const nodeIdA = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
const nodeIdB = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
const nodeIdC = editor.addNode('test1', 1, 1, Math.floor(Math.random() * 1920) + 1, Math.floor(Math.random() * 800) + 1, 'test1', {}, '<div>Hi!!</div>');
console.log(nodeIdA);
console.log(nodeIdB);
console.log(nodeIdC);

— Reply to this email directly, view it on GitHub https://github.com/jerosoler/Drawflow/issues/674#issuecomment-1480864882, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6VDS5NQF4HCRVW3NF7TOC3W5QKDRANCNFSM6AAAAAAWE5MXMI . You are receiving this because you authored the thread.Message ID: @.***>

jerosoler commented 1 year ago

I don't see anything weird. Just the asterisks. I don't know what they do in angular.

pninaru commented 1 year ago

The question is whether I can use the addNode function once and the ID should be added automatically ?

‫בתאריך יום ה׳, 23 במרץ 2023 ב-12:18 מאת ‪Jero Soler‬‏ <‪ @.***‬‏>:‬

I don't see anything weird. Just the asterisks. I don't know what they do in angular.

— Reply to this email directly, view it on GitHub https://github.com/jerosoler/Drawflow/issues/674#issuecomment-1480930333, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6VDS5M3R6LU6R4BEVHNTIDW5QPP7ANCNFSM6AAAAAAWE5MXMI . You are receiving this because you authored the thread.Message ID: @.***>

jerosoler commented 1 year ago

You can see here the addNode function.

https://github.com/jerosoler/Drawflow/blob/300c9efda3bf8820131b3e93ea50cd9b76c892d3/src/drawflow.js#L1183

pninaru commented 1 year ago

Thanks for responding !

‫בתאריך יום ה׳, 23 במרץ 2023 ב-12:55 מאת ‪Jero Soler‬‏ <‪ @.***‬‏>:‬

You can see here the addNode function.

https://github.com/jerosoler/Drawflow/blob/300c9efda3bf8820131b3e93ea50cd9b76c892d3/src/drawflow.js#L1183

— Reply to this email directly, view it on GitHub https://github.com/jerosoler/Drawflow/issues/674#issuecomment-1480977452, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6VDS5KS43U2IG25U2S62CDW5QTYHANCNFSM6AAAAAAWE5MXMI . You are receiving this because you authored the thread.Message ID: @.***>

pninaru commented 1 year ago

I'm using drawflow and I need to change the text inside a node dynamically. I want it to be bounded to an parameter .

‫בתאריך יום ב׳, 27 במרץ 2023 ב-7:18 מאת אתי כהן @.***‬‏>:‬

Thanks for responding !

‫בתאריך יום ה׳, 23 במרץ 2023 ב-12:55 מאת ‪Jero Soler‬‏ <‪ @.***‬‏>:‬

You can see here the addNode function.

https://github.com/jerosoler/Drawflow/blob/300c9efda3bf8820131b3e93ea50cd9b76c892d3/src/drawflow.js#L1183

— Reply to this email directly, view it on GitHub https://github.com/jerosoler/Drawflow/issues/674#issuecomment-1480977452, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6VDS5KS43U2IG25U2S62CDW5QTYHANCNFSM6AAAAAAWE5MXMI . You are receiving this because you authored the thread.Message ID: @.***>

pninaru commented 1 year ago

I want to create a connection between two or more nodes. I use the addConnection function And he falls for her. I wanted to ask if I should wrap the function in an event like 'connectionStart'?! And if so, how do I use it, it flies away from the function as soon as I call it.. I would appreciate an answer on this matter.