mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
support for toggling custom context menu (#1683)
* support for toggling custom context menu * fix unit tests
This commit is contained in:
committed by
Mario Romano
parent
4ca18bc8f9
commit
2e44550d7f
@@ -26,6 +26,7 @@ describe('ContextMenuDirective', () => {
|
||||
beforeEach(() => {
|
||||
contextMenuService = new ContextMenuService();
|
||||
directive = new ContextMenuDirective(contextMenuService);
|
||||
directive.enabled = true;
|
||||
});
|
||||
|
||||
it('should show menu via service', (done) => {
|
||||
|
@@ -25,18 +25,23 @@ export class ContextMenuDirective {
|
||||
@Input('context-menu')
|
||||
links: any[];
|
||||
|
||||
@Input('context-menu-enabled')
|
||||
enabled: boolean = false;
|
||||
|
||||
constructor(private _contextMenuService: ContextMenuService) {
|
||||
}
|
||||
|
||||
@HostListener('contextmenu', ['$event'])
|
||||
onShowContextMenu(event?: MouseEvent) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
if (this.enabled) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if (this.links && this.links.length > 0) {
|
||||
if (this._contextMenuService) {
|
||||
this._contextMenuService.show.next({event: event, obj: this.links});
|
||||
if (this.links && this.links.length > 0) {
|
||||
if (this._contextMenuService) {
|
||||
this._contextMenuService.show.next({event: event, obj: this.links});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user