ghostiam / vue-blocks

Vue2 dataflow graph editor
https://ghostiam.github.io/vue-blocks/index.html
MIT License
280 stars 61 forks source link

Need an easy way to dynamically add outputs #15

Open AlanGreyjoy opened 3 years ago

AlanGreyjoy commented 3 years ago

So, I have tried to add them in VueBlocksContainer, this.blocks.find(t => t.id === block.id).outputs.push({ active: false, label: 'New Match', name: 'NewMatch' }) But, as soon as this.updateScene() runs, they are cleared.

Any tips on dynamically adding outputs?

Thanks!

AlanGreyjoy commented 3 years ago

So I commented out the deletes in clonedBlocks.map inside exportScene. Everything seems to work fine. Will this cause any problems?

ghostiam commented 3 years ago

Hi. Thank you for your interest in the project.

I think your solution with clonedBlocks.map is correct. The only problem is if you change the inputs/outputs of the block(in "blocksContent" array), they will not be updated in the saved scene. Perhaps you should write some functionality that adds missing inputs/outputs to the prepareBlocks function.

Although I can see that there is a merge of objects happening there, so there is a chance the problem will be solved automatically. Unfortunately, I am not able to verify this at the moment.