Skip to content

Commit

Permalink
Configure fork and join nodes as not resizable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tortmayr committed May 29, 2024
1 parent 7823455 commit 24f21e8
Showing 1 changed file with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
})
];
}

Expand All @@ -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>): ShapeTypeHint;
export function createDefaultShapeTypeHint(elementId: string): ShapeTypeHint;
export function createDefaultShapeTypeHint(
elementIdOrTemplate: string | ({ elementTypeId: string } & Partial<ShapeTypeHint>)
): 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>): EdgeTypeHint;
export function createDefaultEdgeTypeHint(elementId: string): EdgeTypeHint;
export function createDefaultEdgeTypeHint(elementIdOrTemplate: string | ({ elementTypeId: string } & Partial<EdgeTypeHint>)): EdgeTypeHint {
const template = typeof elementIdOrTemplate === 'string' ? { elementTypeId: elementIdOrTemplate } : elementIdOrTemplate;
return {
elementTypeId: elementId,
repositionable: true,
deletable: true,
routable: true,
Expand All @@ -110,6 +110,7 @@ export function createDefaultEdgeTypeHint(elementId: string): EdgeTypeHint {
types.FORK_NODE,
types.JOIN_NODE,
types.CATEGORY
]
],
...template
};
}

0 comments on commit 24f21e8

Please sign in to comment.