Skip to content

Commit

Permalink
feat(grid): create a setter for grid's outlet #7379
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyexeption committed Jul 23, 2020
1 parent 66b8008 commit b1d4850
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
[igxFocus]="true" [disableRipple]="true"></igx-checkbox>
</ng-container>
<ng-container *ngIf="column.dataType === 'date'">
<igx-date-picker [style.width.%]="100" [outlet]="grid.outletDirective" mode="dropdown"
<igx-date-picker [style.width.%]="100" [outlet]="grid.outlet" mode="dropdown"
[locale]="grid.locale" [(value)]="editValue" [igxFocus]="true" [labelVisibility]="false">
</igx-date-picker>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface GridType extends IGridDataBindable {
selectionService: any;
navigation: any;
filteringService: any;
outletDirective: any;
outlet: any;

calcHeight: number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ <h6 class="igx-filter-empty__title">
mode="dropdown"
[(ngModel)]="searchValue"
[locale]="grid.locale"
[outlet]="grid.outletDirective">
[outlet]="grid.outlet">
<ng-template igxDatePickerTemplate let-openDialog="openDialog" let-value="value">
<igx-input-group #dropDownTarget type="box" [displayDensity]="'compact'">
<input #searchValueInput
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
tabindex="0"
mode="dropdown"
[value]="value"
[outlet]="filteringService.grid.outletDirective"
[outlet]="filteringService.grid.outlet"
[locale]="filteringService.grid.locale"
(onSelection)="onDateSelected($event)"
(onClosed)="datePickerClose()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
constructor(public filteringService: IgxFilteringService, public element: ElementRef, public cdr: ChangeDetectorRef) { }

ngAfterViewInit() {
this._conditionsOverlaySettings.outlet = this.column.grid.outletDirective;
this._operatorsOverlaySettings.outlet = this.column.grid.outletDirective;
this._conditionsOverlaySettings.outlet = this.column.grid.outlet;
this._operatorsOverlaySettings.outlet = this.column.grid.outlet;

const selectedItem = this.expressionsList.find(expr => expr.isSelected === true);
if (selectedItem) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</igx-select-item>
</igx-select>

<igx-date-picker #datePicker mode="dropdown" [(ngModel)]="expressionUI.expression.searchVal" [locale]="grid.locale" [outlet]="grid.outletDirective">
<igx-date-picker #datePicker mode="dropdown" [(ngModel)]="expressionUI.expression.searchVal" [locale]="grid.locale" [outlet]="grid.outlet">
<ng-template igxDatePickerTemplate let-openDialog="openDialog" let-value="value">
<igx-input-group #dropDownTarget type="box" [displayDensity]="displayDensity">
<input #input
Expand Down
35 changes: 21 additions & 14 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
positionStrategy: new ConnectedPositioningStrategy(this._advancedFilteringPositionSettings),
};

protected _userOutletDirective: IgxOverlayOutletDirective;

/**
* @hidden @internal
*/
Expand Down Expand Up @@ -1797,20 +1799,12 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
@ViewChild('tfoot', { static: true })
public tfoot: ElementRef;


/**
* @hidden @internal
*/
@ViewChild('igxFilteringOverlayOutlet', { read: IgxOverlayOutletDirective, static: true })
protected _outletDirective: IgxOverlayOutletDirective;

/**
* @hidden @internal
*/
public get outletDirective() {
return this._outletDirective;
}

/**
* @hidden @internal
*/
Expand All @@ -1835,7 +1829,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
* @hidden @internal
*/
public get parentRowOutletDirective() {
return this.outletDirective;
return this.outlet;
}

/**
Expand Down Expand Up @@ -2918,7 +2912,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
return;
}

if (this.overlayService.getOverlayById(event.id)?.settings?.outlet === this.outletDirective &&
if (this.overlayService.getOverlayById(event.id)?.settings?.outlet === this.outlet &&
this.overlayIDs.indexOf(event.id) < 0) {
this.overlayIDs.push(event.id);
}
Expand Down Expand Up @@ -3363,10 +3357,23 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
}

/**
* @hidden @internal
* Gets the outlet used to attach the grid's overlays to.
* @remark
* If set, returns the outlet defined outside the grid. Otherwise returns the grid's internal outlet directive.
*/
get outlet() {
return this.resolveOutlet();
}

protected resolveOutlet() {
return this._userOutletDirective ? this._userOutletDirective : this._outletDirective;
}

/**
* Sets the outlet used to attach the grid's overlays to.
*/
protected get outlet() {
return this.outletDirective;
set outlet(val: any) {
this._userOutletDirective = val;
}

/**
Expand Down Expand Up @@ -6493,7 +6500,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
if (!this._advancedFilteringOverlayId) {
this._advancedFilteringOverlaySettings.positionStrategy.settings.target =
(this as any).rootGrid ? (this as any).rootGrid.nativeElement : this.nativeElement;
this._advancedFilteringOverlaySettings.outlet = this.outletDirective;
this._advancedFilteringOverlaySettings.outlet = this.outlet;

this._advancedFilteringOverlayId = this.overlayService.attach(
IgxAdvancedFilteringDialogComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<igx-checkbox (change)="editValue = $event.checked" [value]="editValue" [checked]="editValue" [disableRipple]="true"></igx-checkbox>
</ng-container>
<ng-container *ngIf="column.dataType === 'date'">
<igx-date-picker [style.width.%]="100" [outlet]="grid.outletDirective" mode="dropdown"
<igx-date-picker [style.width.%]="100" [outlet]="grid.outlet" mode="dropdown"
[locale]="grid.locale" [(value)]="editValue" [igxFocus]="true" [labelVisibility]="false">
</igx-date-picker>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[column]="child"
[gridID]="child.grid.id"
[igxColumnMovingDrag]="child"
[ghostHost]="grid.outletDirective.nativeElement"
[ghostHost]="grid.outlet.nativeElement"
[attr.droppable]="true"
[igxColumnMovingDrop]="child">
</igx-grid-header-group>
Expand Down Expand Up @@ -48,7 +48,7 @@
'igx-grid__th--selected': selected,
'igx-grid__th--active': activeGroup}"
[igxColumnMovingDrag]="column"
[ghostHost]="grid.outletDirective.nativeElement"
[ghostHost]="grid.outlet.nativeElement"
[attr.droppable]="true"
[igxColumnMovingDrop]="column"
(pointerdown)="activate()"
Expand Down Expand Up @@ -81,7 +81,7 @@

<ng-container *ngIf="!column.columnGroup">
<span *ngIf="grid.hasMovableColumns" class="igx-grid__th-drop-indicator-left"></span>
<igx-grid-header [igxColumnMovingDrag]="column" [ghostHost]="grid.outletDirective.nativeElement" [attr.droppable]="true" (pointerdown)="activate()" [igxColumnMovingDrop]="column" [gridID]="column.grid.id" [column]="column"></igx-grid-header>
<igx-grid-header [igxColumnMovingDrag]="column" [ghostHost]="grid.outlet.nativeElement" [attr.droppable]="true" (pointerdown)="activate()" [igxColumnMovingDrop]="column" [gridID]="column.grid.id" [column]="column"></igx-grid-header>
<igx-grid-filtering-cell *ngIf="grid.allowFiltering && grid.filterMode == 'quickFilter'" [column]="column" [attr.draggable]="false"></igx-grid-filtering-cell>
<span *ngIf="!column.columnGroup && column.resizable" class="igx-grid__th-resize-handle"
[igxResizeHandle]="column"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,19 @@ export class IgxHierarchicalGridBaseDirective extends IgxGridBaseDirective {
}

/**
* @hidden
* Gets the outlet used to attach the grid's overlays to.
* @remark
* If set, returns the outlet defined outside the grid. Otherwise returns the grid's internal outlet directive.
*/
get outlet() {
return this.rootGrid ? this.rootGrid.resolveOutlet() : this.resolveOutlet();
}

/**
* Sets the outlet used to attach the grid's overlays to.
*/
protected get outlet() {
return this.rootGrid ? this.rootGrid.outletDirective : this.outletDirective;
set outlet(val: any) {
this._userOutletDirective = val;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export class IgxGridToolbarComponent extends DisplayDensityBase implements After
*/
public exportClicked() {
this._overlaySettings.positionStrategy.settings.target = this.exportButton.nativeElement;
this._overlaySettings.outlet = this.grid.outletDirective;
this._overlaySettings.outlet = this.grid.outlet;
this.exportDropdown.toggle(this._overlaySettings);
}

Expand Down Expand Up @@ -351,7 +351,7 @@ export class IgxGridToolbarComponent extends DisplayDensityBase implements After
*/
public toggleColumnHidingUI() {
this._overlaySettings.positionStrategy.settings.target = this.columnHidingButton.nativeElement;
this._overlaySettings.outlet = this.grid.outletDirective;
this._overlaySettings.outlet = this.grid.outlet;
this.columnHidingDropdown.toggle(this._overlaySettings);
}

Expand All @@ -363,7 +363,7 @@ export class IgxGridToolbarComponent extends DisplayDensityBase implements After
*/
public toggleColumnPinningUI() {
this._overlaySettings.positionStrategy.settings.target = this.columnPinningButton.nativeElement;
this._overlaySettings.outlet = this.grid.outletDirective;
this._overlaySettings.outlet = this.grid.outlet;
this.columnPinningDropdown.toggle(this._overlaySettings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<igx-checkbox (change)="editValue = $event.checked" [value]="editValue" [checked]="editValue" [disableRipple]="true"></igx-checkbox>
</ng-container>
<ng-container *ngIf="column.dataType === 'date'">
<igx-date-picker [style.width.%]="100" [outlet]="grid.outletDirective" mode="dropdown"
<igx-date-picker [style.width.%]="100" [outlet]="grid.outlet" mode="dropdown"
[locale]="grid.locale" [(value)]="editValue" [igxFocus]="focused" [labelVisibility]="false">
</igx-date-picker>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class GridColumnSelectionSampleComponent implements OnInit {

public toggleColumnSelection() {
this._overlaySettings.positionStrategy.settings.target = this.columnSelectionButton.nativeElement;
this._overlaySettings.outlet = this.grid1.outletDirective;
this._overlaySettings.outlet = this.grid1.outlet;
this.columnSelectionDropdown.toggle(this._overlaySettings);
}

Expand Down

0 comments on commit b1d4850

Please sign in to comment.