Closed NexPlex closed 6 months ago
Hello @NexPlex!
For branched steps you should use the createBranchedStepModel
method. Check this example.
For sequential steps you should use the createSequentialStepModel
method. Check this example.
I noticed also your interfaces have properties on the wrong level. All properties should be inside the properties
field.
export interface SetStep extends Step {
type: 'set';
componentType: 'task';
properties: {
result: NullableAnyVariable;
value: Dynamic<NullableAnyVariable | string | number | boolean>;
};
}
Hi thank you for the feedback,
when implementing the createBranchedStepModel method from your link, I'm getting an error on this line.
const a = context.formatPropertyValue('a', StepNameFormatter.formatDynamic);
Cannot read properties of undefined (reading 'formatDynamic')
You don't need StepNameFormatter
to create a branched step model or a sequential step model (btw: the StepNameFormatter
is defined at the app level, so it's a custom function).
Here you can find simpler examples:
I would recommend to copy a code from these examples iteratively, not all at once. This will help you to understand what is wrong.
Try to start from a simple branched step like:
export const ifStepModel = createBranchedStepModel<IfStep>('if', 'switch', step => {
step.branches().value(
createBranchesValueModel({
branches: {
true: [],
false: []
}
})
);
});
Then add next value models for properties.
Thank you for you help I got the if and loop running without error. I'm having a challenge showing the editor properties window correctly.
in ts
public ngOnInit() {
const editorProvider = EditorProvider.create(definitionModel, {
uidGenerator: Uid.next
});
this.stepEditorProvider = editorProvider.createStepEditorProvider();
this.rootEditorProvider = editorProvider.createRootEditorProvider();
this.validatorConfiguration = {
root: editorProvider.createRootValidator(),
step: editorProvider.createStepValidator()
};
}
in HTML
[rootEditor]="rootEditorProvider"
[stepEditor]="stepEditorProvider"
I'm getting this error: Cannot read path: properties/inputs
is this related to this code in my model?
export interface MyDefinition extends Definition {
properties: {
inputs: VariableDefinitions;
};
}
export const rootModel = createRootModel<MyDefinition>(root => {
root.property('inputs')
.value(
createVariableDefinitionsValueModel({})
);
});
I suppose your start definition doesn't have any value for the inputs
field in the root properties.
{
"properties": { "inputs": { "variables": [] } },
"sequence": [ ]
}
To create a start definition from the model you can use:
editorProvider.activateDefinition()
Sorry, I'm not understanding how to use or where it goes. can you provide an example?
{ "properties": { "inputs": { "variables": [] } }, "sequence": [ ] }
If I print to console activatedDefinition seems fine
const editorProvider = EditorProvider.create(definitionModel, {
uidGenerator: Uid.next
});
const activatedDefinition = editorProvider.activateDefinition();
console.log('activatedDefinition', activatedDefinition)
this.stepEditorProvider = editorProvider.createStepEditorProvider();
this.rootEditorProvider = editorProvider.createRootEditorProvider();
this.validatorConfiguration = {
root: editorProvider.createRootValidator(),
step: editorProvider.createStepValidator()
};
It should be something like this (I didn't test it).
public definition: Definition;
public ngOnInit() {
const editorProvider = EditorProvider.create(definitionModel, {
uidGenerator: Uid.next
});
this.definition = editorProvider.activateDefinition();
// ...
}
<sqd-designer
[definition]="definition"
...
></sqd-designer>
Ok I see what you mean. Resolved the issue. thank you so much!!
Hi, I'm trying to move your example code from the component to a model.ts file. This code.
sequential-workflow-model.ts
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?