1 changed file
projects/igniteui-angular-extras/src/lib/context-menu | ||
context-menu.component.ts | ||
context-menu.component.ts
/projects/igniteui-angular-extras/src/lib/context-menu/context-menu.component.ts-19+43/projects/igniteui-angular-extras/src/lib/context-menu/context-menu.component.ts
Add comment 1 import { AfterViewInit, Component, ElementRef, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core';
Add comment 2 import { AbsoluteScrollStrategy, AutoPositionStrategy, HorizontalAlignment,
Add comment 3 // tslint:disable-next-line: max-line-length
Add comment 4 Minus IgxOverlayService, IgxToggleDirective, OverlayCancelableEventArgs, VerticalAlignment, OverlayEventArgs, IgxTabsComponent } from '@infragistics/igniteui-angular';
Add comment 4 Plus IgxOverlayService, IgxToggleDirective, OverlayCancelableEventArgs, VerticalAlignment, IgxTabsComponent, OverlaySettings, CloseScrollStrategy, OverlayEventArgs } from '@infragistics/igniteui-angular';
Add comment 5 import { Subject } from 'rxjs';
Add comment 6 import { takeUntil } from 'rxjs/operators';
Add comment 7 import { IgxChartMenuComponent } from './chart-dialog/chart-dialog.component';
Add comment 30 private destroy$ = new Subject<any>();
Add comment 31 private _dialogId;
Add comment 32 private _chartDialogOS = { closeOnOutsideClick: false };
Add comment 33 Minus private _tabsMenuOverlaySettings = this.getPositionSettings(HorizontalAlignment.Center, VerticalAlignment.Bottom);
Add comment 34 Minus private _chartPreviewDialogOS = this.getPositionSettings(HorizontalAlignment.Center, VerticalAlignment.Top);
Add comment 33 Plus
Add comment 34 Plus private _tabsMenuOverlaySettings: OverlaySettings = {
Add comment 35 Plus closeOnOutsideClick: false,
Add comment 36 Plus modal: false,
Add comment 37 Plus outlet: null,
Add comment 38 Plus scrollStrategy: new CloseScrollStrategy(),
Add comment 39 Plus positionStrategy: new AutoPositionStrategy({
Add comment 40 Plus horizontalDirection: HorizontalAlignment.Center,
Add comment 41 Plus horizontalStartPoint: HorizontalAlignment.Center,
Add comment 42 Plus verticalStartPoint: VerticalAlignment.Bottom,
Add comment 43 Plus verticalDirection: VerticalAlignment.Bottom,
Add comment 44 Plus openAnimation: null,
Add comment 45 Plus closeAnimation: null
Add comment 46 Plus })
Add comment 47 Plus };
Add comment 48 Plus private _chartPreviewDialogOverlaySettings: OverlaySettings = {
Add comment 49 Plus closeOnOutsideClick: false,
Add comment 50 Plus modal: false,
Add comment 51 Plus outlet: null,
Add comment 52 Plus scrollStrategy: new CloseScrollStrategy(),
Add comment 53 Plus positionStrategy: new AutoPositionStrategy({
Add comment 54 Plus horizontalDirection: HorizontalAlignment.Center,
Add comment 55 Plus horizontalStartPoint: HorizontalAlignment.Center,
Add comment 56 Plus verticalStartPoint: VerticalAlignment.Top,
Add comment 57 Plus verticalDirection: VerticalAlignment.Top,
Add comment 58 Plus openAnimation: null,
Add comment 59 Plus closeAnimation: null
Add comment 60 Plus })
Add comment 61 Plus };
Add comment 35 62 public chartImages;
Add comment 36 63 public conditionImages;
Add comment 37 64 constructor(private overlayService: IgxOverlayService) {
Add comment 87 114 // This is a temporary fix, which should be removed right after
Add comment 88 115 // the overlay service is capable of notifying the overlay content elements
Add comment 89 116 // that their children has been resized.
Add comment 117 Plus
Add comment 118 Plus if ((this.overlayService as any)._overlayElement.children[1]){
Add comment 90 119 // tslint:disable-next-line: max-line-length
Add comment 91 120 (this.overlayService as any)._overlayElement.children[1].children[0].style.width = resizedContentArgs[0].contentRect.width + 'px';
Add comment 121 Plus }
Add comment 92 122 });
Add comment 93 123 }
Add comment 94 124 });
Add comment 95 125 this.overlayService.closing.pipe(takeUntil(this.destroy$))
Add comment 96 126 .subscribe((args: OverlayEventArgs) => {
Add comment 97 127 if (args.componentRef && args.componentRef.instance instanceof IgxChartMenuComponent) {
Add comment 98 Minus this.toggleTabMenu();
Add comment 99 Minus this._dialogId = undefined;
Add comment 128 Plus if (this._dialogId) {
Add comment 129 Plus this.tabsMenu.open(this._tabsMenuOverlaySettings)
Add comment 130 Plus }
Add comment 100 131 }
Add comment 101 132 });
Add comment 102 133 }
Add comment 108 139
Add comment 109 140 public toggleTabMenu() {
Add comment 110 141 this.currentChartType = this.currentChartType ? this.currentChartType : CHART_TYPE.COLUMN_GROUPED;
Add comment 111 Minus this._tabsMenuOverlaySettings.positionStrategy.settings.target = this.button.nativeElement;
Add comment 142 Plus this._tabsMenuOverlaySettings.target = this.button.nativeElement;
Add comment 112 143 this.tabsMenu.collapsed ? this.tabsMenu.open(this._tabsMenuOverlaySettings) : this.tabsMenu.close();
Add comment 113 144 }
Add comment 114 145
Add comment 126 157 this.currentChartType = currentChartType;
Add comment 127 158 this.chartPreview.clear();
Add comment 128 159 this.contextDirective.chartsDirective.chartFactory(currentChartType, this.chartPreview);
Add comment 129 Minus this._chartPreviewDialogOS.positionStrategy.settings.target = this.tabsMenu.element;
Add comment 130 Minus this._chartPreviewDialogOS.positionStrategy.settings.openAnimation = null;
Add comment 131 Minus this.chartPreviewDialog.open(this._chartPreviewDialogOS);
Add comment 160 Plus this._chartPreviewDialogOverlaySettings.target = this.tabsMenu.element;
Add comment 161 Plus this.chartPreviewDialog.open(this._chartPreviewDialogOverlaySettings);
Add comment 132 162 }
Add comment 133 163
Add comment 134 164 public hidePreview() {
Add comment 144 174 }
Add comment 145 175
Add comment 146 176 public closeDialog() {
Add comment 177 Plus const info = this.overlayService.getOverlayById(this._dialogId);
Add comment 178 Plus if (info) {
Add comment 147 179 this.overlayService.hide(this._dialogId);
Add comment 180 Plus this.overlayService.detach(this._dialogId);
Add comment 181 Plus this._dialogId = undefined;
Add comment 148 182 }
Add comment 149 Minus
Add comment 150 Minus private getPositionSettings(horizontal, vertical) {
Add comment 151 Minus return {
Add comment 152 Minus closeOnOutsideClick: false, modal: false,
Add comment 153 Minus scrollStrategy: new AbsoluteScrollStrategy(),
Add comment 154 Minus positionStrategy: new AutoPositionStrategy({
Add comment 155 Minus horizontalDirection: horizontal, horizontalStartPoint: horizontal,
Add comment 156 Minus verticalStartPoint: vertical, verticalDirection: vertical, closeAnimation: null
Add comment 157 Minus })
Add comment 158 Minus };
Add comment 159 183 }
Add comment 160 184 }
Add comment 161 185