ConditionsOrchestrator class
đ Descriptionâ
The ConditionsOrchestrator class instance is supplied to the @conditions decorated method of a NodeBlock. It is used to define condition templates for the block. Condition templates can be used to create new conditions. They are listed in the builder and the user can select one of the templates when adding new conditions.
The ConditionsOrchestrator instance is only available within the method of the NodeBlock marked with the @conditions decorator. The instance is supplied as argument to that decorated method or through the conditions property of the NodeBlock instance.
đī¸ Fieldsâ
đˇī¸ templatesâ
Retrieves an array with the available condition templates.
Typeâ
(IConditionTemplate | IConditionGroup)[]
âļī¸ Methodsâ
đ§ templateâ
Creates a new condition template and adds it to the list of templates.
Signatureâ
template(properties: ITemplateProperties): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
properties | ITemplateProperties | No | Specifies the template properties. |
Return valueâ
Returns a reference to the ConditionsOrchestrator instance.
Exampleâ
import { tripetto, conditions, NodeBlock } from "@tripetto/builder";
@tripetto({
type: "node",
identifier: "example-block",
label: "Example",
icon: "data:image/svg+xml;base64,PHN2ZyAvPg=="
})
class ExampleBlock extends NodeBlock {
@conditions
onConditions(): void {
this.conditions.template({
condition: ExampleCondition
});
}
}
đ§ customâ
Adds a custom command to the list of templates. A custom command is execute for a certain Condition.
Signatureâ
custom(
label: string,
command: (condition: Condition) => void,
icon?: string,
markdown: boolean
): this
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
label | string | No | Specifies the label for the custom command. |
command | (condition: Condition) => void | No | Specifies the command to execute for a condition. A reference to the Condition instance is supplied. |
icon | string | Yes | Specifies the icon for the custom command. |
markdown | boolean | Yes | Specifies if markdown is supported in the label (default is false). |
Return valueâ
Returns a reference to the ConditionsOrchestrator instance.
đ§ groupâ
Adds a group that can contain templates and custom commands.
Signatureâ
group(
label: string,
icon?: string,
markdown?: boolean,
separator?: boolean
): ConditionsOrchestrator
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
label | string | No | Specifies the label for the group. |
icon | string | Yes | Specifies the icon for the group. |
markdown | boolean | Yes | Specifies if markdown is supported in the label (default is false). |
separator | boolean | Yes | Specifies if the group should be preceded by a separator in the menu (default is false). |
Return valueâ
Returns a new ConditionsOrchestrator instance that can be used to create new templates and custom commands for the group.
âī¸ Interfacesâ
đ ITemplatePropertiesâ
Describes the interface for declaring condition templates.
Type declarationâ
interface ITemplateProperties<T> { condition: typeof ConditionBlock; label?: string;Optional markdown?: string;Optional icon?: SVGImage | string;Optional props?: Partial<Readonly<T>>;Optional burst?: boolean | "branch";Optional autoOpen?: boolean;Optional separator?: boolean;Optional }
đˇī¸ autoOpenâ
Contains if the condition editor panel should be opened automatically after creation.
Typeâ
boolean
đˇī¸ burstâ
Contains if the condition allows burst creation. Burst creation allows a user to create a collection of conditions at once. For example, it allows to create a condition for each option in a dropdown block in a single action. It can be one of the following values:
false: Burst creation not supported for this condition;- `true: Burst creation of conditions in separate branches supported;
branch: Burst creation of conditions in a single branch supported.
Typeâ
boolean | "branch"
đˇī¸ conditionâ
Specifies the condition block the template is for.
Typeâ
đˇī¸ iconâ
Specifies the icon for the condition.
Typeâ
SVGImage | string
đˇī¸ labelâ
Specifies the label for the condition.
Typeâ
string
đˇī¸ markdownâ
Specifies a label for the condition that has markdown in it (overrules the label property).
Typeâ
string
đˇī¸ propsâ
Specifies the properties to set on the condition. All properties implemented in the condition block are allowed.
Typeâ
{}
đˇī¸ separatorâ
Specifies if the template should be preceded by a separator in the condition template menu.
Typeâ
boolean
đ IConditionTemplateâ
Describes the interface for template object.
Type declarationâ
interface IConditionTemplate { label: string;Readonly markdown: boolean;Readonly icon?: SVGImage | string;ReadonlyOptional separator?: boolean;ReadonlyOptional burst?: "branches" | "branch" | "pipe";ReadonlyOptional command: (condition: Condition, burst: boolean) => void;Function }
đˇī¸ burstâ
Contains if the condition allows burst creation. It can be one of the following values:
branches: Separate branches are created for each condition;branch: The conditions are created within a single branch with the culling modefirst;pipe: The conditions are created within a single branch with the culling modeeach.
Typeâ
"branches" | "branch" | "pipe"
đˇī¸ iconâ
Icon for the template.
Typeâ
SVGImage | string
đˇī¸ labelâ
Label for the template.
Typeâ
string
đˇī¸ markdownâ
Specifies if the label has possible markdown in it.
Typeâ
boolean
đˇī¸ separatorâ
Specifies if the template should be preceded by a separator.
Typeâ
boolean
đ§ commandâ
Command that creates the actual condition block.
Signatureâ
(condition: Condition, burst: boolean) => void
Parametersâ
| Name | Type | Optional | Description |
|---|---|---|---|
condition | Condition | No | Reference to the Condition. |
burst | boolean | No | Specifies if the burst mode is active. |
đ IConditionGroupâ
Describes the interface for group object.
Type declarationâ
interface IConditionGroup { label: string;Readonly markdown: boolean;Readonly icon?: SVGImage | string;ReadonlyOptional templates: IConditionTemplate[];Readonly }
đˇī¸ iconâ
Icon for the template.
Typeâ
SVGImage | string
đˇī¸ labelâ
Label for the template.
Typeâ
string
đˇī¸ markdownâ
Specifies if the label has possible markdown in it.
Typeâ
boolean
đˇī¸ templatesâ
Specifies the templates in the group.