Skip to content

Commit

Permalink
Merge pull request #3 from netgrif/NAB-327
Browse files Browse the repository at this point in the history
[NAB-327] - Release 4.0.0
  • Loading branch information
mazarijuraj authored Jan 17, 2024
2 parents 9421160 + b074d59 commit f1421ab
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
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

0 comments on commit f1421ab

Please sign in to comment.