Skip to content

Commit

Permalink
Merge branch 'master' into bpenkov/igx-date-range
Browse files Browse the repository at this point in the history
  • Loading branch information
Lipata authored Apr 21, 2020
2 parents 0400daf + f68ceb8 commit 460f075
Show file tree
Hide file tree
Showing 23 changed files with 500 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
IgxGridPaginatorOptionsPipe,
IgxHasVisibleColumnsPipe,
IgxDatePipeComponent,
IgxDecimalPipeComponent
IgxDecimalPipeComponent,
IgxGridRowPinningPipe
} from './pipes';

@NgModule({
Expand All @@ -24,7 +25,8 @@ import {
IgxGridCellStylesPipe,
IgxGridCellStyleClassesPipe,
IgxGridPaginatorOptionsPipe,
IgxHasVisibleColumnsPipe
IgxHasVisibleColumnsPipe,
IgxGridRowPinningPipe
],
exports: [
IgxDatePipeComponent,
Expand All @@ -36,7 +38,8 @@ import {
IgxGridCellStylesPipe,
IgxGridCellStyleClassesPipe,
IgxGridPaginatorOptionsPipe,
IgxHasVisibleColumnsPipe
IgxHasVisibleColumnsPipe,
IgxGridRowPinningPipe
],
imports: [
CommonModule
Expand Down
31 changes: 31 additions & 0 deletions projects/igniteui-angular/src/lib/grids/common/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,34 @@ export class IgxDecimalPipeComponent extends DecimalPipe implements PipeTransfor
}
}
}

/**
* @hidden
*/
@Pipe({
name: 'gridRowPinning',
pure: true
})
export class IgxGridRowPinningPipe implements PipeTransform {

constructor(private gridAPI: GridBaseAPIService<IgxGridBaseDirective & GridType>) {}

public transform(collection: any[] , id: string, isPinned = false, pipeTrigger: number) {
const grid = this.gridAPI.grid;

if (!grid.hasPinnedRecords) {
return isPinned ? [] : collection;
}

if (grid.hasPinnedRecords && isPinned) {
const result = collection.filter(rec => grid.isRecordPinned(rec));
result.sort((rec1, rec2) => grid.pinRecordIndex(rec1) - grid.pinRecordIndex(rec2));
return result;
}

grid.unpinnedRecords = collection;
return collection.map((rec) => {
return grid.isRecordPinned(rec) ? { recordRef: rec, ghostRecord: true} : rec;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { IBaseChipEventArgs, IgxChipsAreaComponent, IgxChipComponent } from '../
import { ExpressionUI } from '../grid-filtering.service';
import { IgxDropDownItemComponent } from '../../../drop-down/drop-down-item.component';
import { IgxFilteringService } from '../grid-filtering.service';
import { KEYS, isEdge, isIE } from '../../../core/utils';
import { KEYS, isEdge } from '../../../core/utils';
import { AbsoluteScrollStrategy } from '../../../services/overlay/scroll';

/**
Expand Down Expand Up @@ -262,11 +262,8 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
public onInput(eventArgs) {
// The 'iskeyPressed' flag is needed for a case in IE, because the input event is fired on focus and for some reason,
// when you have a japanese character as a placeholder, on init the value here is empty string .
// There is no need to reset the value on every invalid number input.
// The invalid value is converted to empty string input type="number"
const target = eventArgs.target;
if (isEdge() && target.type !== 'number' || this.isKeyPressed && isIE() || target.value) {
this.value = target.value;
if (isEdge() || this.isKeyPressed || eventArgs.target.value) {
this.value = eventArgs.target.value;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
}
}

constructor(private cdr: ChangeDetectorRef) {}
constructor(private cdr: ChangeDetectorRef, private element: ElementRef) {}

/**
* @hidden @internal
Expand Down Expand Up @@ -519,7 +519,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
this.customDialog.selectedOperator = eventArgs.newSelection.value;
eventArgs.cancel = true;
if (this.overlayComponentId) {
this.mainDropdown.nativeElement.style.display = 'none';
this.element.nativeElement.style.display = 'none';
}
this.subMenu.close();
this.customDialog.open(this.mainDropdown.nativeElement);
Expand Down
20 changes: 11 additions & 9 deletions projects/igniteui-angular/src/lib/grids/grid-base.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2930,8 +2930,9 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements

public setFilterData(data, pinned: boolean) {
if (this.hasPinnedRecords && pinned) {
this._filteredPinnedData = data;
this.filteredData = [... this._filteredPinnedData, ... this._filteredUnpinnedData];
this._filteredPinnedData = data || [];
const filteredUnpinned = this._filteredUnpinnedData || [];
this.filteredData = [... this._filteredPinnedData, ... filteredUnpinned];
} else if (this.hasPinnedRecords && !pinned) {
this._filteredUnpinnedData = data;
} else {
Expand Down Expand Up @@ -2987,6 +2988,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
* @internal
*/
public setFilteredSortedData(data, pinned: boolean) {
data = data.map(rec => rec.ghostRecord !== undefined ? rec.recordRef : rec);
if (this._pinnedRecordIDs.length > 0 && pinned) {
this._filteredSortedPinnedData = data;
this.filteredSortedData = this.isRowPinningToTop ? [... this._filteredSortedPinnedData, ... this._filteredSortedUnpinnedData] :
Expand Down Expand Up @@ -5164,13 +5166,13 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
return this.unpinnedRecords ? this.unpinnedRecords : this.verticalScrollContainer.igxForOf;
}

/**
* Returns the currently transformed paged/filtered/sorted/grouped pinned data, displayed in the grid.
* @example
* ```typescript
* const pinnedDataView = this.grid.pinnedDataView;
* ```
*/
/**
* Returns the currently transformed paged/filtered/sorted/grouped pinned data, displayed in the grid.
* @example
* ```typescript
* const pinnedDataView = this.grid.pinnedDataView;
* ```
*/
get pinnedDataView(): any[] {
return this.pinnedRows.map(row => row.rowData);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,6 @@ describe('IgxGrid - Filtering Row UI actions #grid', () => {

expect(grid.rowList.length).toEqual(3);
verifyFilterRowUI(input, close, reset, false);

// greater than or equal to with invalid value should not reset filter
GridFunctions.openFilterDDAndSelectCondition(fix, 4);
GridFunctions.typeValueInFilterRowInput('254..', fix, input);

expect(grid.rowList.length).toEqual(3);
verifyFilterRowUI(input, close, reset, false);
}));

// UI tests boolean column
Expand Down
5 changes: 1 addition & 4 deletions projects/igniteui-angular/src/lib/grids/grid/grid.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
IgxGridPagingPipe,
IgxGridGroupingPipe,
IgxGridSortingPipe,
IgxGridFilteringPipe,
IgxGridRowPinningPipe
IgxGridFilteringPipe
} from './grid.pipes';
import { IgxGridGroupByRowComponent } from './groupby-row.component';
import { IgxGridRowComponent } from './grid-row.component';
Expand Down Expand Up @@ -42,7 +41,6 @@ import { IgxGridExpandableCellComponent } from './expandable-cell.component';
IgxGridPagingPipe,
IgxGridSortingPipe,
IgxGridFilteringPipe,
IgxGridRowPinningPipe,
IgxGridSummaryPipe,
IgxGridDetailsPipe,
IgxGridExpandableCellComponent
Expand All @@ -63,7 +61,6 @@ import { IgxGridExpandableCellComponent } from './expandable-cell.component';
IgxGridPagingPipe,
IgxGridSortingPipe,
IgxGridFilteringPipe,
IgxGridRowPinningPipe,
IgxGridSummaryPipe,
IgxGridDetailsPipe,
IgxGridCommonModule
Expand Down
30 changes: 0 additions & 30 deletions projects/igniteui-angular/src/lib/grids/grid/grid.pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,33 +152,3 @@ export class IgxGridFilteringPipe implements PipeTransform {
}
}

/**
* @hidden
*/
@Pipe({
name: 'gridRowPinning',
pure: true
})
export class IgxGridRowPinningPipe implements PipeTransform {

constructor(private gridAPI: GridBaseAPIService<IgxGridBaseDirective & GridType>) {}

public transform(collection: any[] , id: string, isPinned = false, pipeTrigger: number) {
const grid = this.gridAPI.grid;

if (!grid.hasPinnedRecords) {
return isPinned ? [] : collection;
}

if (grid.hasPinnedRecords && isPinned) {
const result = collection.filter(rec => grid.isRecordPinned(rec));
result.sort((rec1, rec2) => grid.pinRecordIndex(rec1) - grid.pinRecordIndex(rec2));
return result;
}

grid.unpinnedRecords = collection;
return collection.map((rec) => {
return grid.isRecordPinned(rec) ? { recordRef: rec, ghostRecord: true} : rec;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ describe('IgxGrid - search API #grid - ', () => {
setupGridScrollDetection(fix, grid);
fix.detectChanges();

grid.data[29] = { ID: 30, Name: 'Eduardo Ramirez', JobTitle: 'Manager', HireDate: '1887-11-28T11:23:17.714Z' };
grid.data[29].HireDate = '1887-11-28T11:23:17.714Z';
grid.width = '500px';
grid.height = '600px';
fixNativeElement = fix.debugElement.nativeElement;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<ng-template #defaultPinnedIndicator>
<igx-chip *ngIf="displayPinnedChip" class="igx-grid__td--pinned-chip" [disabled]="true" [displayDensity]="'compact'">{{ grid.resourceStrings.igx_grid_pinned_row_indicator }}</igx-chip>
</ng-template>
<ng-template #defaultCell>
<div igxTextHighlight style="pointer-events: none" [cssClass]="highlightClass" [activeCssClass]="activeHighlightClass" [groupName]="gridID"
[value]="formatter ? formatter(value) : column.dataType === 'number' ? (value | igxdecimal: grid.locale) : column.dataType === 'date' ? (value | igxdate: grid.locale) : value"
Expand Down Expand Up @@ -36,6 +39,8 @@
(click)="toggle($event)" (focus)="onIndicatorFocus()" tabindex="-1">
<ng-container *ngTemplateOutlet="iconTemplate; context: { $implicit: this }">
</ng-container>
<ng-container *ngTemplateOutlet="pinnedIndicatorTemplate; context: context">
</ng-container>
</div>
<div *ngIf="isLoading"
(dblclick)="onLoadingDblClick($event)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Component, ChangeDetectorRef, ElementRef, ViewChild, Inject,
ChangeDetectionStrategy, NgZone, OnInit, Input, TemplateRef } from '@angular/core';
import { IgxGridCellComponent } from '../cell.component';
import { Component, ChangeDetectorRef, ElementRef, Inject,
ChangeDetectionStrategy, NgZone, Input } from '@angular/core';
import { IgxTreeGridAPIService } from './tree-grid-api.service';
import { GridBaseAPIService } from '../api.service';
import { getNodeSizeViaRange, PlatformUtil } from '../../core/utils';
import { PlatformUtil } from '../../core/utils';
import { DOCUMENT } from '@angular/common';
import { IgxGridBaseDirective } from '../grid';
import { IgxGridSelectionService, IgxGridCRUDService } from '../selection/selection.service';
Expand All @@ -21,15 +20,15 @@ export class IgxTreeGridCellComponent extends IgxGridExpandableCellComponent {
private treeGridAPI: IgxTreeGridAPIService;

constructor(
selectionService: IgxGridSelectionService,
crudService: IgxGridCRUDService,
gridAPI: GridBaseAPIService<IgxGridBaseDirective & GridType>,
cdr: ChangeDetectorRef,
element: ElementRef,
protected zone: NgZone,
touchManager: HammerGesturesManager,
@Inject(DOCUMENT) public document,
protected platformUtil: PlatformUtil) {
selectionService: IgxGridSelectionService,
crudService: IgxGridCRUDService,
gridAPI: GridBaseAPIService<IgxGridBaseDirective & GridType>,
cdr: ChangeDetectorRef,
element: ElementRef,
protected zone: NgZone,
touchManager: HammerGesturesManager,
@Inject(DOCUMENT) public document,
protected platformUtil: PlatformUtil) {
super(selectionService, crudService, gridAPI, cdr, element, zone, touchManager, document, platformUtil);
this.treeGridAPI = <IgxTreeGridAPIService>gridAPI;
}
Expand All @@ -46,7 +45,6 @@ export class IgxTreeGridCellComponent extends IgxGridExpandableCellComponent {
@Input()
showIndicator = false;


/**
* @hidden
*/
Expand Down
Loading

0 comments on commit 460f075

Please sign in to comment.