-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext-menu.component.ts
50 lines (44 loc) · 1.69 KB
/
context-menu.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { NgClass } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject, input } from '@angular/core';
import {
ThyDropdownAbstractMenu,
ThyDropdownMenuItemDirective,
ThyDropdownMenuItemNameDirective,
ThyDropdownMenuItemIconDirective,
ThyDropdownMenuItemMetaDirective
} from 'ngx-tethys/dropdown';
import { ThyIcon } from 'ngx-tethys/icon';
import { ThyDivider } from 'ngx-tethys/divider';
import { AITable } from '../../core';
import { AITableContextMenuItem } from '../../types';
import { AITableGridSelectionService } from '../../services/selection.service';
@Component({
selector: 'ai-table-context-menu',
templateUrl: './context-menu.component.html',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'context-menu'
},
imports: [
ThyDropdownMenuItemDirective,
ThyDropdownMenuItemNameDirective,
ThyDropdownMenuItemIconDirective,
ThyDropdownMenuItemMetaDirective,
ThyIcon,
NgClass,
ThyDivider
]
})
export class AITableContextMenu extends ThyDropdownAbstractMenu {
private aiTableGridSelectionService = inject(AITableGridSelectionService);
aiTable = input.required<AITable>();
menuItems = input.required<AITableContextMenuItem[]>();
targetName = input.required<string>();
position = input.required<{ x: number; y: number }>();
execute(menu: AITableContextMenuItem) {
if ((menu.disabled && !menu.disabled(this.aiTable(), this.targetName(), this.position())) || !menu.disabled) {
menu.exec && menu.exec(this.aiTable(), this.targetName(), this.position(), this.aiTableGridSelectionService);
}
}
}