Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NAB-327] - Release 4.0.0 #3

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {MenuItem} from './menu-item';
import {SelectTool} from '../../services/modes/select-tool';
import {CanvasNodeElement} from '../../domain/canvas-node-element';

export class SelectArcsMenuItem extends MenuItem {

constructor(tool: SelectTool, element: CanvasNodeElement<any, any>) {
super(
`Select connected arcs`,
'sync_alt',
() => {
tool.selectConnectedArcs(element);
}
);
}
}
14 changes: 14 additions & 0 deletions src/app/modeler/edit-mode/services/modes/quick-draw-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ export class QuickDrawTool extends CanvasTool {
super.onArcContextMenu(event, arc);
}

onArcEnter(event: MouseEvent, arc: CanvasArc) {
if (this.isWorkInProgress()) {
return;
}
super.onArcEnter(event, arc);
}

onArcLeave(event: MouseEvent, arc: CanvasArc) {
if (this.isWorkInProgress()) {
return;
}
super.onArcLeave(event, arc);
}

onPlaceClick(event: MouseEvent, canvasPlace: CanvasPlace) {
if (this.isContextMenuOpen()) {
this.closeContextMenu();
Expand Down
16 changes: 14 additions & 2 deletions src/app/modeler/edit-mode/services/modes/select-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
import {ModelerConfig} from '../../../modeler-config';
import {DeleteSelectedMenuItem} from '../../context-menu/menu-items/delete-selected-menu-item';
import {DeleteMenuItem} from '../../context-menu/menu-items/delete-menu-item';
import {SelectArcsMenuItem} from '../../context-menu/menu-items/select-arcs-menu-item';
import {CanvasNodeElement} from '../../domain/canvas-node-element';

export class SelectTool extends CanvasTool {

Expand Down Expand Up @@ -533,17 +535,27 @@ export class SelectTool extends CanvasTool {
}

placeContextMenu(place: CanvasPlace, event: MouseEvent): ContextMenu {
return this.replaceDeleteMenuItem(super.placeContextMenu(place, event));
const menu = this.replaceDeleteMenuItem(super.placeContextMenu(place, event));
menu.items.push(new SelectArcsMenuItem(this, place));
return menu;
}

transitionContextMenu(transition: CanvasTransition, event: MouseEvent): ContextMenu {
return this.replaceDeleteMenuItem(super.transitionContextMenu(transition, event));
const menu = this.replaceDeleteMenuItem(super.transitionContextMenu(transition, event));
menu.items.push(new SelectArcsMenuItem(this, transition));
return menu;
}

arcContextMenu(arc: CanvasArc, event: MouseEvent): ContextMenu {
return this.replaceDeleteMenuItem(super.arcContextMenu(arc, event));
}

selectConnectedArcs(element: CanvasNodeElement<any, any>) {
const elementId = element.modelElement.id;
const connected = this.elements.arcs.filter(a => a.modelArc.source.id === elementId || a.modelArc.destination.id === elementId);
connected.forEach(a => this.addToSelection(a));
}

private replaceDeleteMenuItem(menuItem: ContextMenu): ContextMenu {
const index = menuItem.items.findIndex(value => value instanceof DeleteMenuItem);
if (index >= 0) {
Expand Down
Loading