Skip to content

Commit

Permalink
Merge pull request #94 from taiga-family/connection-deletion-event
Browse files Browse the repository at this point in the history
feat: added an event that is sent when connections are deleted …
  • Loading branch information
a1rat91 authored Dec 16, 2024
2 parents e120ab7 + d50d87d commit 8f0e327
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions projects/ng-draw-flow/src/lib/components/scene/scene.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ export class SceneComponent implements ControlValueAccessor, OnInit {
target: deletedNode,
model: this.model,
});

this.emitConnectionDeletedByNodeId(key);
this.connectionsService.removeConnectionsByNodeId(key);
}

Expand Down Expand Up @@ -161,6 +163,18 @@ export class SceneComponent implements ControlValueAccessor, OnInit {
});
}

private emitConnectionDeletedByNodeId(nodeId: string): void {
this.connectionsService.connections$.value
.filter(
(connection) =>
connection.source.nodeId === nodeId ||
connection.target.nodeId === nodeId,
)
?.forEach((connection) =>
this.connectionDeleted.emit({target: connection, model: this.model}),
);
}

// @ts-ignore
private onChange: (value: DfDataModel) => void = (_: DfDataModel) => {};
// @ts-ignore
Expand Down

0 comments on commit 8f0e327

Please sign in to comment.