Giter VIP home page Giter VIP logo

Comments (4)

b4rtaz avatar b4rtaz commented on May 23, 2024 1

Check the getStepParents method of the Designer class.

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.

from sequential-workflow-designer.

b4rtaz avatar b4rtaz commented on May 23, 2024

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.

from sequential-workflow-designer.

b4rtaz avatar b4rtaz commented on May 23, 2024

@lechuhuuha is the problem solved?

from sequential-workflow-designer.

lechuhuuha avatar lechuhuuha commented on May 23, 2024

@lechuhuuha is the problem solved?

Thanks
i just loop in the sequence and get the next index of step then its work perfect

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);
			}
		}
	});
}

from sequential-workflow-designer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.