jerosoler / Drawflow

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

Save data when edited on modal #197

Closed Yusufzai closed 3 years ago

Yusufzai commented 3 years ago

How can I JSON save data when I edit it on modal.

For Example :

I have this -> https://prnt.sc/18xbkn5

Now I have updated my data like -> https://prnt.sc/18xbuok

and I want to save the data in my workflow

How can I save it?

jerosoler commented 3 years ago

Hello @Yusufzai

Use attributes df- for save data. https://github.com/jerosoler/Drawflow#nodes

The modal append in drawflow div. No in body.

Or use updateNodeDataFromId method for update data manualy.

View in demo "DbClick!" node.

Jero

Yusufzai commented 3 years ago

Thanks for the reply @jerosoler

I think my question is not clear to you

Let me clarify my query.

  1. I have a widget that uses the df-* attribute.

  2. I entered a value in that widget. Screenshot -> Screenshot_1

  3. Now I clicked on "Show JSON data" ( A button created by me but using the same functionality as in your export button and also I have changed the modal using code mirror )

  4. So the output value of exported JSON data is -> Screenshot_2

  5. Now If I edit inside the JSON data directly from the modal like -> Screenshot_3

  6. How can I save this and output it to my widget on save btn click -> Screenshot_4

Note 1 - : . I am already using df- * attribute Note 2 - : I am not asking about DBclick example.

Hope this time I am clear to you :)

jerosoler commented 3 years ago

uhmmm. Okay.

Use updateNodeDataFromId

But I see that more than one node can be edited. Import the new Json on Save for regenerate flow.

Yusufzai commented 3 years ago

Yes, More than one code can be edited. How can I Import the new Json on Save for regenerate flow as this is exactly I want?

I got this inside the docs https://github.com/jerosoler/Drawflow#export--import

I can I use that any idea!

jerosoler commented 3 years ago

Yes simple!

editor.import(YOUR_DATA);

If you use modules. Save the module name and. To be at the same point.

editor.changeModule('nameofmodule');
Yusufzai commented 3 years ago

The import data should be the JSON data right?

editor.import(MY_JSON_DATA);

jerosoler commented 3 years ago

Yes! View example: https://github.com/jerosoler/drawflow-minimap-example/blob/main/index.html

Yusufzai commented 3 years ago

It works successfully. Thanks for the help :)