From 24f21e884af0beca7360a0587b793135b117e745 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Wed, 29 May 2024 13:37:10 +0200 Subject: [PATCH] Configure fork and join nodes as not resizable Update type hints configuration for workflow example to make fork and join nodes not resizable => we have test cases for both resizable and non-resizable elements in the diagram Refactor createDefault hint functions to allow partial overriding of default properties --- .../common/workflow-diagram-configuration.ts | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/examples/workflow-server/src/common/workflow-diagram-configuration.ts b/examples/workflow-server/src/common/workflow-diagram-configuration.ts index 784c9bf..2a4daf9 100644 --- a/examples/workflow-server/src/common/workflow-diagram-configuration.ts +++ b/examples/workflow-server/src/common/workflow-diagram-configuration.ts @@ -48,33 +48,26 @@ export class WorkflowDiagramConfiguration implements DiagramConfiguration { return [ createDefaultShapeTypeHint(types.MANUAL_TASK), createDefaultShapeTypeHint(types.AUTOMATED_TASK), - createDefaultShapeTypeHint(types.FORK_NODE), - createDefaultShapeTypeHint(types.JOIN_NODE), + createDefaultShapeTypeHint({ elementTypeId: types.FORK_NODE, resizable: false }), + createDefaultShapeTypeHint({ elementTypeId: types.JOIN_NODE, resizable: false }), createDefaultShapeTypeHint(types.DECISION_NODE), createDefaultShapeTypeHint(types.MERGE_NODE), - { + createDefaultShapeTypeHint({ elementTypeId: types.CATEGORY, - repositionable: true, - deletable: true, - resizable: true, - reparentable: true, containableElementTypeIds: [types.TASK, types.ACTIVITY_NODE, types.CATEGORY] - } + }) ]; } get edgeTypeHints(): EdgeTypeHint[] { return [ createDefaultEdgeTypeHint(DefaultTypes.EDGE), - { - elementTypeId: types.WEIGHTED_EDGE, - repositionable: true, - deletable: true, - routable: true, + createDefaultEdgeTypeHint({ + elementTypeId: DefaultTypes.EDGE, dynamic: true, sourceElementTypeIds: [types.ACTIVITY_NODE], targetElementTypeIds: [types.TASK, types.ACTIVITY_NODE] - } + }) ]; } @@ -83,13 +76,20 @@ export class WorkflowDiagramConfiguration implements DiagramConfiguration { animatedUpdate = true; } -export function createDefaultShapeTypeHint(elementId: string): ShapeTypeHint { - return { elementTypeId: elementId, repositionable: true, deletable: true, resizable: true, reparentable: true }; +export function createDefaultShapeTypeHint(template: { elementTypeId: string } & Partial): ShapeTypeHint; +export function createDefaultShapeTypeHint(elementId: string): ShapeTypeHint; +export function createDefaultShapeTypeHint( + elementIdOrTemplate: string | ({ elementTypeId: string } & Partial) +): ShapeTypeHint { + const template = typeof elementIdOrTemplate === 'string' ? { elementTypeId: elementIdOrTemplate } : elementIdOrTemplate; + return { repositionable: true, deletable: true, resizable: true, reparentable: true, ...template }; } -export function createDefaultEdgeTypeHint(elementId: string): EdgeTypeHint { +export function createDefaultEdgeTypeHint(template: { elementTypeId: string } & Partial): EdgeTypeHint; +export function createDefaultEdgeTypeHint(elementId: string): EdgeTypeHint; +export function createDefaultEdgeTypeHint(elementIdOrTemplate: string | ({ elementTypeId: string } & Partial)): EdgeTypeHint { + const template = typeof elementIdOrTemplate === 'string' ? { elementTypeId: elementIdOrTemplate } : elementIdOrTemplate; return { - elementTypeId: elementId, repositionable: true, deletable: true, routable: true, @@ -110,6 +110,7 @@ export function createDefaultEdgeTypeHint(elementId: string): EdgeTypeHint { types.FORK_NODE, types.JOIN_NODE, types.CATEGORY - ] + ], + ...template }; }