From f05ea8ba36b890922601ab69d859266d182b8bf2 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Mon, 17 Jun 2024 14:06:33 +0200 Subject: [PATCH] Fix issue with change bounds tool - Ensure that the change bounds tool does not dispatch `ChangeRoutingPointsAction` if there are not valid element moves. - Ensure that duplicate detection in `resolveContainerConfiguration` properly stringifies symboles. --- .../tools/change-bounds/change-bounds-tool.ts | 21 +++++++++++-------- .../src/di/container-configuration.ts | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/packages/client/src/features/tools/change-bounds/change-bounds-tool.ts b/packages/client/src/features/tools/change-bounds/change-bounds-tool.ts index ce59aded..a7f23fe1 100644 --- a/packages/client/src/features/tools/change-bounds/change-bounds-tool.ts +++ b/packages/client/src/features/tools/change-bounds/change-bounds-tool.ts @@ -43,8 +43,8 @@ import { ISelectionListener, SelectionService } from '../../../base/selection-se import { BoundsAwareModelElement, ResizableModelElement, + SelectableBoundsAware, calcElementAndRoutingPoints, - forEachElement, getMatchingElements, isNonRoutableSelectedMovableBoundsAware, toElementAndBounds @@ -251,17 +251,20 @@ export class ChangeBoundsListener extends DragAwareMouseListener implements ISel protected handleMoveOnServer(target: GModelElement): Action[] { const operations: Operation[] = []; - operations.push(...this.handleMoveElementsOnServer(target)); - operations.push(...this.handleMoveRoutingPointsOnServer(target)); + const elementToMove = this.getElementsToMove(target); + operations.push(...this.handleMoveElementsOnServer(elementToMove)); + operations.push(...this.handleMoveRoutingPointsOnServer(elementToMove)); return operations.length > 0 ? [CompoundOperation.create(operations)] : []; } - protected handleMoveElementsOnServer(target: GModelElement): Operation[] { + protected getElementsToMove(target: GModelElement): SelectableBoundsAware[] { const selectedElements = getMatchingElements(target.index, isNonRoutableSelectedMovableBoundsAware); const selectionSet: Set = new Set(selectedElements); - const newBounds: ElementAndBounds[] = selectedElements - .filter(element => this.isValidMove(element, selectionSet)) - .map(toElementAndBounds); + return selectedElements.filter(element => this.isValidMove(element, selectionSet)); + } + + protected handleMoveElementsOnServer(elementsToMove: SelectableBoundsAware[]): Operation[] { + const newBounds = elementsToMove.map(toElementAndBounds); return newBounds.length > 0 ? [ChangeBoundsOperation.create(newBounds)] : []; } @@ -282,12 +285,12 @@ export class ChangeBoundsListener extends DragAwareMouseListener implements ISel return false; } - protected handleMoveRoutingPointsOnServer(target: GModelElement): Operation[] { + protected handleMoveRoutingPointsOnServer(elementsToMove: SelectableBoundsAware[]): Operation[] { const newRoutingPoints: ElementAndRoutingPoints[] = []; const routerRegistry = this.tool.edgeRouterRegistry; if (routerRegistry) { // If client routing is enabled -> delegate routing points of connected edges to server - forEachElement(target.index, isNonRoutableSelectedMovableBoundsAware, element => { + elementsToMove.forEach(element => { if (element instanceof GConnectableElement) { element.incomingEdges .map(connectable => calcElementAndRoutingPoints(connectable, routerRegistry)) diff --git a/packages/protocol/src/di/container-configuration.ts b/packages/protocol/src/di/container-configuration.ts index 26fbf62c..2425f37e 100644 --- a/packages/protocol/src/di/container-configuration.ts +++ b/packages/protocol/src/di/container-configuration.ts @@ -85,7 +85,7 @@ export function resolveContainerConfiguration(...containerConfigurations: Contai } }); if (duplicates.length > 0) { - const culprits = duplicates.map(m => m.featureId).join(', '); + const culprits = duplicates.map(m => m.featureId.toString()).join(', '); throw new Error(`Could not resolve container configuration. Non-unique feature ids found in container configuration: ${culprits}`); } return modules;