Skip to content

Commit 231d53b

Browse files
authored
Bugfixes for 2.0 (#62)
- Fix cut operation handler Ensure that the GModelCutOperation handler does not execute a command itself and instead dispatches a corresponding DeleteOperation - Fix dependecy resolvement in delete-operaetion handler
1 parent 2ae7567 commit 231d53b

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/server/src/common/gmodel/cut-operation-handler.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ export class GModelCutOperationHandler extends GModelOperationHandler {
2828

2929
createCommand(operation: CutOperation): MaybePromise<Command | undefined> {
3030
const cuttableElementIds = this.getElementToCut(operation);
31-
return cuttableElementIds.length > 0 //
32-
? this.commandOf(() => this.actionDispatcher.dispatch(DeleteElementOperation.create(cuttableElementIds)))
33-
: undefined;
31+
// If we have cuttable elements we dispatch a DeleteElementOperation otherwise do nothing
32+
if (cuttableElementIds.length > 0) {
33+
this.actionDispatcher.dispatch(DeleteElementOperation.create(cuttableElementIds));
34+
}
35+
return undefined;
3436
}
3537

3638
protected getElementToCut(cutOperation: CutOperation): string[] {

packages/server/src/common/gmodel/delete-operation-handler.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class GModelDeleteOperationHandler extends GModelOperationHandler {
7272
}
7373

7474
const dependents = new Set<GModelElement>();
75-
this.collectDependents(dependents, nodeToDelete);
75+
this.collectDependents(dependents, nodeToDelete, false);
7676

7777
dependents.forEach(dependant => {
7878
const index = this.modelState.root.children.findIndex(element => element === dependant);
@@ -85,22 +85,23 @@ export class GModelDeleteOperationHandler extends GModelOperationHandler {
8585
return true;
8686
}
8787

88-
protected collectDependents(dependents: Set<GModelElement>, nodeToDelete: GModelElement): void {
88+
protected collectDependents(dependents: Set<GModelElement>, nodeToDelete: GModelElement, isChild: boolean): void {
8989
if (dependents.has(nodeToDelete)) {
9090
return;
9191
}
9292

9393
if (nodeToDelete.children.length > 0) {
94-
nodeToDelete.children.forEach(child => this.collectDependents(dependents, child));
94+
nodeToDelete.children.forEach(child => this.collectDependents(dependents, child, true));
9595
}
9696

9797
if (nodeToDelete instanceof GNode) {
9898
const index = this.modelState.index;
99+
99100
index.getIncomingEdges(nodeToDelete).forEach(incoming => {
100-
this.collectDependents(dependents, incoming);
101+
dependents.add(incoming);
101102
});
102103
index.getOutgoingEdges(nodeToDelete).forEach(outgoing => {
103-
this.collectDependents(dependents, outgoing);
104+
dependents.add(outgoing);
104105
});
105106
}
106107

0 commit comments

Comments
 (0)