Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

1023 B
Raw Blame
import { Component, Inject } from '@angular/core';
import {
  OpContextMenuItem,
  OpContextMenuLocalsMap,
  OpContextMenuLocalsToken,
} from 'core-app/shared/components/op-context-menu/op-context-menu.types';
import { OPContextMenuService } from 'core-app/shared/components/op-context-menu/op-context-menu.service';

@Component({
  templateUrl: './op-context-menu.html',
  standalone: false,
})
export class OPContextMenuComponent {
  public items:OpContextMenuItem[];

  public service:OPContextMenuService;

  constructor(@Inject(OpContextMenuLocalsToken) public locals:OpContextMenuLocalsMap) {
    this.items = this.locals.items.filter((item) => !item?.hidden);
    this.service = this.locals.service;
  }

  public handleClick(item:OpContextMenuItem, event:MouseEvent) {
    if (item.disabled || item.divider) {
      return false;
    }

    if (item.onClick!(event)) {
      this.locals.service.close();
      event.preventDefault();
      event.stopPropagation();
      return false;
    }

    return true;
  }
}