nocode-js / sequential-workflow-editor Goto Github PK
View Code? Open in Web Editor NEWPowerful workflow editor builder for any workflow designer.
Home Page: https://nocode-js.com/
License: MIT License
Powerful workflow editor builder for any workflow designer.
Home Page: https://nocode-js.com/
License: MIT License
Hi, I'm trying to move your example code from the component to a model.ts file. This code.
public readonly toolboxConfiguration: ToolboxConfiguration = {
groups: [
{
name: 'Step',
steps: [
this.createTaskStep(null, 'save', 'Save file', {"velocity": "0"}),
this.createTaskStep(null, 'text', 'Send email', {"velocity": "0"}),
this.createTaskStep(null, 'task', 'Create task', {"velocity": "0"}),
this.createIfStep(null, [], []),
this.createContainerStep(null, [])
]
}
]
};
private createTaskStep(id: any, type: any, name: any, properties: any) {
return {
id,
componentType: 'task',
type,
name,
properties: properties || {}
};
}
private createIfStep(id: any, _true: any, _false: any) {
return {
id,
componentType: 'switch',
type: 'if',
name: 'If',
branches: {
'true': _true,
'false': _false
},
properties: {}
};
}
createContainerStep(id: any, steps: any) {
return {
id,
componentType: 'container',
type: 'loop',
name: 'Loop',
properties: {},
sequence: steps
};
}
sequential-workflow-model.ts
// Define a model for an Email Task Step
export const emailTaskModel = createStepModel<Step>('email', 'task', step => {
// Define the "recipient" property
step.property('recipient')
.value(createStringValueModel({
minLength: 1, // Minimum length of 1 character
}))
.label('Recipient');
// Define the "subject" property
step.property('subject')
.value(createStringValueModel({
minLength: 1, // Minimum length of 1 character
}))
.label('Email Subject');
// Define the "message" property
step.property('message')
.value(createStringValueModel({
minLength: 1, // Minimum length of 1 character
}))
.label('Email Message');
});
// Define your custom step types as interfaces if needed
export interface TaskStep extends Step {
type: string; // Type of task (e.g., 'save', 'text', 'task')
name: string; // Human-readable name for the task
velocity: string; // A string representing the "speed" or priority of the task
// Add any other task-specific properties here
}
export interface IfStep extends Step {
condition: string; // The condition to evaluate, represented as a string
branches: {
'true': true,
'false': false
};
// Any additional properties related to conditional execution
}
export interface ContainerStep extends Step {
sequence: Step[]; // An array of steps that are part of this container
// Additional properties that define how the steps in the sequence are executed
}
// Use createStepModel to define your custom steps
export const taskStepModel = createStepModel<TaskStep>('task', 'task', step => {
step.property('type')
.value(createStringValueModel({
// Example configuration: Adjust these properties as needed
minLength: 1,
}))
.label('Task Type');
step.property('name')
.value(createStringValueModel({
minLength: 1, // Minimum length of 1 character
}))
.label('Task Name');
step.property('velocity')
.value(createStringValueModel({
// Convert the string pattern to a RegExp object
pattern: new RegExp('^[0-9]+$'), // Ensures the velocity is a number
}))
.label('Velocity');
});
export const ifStepModel = createStepModel<IfStep>('if', 'switch', step => {
step.property('condition')
.value(createStringValueModel({
minLength: 1, // Assuming a simple condition represented as a string
}))
.label('Condition');
;
});
export const containerStepModel = createStepModel<ContainerStep>('loop', 'container', step => {
// Assuming sequence needs to be an array of step IDs or similar identifiers
step.property('sequence')
.value(createStringValueModel({
minLength: 1, // Adjust based on how sequences are represented
}))
.label('Sequence');
// Container-specific properties can be added here
});
export const rootModel = createRootModel<MyDefinition>(root => {
root.property('inputs')
.value(
createVariableDefinitionsValueModel({})
);
});
export const definitionModel = createDefinitionModel<MyDefinition>(model => {
model.valueTypes(['string', 'number']);
model.root(rootModel);
model.steps([logStepModel, taskStepModel, ifStepModel, containerStepModel, emailTaskModel]);
});
export const editorProvider = EditorProvider.create(definitionModel, {
uidGenerator: Uid.next,
});
`
calling it like this from the component
this.toolboxConfiguration = { groups: editorProvider.getToolboxGroups() };
the taskStepModel and emailTaskModel seem to work but the ifStepModel and containerStepModel give a lot of errors.
Any suggestions?
Hi!
I'm triying to create steps on realtime, which means that my backend sends the information about which steps will be used and the corresponding definition of them.
In my case, I have a variable with all the steps and the definition about them, and now I have a React Component that loops for all of them and generate the Step content. But I would like to use the swd-editor to avoid developing validations & features that the editor has.
export interface LogStep extends Step {
type: 'log';
componentType: 'task';
properties: {
message: string;
};
}
export const definitionModel = createDefinitionModel<MyDefinition>(model => {
model.valueTypes(['string', 'number']);
model.root(rootModel);
model.steps([logStepModel]);
});
Is there any chance to generate the StepTypes and definition model dynamically based on schema data sent from the backend?
Thanks in advance!
In react app, how to get the value of global editor?
I try to use hook useGlobalEditor, but throw exception.
react_devtools_backend_compact.js:12966 React Router caught the following error during render Error: Cannot find global editor context
at useGlobalEditor (index.js:75:11)
at WorkflowEditor (WorkflowEditor.tsx:54:106)
at fm (react-dom.development.js:1:152112)
at react-dom.development.js:1:196268
at Hg (react-dom.development.js:1:197617)
at qw (react-dom.development.js:1:244731)
at Lw (react-dom.development.js:1:237660)
at _w (react-dom.development.js:1:237542)
at Nw (react-dom.development.js:1:237304)
at mw (react-dom.development.js:1:234875)
I try to use the sequential-workflow-editor with sequential-workflow-designer-react.
But i can't find the option globalEditorProvider and stepEditorProvider in SequentialWorkflowDesigner component.
You can help me to use the sequential-workflow-editor in react?
Dear Team,
I'd like to express my appreciation for the Workflow Editor. Its user-friendly interface and versatile features made it easy to get started. However, as I delve deeper into its capabilities, I've encountered challenges beyond my current abilities.
I'm currently exploring the Workflow Editor and its capabilities. Specifically, I'm uncertain about how to add a Multi-Value Array or Dictionary to a step. Could you please provide guidance on this matter, or clarify if it's not supported? For example, I'd like to create a dictionary with animals described by Type, Size, and Name.
Thank you for your assistance.
Best regards,
Max
export const anyVariablesStepModel = createStepModel<TransitionVariablesStepModel>('animal', 'task', step => { step.property('Animal') .label('Animal Entry') .value( [ { createChoiceValueModel({ choices: ["Dog", "Cat", "Mouse"] }) }, { createNumberValueModel({ defaultValue: size.Default, min: size.Min, max: size.Max }); }, { createStringValueModel({ defaultValue: animalName }) } );
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.