Drawflow
Drawflow copied to clipboard
import fails when it doesn't include Home. and must spell exactly as `Home`
I create this gist https://gist.github.com/simkimsia/2640f3a5b2753fc40450dba25d1c2ab6
In it i have 3 index files that are modified from your current docs/index.html. the differences between all 3 are:
- index-with-Home.html (this will have a Home in the import data)
- index-spell-home-still-fails.html (this uses
home
instead ofHome
and still cause failure) - index-without-Home.html (this does not have Home at all and still fails)
Is there a way to import without being forced to include a Home at all?
Hi @simkimsia
You can try this solution:
editor.reroute = true;
editor.import = function(data, notifi = true) {
this.clear();
this.drawflow = JSON.parse(JSON.stringify(data));
if(notifi) {
this.module= Object.keys(this.drawflow.drawflow)[0];
}
this.load();
if(notifi) {
this.dispatch('import', 'import');
}
}
editor.start();
It would also be convenient to modify the function:
editor.removeModule = function(name) {
delete this.drawflow.drawflow[name];
this.dispatch('moduleRemoved', name);
if(this.module === name) {
this.changeModule(Object.keys(this.drawflow.drawflow)[0]);
}
}
I will check so that this does not happen. Or you can define a module other than Home.
Jero
Thank you for response @jerosoler
I am not fantastic at Javascript but i think your solution is basically suggesting that I override your original implementation of the two functions import
and removeModule
yes?
if so, this is good but temporary. because as time goes by, you will slowly add more code and may even modify these two methods or their signatures and so my override will eventually become wrong.
I think a long term solution would be your library consider the situation of users not starting with "Home" or removing modules midway in their usage into account. Do you agree? Let me know if I am mistaken in my thinking. Thank you.