-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get parent id of steps? #49
Comments
Check the const step: Step = ...;
const parents = designer.getStepParents(step);
const parent = parents[parents.length - 1]; This method returns a path to a passed step. To get parent you need to read one before last item. |
BTW: your suggestion would cause that the model would contain data redundancy. What is completely wrong. Now the model contains all information what you need. You can easily get an access to previous/next/parent/child step, but it requires a definition search. |
@lechuhuuha is the problem solved? |
Thanks Here is the code designer = sequentialWorkflowDesigner.Designer.create(placeholder, startDefinition, configuration);
designer.onDefinitionChanged.subscribe(newDefinition => {
refreshValidationStatus();
if (!newDefinition && !newDefinition.sequence) {
return;
}
const modifiedArray = [];
processBranches(newDefinition.sequence, modifiedArray);
console.clear();
console.log(JSON.stringify(modifiedArray, null, 2));
// console.log('the definition has changed', newDefinition.sequence);
});
function processBranches(branches, modifiedArray) {
branches.forEach((element, index) => {
const modifiedElement = { ...element };
const childIndex = `${index + 1}`;
if (branches[childIndex]) {
modifiedElement.child = branches[childIndex].id;
}
modifiedArray.push(modifiedElement);
if (modifiedElement.componentType === 'switch') {
const yesBranch = modifiedElement.branches.yes;
const noBranch = modifiedElement.branches.no;
if (yesBranch.length > 0) {
processBranches(yesBranch, modifiedArray);
}
if (noBranch.length > 0) {
processBranches(noBranch, modifiedArray);
}
}
});
} |
Hi,
I want to get the parent id of each step in the sequence. Like in this example sequence :
is there any built in function to get the parent id and convert the json into this
have the properties child corresponding for each step
thanks
The text was updated successfully, but these errors were encountered: