jerosoler / Drawflow

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

Way to hide cross button to disable deletion of node? #124

Closed ishpreetkaurwebner closed 3 years ago

ishpreetkaurwebner commented 3 years ago

Whether there is any option or setting to disable deletion of node? Currently, deletion is possible with delete button and cross icon shown when the node is selected. Both options need to be stopped for a particular node.

jerosoler commented 3 years ago

Hello @ishpreetkaurwebner

View #10 and #70

They sure help you.

Jero

ishpreetkaurwebner commented 3 years ago

Thank you @jerosoler, these links gave me idea to prevent deletion of particular node. The solutions provided on #10 and #70 gave me some direction to implement my own problem area.

ishpreetkaurwebner commented 3 years ago

Hello @jerosoler ,

With your solution, it was great help for me to handle to do something like confirmation before delete .

But, now I am facing a new issue with above. Above solution was working perfectly fine when there was no connection between two nodes. When there is connection between two nodes, and I try to remove one node, node remove successfully, but not the connection arrow. I want to remove connection also when node is deleted, and when I look on console of browser console tool, then following error is displayed sometimes for output and sometimes for input node:

Uncaught TypeError: Cannot read property 'inputs' of undefined
    at Drawflowoverride.removeConnectionNodeId (drawflow.min.js:1)
    at Drawflowoverride.removeNodeId (drawflow-custom.js:19)
    at Drawflowoverride.click (drawflow.min.js:1)
removeConnectionNodeId @ drawflow.min.js:1
removeNodeId @ drawflow-custom.js:19
click @ drawflow.min.js:1
Uncaught TypeError: Cannot read property 'outputs' of undefined
    at Drawflowoverride.removeConnectionNodeId (drawflow.min.js:1)
    at Drawflowoverride.removeNodeId (drawflow-custom.js:19)
    at Drawflowoverride.click (drawflow.min.js:1)
removeConnectionNodeId @ drawflow.min.js:1
removeNodeId @ drawflow-custom.js:19
click @ drawflow.min.js:1
ishpreetkaurwebner commented 3 years ago

Hello @jerosoler ,

Issue is resolved as I moved the line

this.removeConnectionNodeId(id);

at start of function

class Drawflowoverride extends Drawflow {
  removeNodeId(id) {

instead at last line.