Coder Social home page Coder Social logo

Adding/Deleting outputs about drawflow HOT 15 CLOSED

jerosoler avatar jerosoler commented on May 12, 2024
Adding/Deleting outputs

from drawflow.

Comments (15)

jerosoler avatar jerosoler commented on May 12, 2024 1

Hi! @MehbubRashid

mmmmm not cloning object correctment.

Try:

  const info = JSON.parse(JSON.stringify(editor.getNodeFromId(5)));
  editor.removeNodeId('node-5');
  console.log(info);

I look to correct it

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024 1

Okay, after searching in google, i found out its a proper way of cloning objects.Learned a new thing.Thanks again

from drawflow.

jerosoler avatar jerosoler commented on May 12, 2024 1

Hello

I would like to add.

  • addNodeOutput
  • addNodeInput
  • deleteNodeOutput
  • deleteNodeInput

I haven't had time to look at it yet.

from drawflow.

jerosoler avatar jerosoler commented on May 12, 2024 1

I just added addNodeOutput and addNodeInput. 1f84ede
I've also fixed the getNodeFromId export. a62cdb0

I have doubts about how to implement deleteNodeOutput/Input.

For example the node with 3 outputs.
[output_1, output_2, output3]
Execute delete output_2 function.

How would it look?
one:
[output_1, output_2]

Oh
two:
[output_1, output_3]

The first option seems the most logical. What do you think?

Another option is to always remove the last output.

How have you implemented it?

from drawflow.

jerosoler avatar jerosoler commented on May 12, 2024 1

Added functions removeNodeInput(id, input_class) and removeNodeOutput(id, output_class)

Commit: af83a12

Try please ;)

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024 1

Thank you so much for adding these features!!

from drawflow.

jerosoler avatar jerosoler commented on May 12, 2024

Hello Thanks!

You mean?

image

To:
image

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024

Yes,exactly.Is it possible?

from drawflow.

jerosoler avatar jerosoler commented on May 12, 2024

Currently does not allow it.

It can be a good feature. Take note.

If you need it maybe you could do something like this: view setTimeout

editor.start();

var html = `
<div><input type="text" df-name></div>
`;

var data = { "name": '' };

var html = document.createElement("div");
html.innerHTML= '<div><input type="text" df-name></div>';

editor.registerNode('test', html);
editor.addNode('github', 0, 1, -300, 300, 'github', data, 'test', true);
editor.addNode('github', 2, 3, 150, 300, 'github', data, 'test', true);
editor.addConnection(1, 2, 'output_1', 'input_2')

setTimeout(function(){
  const info = editor.getNodeFromId(1);

  editor.addNode(info.name, Object.keys(info.inputs).length, Object.keys(info.outputs).length +1, info.pos_x, info.pos_y, info.class, info.data, info.html, info.typenode);
  editor.removeNodeId('node-1');
  // REDRAW connections  with
  //editor.addConnection(....)

}, 1500);

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024

Thanks.i thought of something like that.

But it would be so great if you add support for this function.There might be case where users need to add button on the node and on adding a new button,a new output also added for that button (just like manychat message flow builder)

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024

Hi, @jerosoler i have tried the method you mentioned.everything works fine.but when i try to get the connections from the old node,there is no connection in the array.even if i called const info = editor.getNodeFromId(1); before removing the node using editor.removeNodeId('node-1');

0 connection in the info array.Strange

To produce the error,you can visually connect two nodes in the browser.then in the console if you enter these two commands console.log(editor.getNodeFromId(1));editor.removeNodeId('node-1'); at once,you will see 0 connection even if you connected two nodes.

why does it happen?

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024

Yes, after adding JSON.parse(JSON.stringify()), it works...But why does it work?Can you tell me the reason behind it? I wish to learn the theory behind it.

i think editor.getNodeFromId(5) and JSON.parse(JSON.stringify(editor.getNodeFromId(5))); this two are same thing.but first one works and second one does not.Why? :D

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024

Hi, @jerosoler , do you have plan to add the (deleteSpecificOutput) function anytime soon?

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024

Great,though i have manually implemented them.but would like to see official implementation soon.thanks

from drawflow.

MehbubRashid avatar MehbubRashid commented on May 12, 2024

Yes,i also have implemented the first option.This will give additional benefits.

from drawflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.