jerosoler / Drawflow

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

Getting error when import and add module #449

Closed SDhivyaRaj closed 2 years ago

SDhivyaRaj commented 2 years ago

Hi, I have tried to add module and then performed change module, getting error as

"core.js:4352 ERROR TypeError: Cannot read properties of undefined (reading 'data') at DrawflowService.load (drawflow.min.js:1:4117) at DrawflowService.import (drawflow.min.js:1:44974) at TagWorkflowCreateComponent.importWorkflowModules (create-workflw.component.ts:967:23) at TagWorkflowCreateComponent.initDrawFlow (create-workflw.component.ts:515:10) at TagWorkflowCreateComponent.ngAfterViewInit (create-workflw.component.ts:164:10) at callHook (core.js:3105:1) at callHooks (core.js:3075:1) at executeInitAndCheckHooks (core.js:3027:1) at refreshView (core.js:7389:1) at refreshComponent (core.js:8465:1)"

Getting the same error while importing. Kindly help on this

SDhivyaRaj commented 2 years ago

DrawflowErr

jerosoler commented 2 years ago

The first module to import has to have the name "Home".

SDhivyaRaj commented 2 years ago

Thanks for the reply.. i have tried changing that too.. now i have Home module in import.. still facing the error

SDhivyaRaj commented 2 years ago

this is my data which i am trying to import,

let exportedData={ "drawflow": { "Home": { "data": {} }, "timesheet": { "data": { "1": { "id": 1, "name": "Start", "data": { "pageid": "259B-97BC-1654595155", "name": "", "label": "", "deviceid": true, "ip": true, "uid": false, "useragent": true }, "class": "draw-page-item", "html": "

🌐
", "typenode": false, "inputs": {}, "outputs": { "output_1": { "connections": [ { "node": "2", "output": "input_1" } ] } }, "pos_x": 169.25, "pos_y": 85 }, "2": { "id": 2, "name": "Page", "data": { "name": "Task", "label": "Task", "ip": true, "deviceid": true, "uid": false, "useragent": true, "pageid": "259B-97BC-1654595155" }, "class": "draw-page-item", "html": "
🧾
Page
", "typenode": false, "inputs": { "input_1": { "connections": [ { "node": "1", "input": "output_1" } ] } }, "outputs": { "output_1": { "connections": [] } }, "pos_x": 391.25, "pos_y": 133 } } } } }

editor.import(exportedData);

jerosoler commented 2 years ago

Work:

editor.import({
    "drawflow": {
        "Home": {
            "data": {}
        },
        "timesheet": {
            "data": {
                "1": {
                    "id": 1,
                    "name": "Start",
                    "data": {
                        "pageid": "259B-97BC-1654595155",
                        "name": "",
                        "label": "",
                        "deviceid": true,
                        "ip": true,
                        "uid": false,
                        "useragent": true
                    },
                    "class": "draw-page-item",
                    "html": "globe_with_meridians",
    "typenode": false,
                    "inputs": {},
                    "outputs": {
                        "output_1": {
                            "connections": [
                                {
                                    "node": "2",
                                    "output": "input_1"
                                }
                            ]
                        }
                    },
                    "pos_x": 169.25,
                    "pos_y": 85
                },
                "2": {
                    "id": 2,
                    "name": "Page",
                    "data": {
                        "name": "Task",
                        "label": "Task",
                        "ip": true,
                        "deviceid": true,
                        "uid": false,
                        "useragent": true,
                        "pageid": "259B-97BC-1654595155"
                    },
                    "class": "draw-page-item",
                    "html": "receipt    Page    ",
    "typenode": false,
                    "inputs": {
                        "input_1": {
                            "connections": [
                                {
                                    "node": "1",
                                    "input": "output_1"
                                }
                            ]
                        }
                    },
                    "outputs": {
                        "output_1": {
                            "connections": []
                        }
                    },
                    "pos_x": 391.25,
                    "pos_y": 133
                }
            }
        }
    }
});
editor.changeModule("timesheet");

Test in console demo: image

SDhivyaRaj commented 2 years ago

I don't know where I am getting missed. Do you have any idea, regarding this.. now while importing the connection line is also missing

SDhivyaRaj commented 2 years ago

I am adding a module and changed to the same"Module2". Then tried to change module to "Module1". getting that error

While importing connection is missing.

jerosoler commented 2 years ago

Copy the complete json and do not paste it as plain text, but as code, to be able to debug.

DhivyaRajesh commented 2 years ago

Thanks for you assistance, the issue got resolved by added waiting time for import using settimeout function