Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

igxGrid - refactor header and filter cell components 6.2.x #3017

Merged
merged 39 commits into from
Nov 23, 2018
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
706e4c3
feat(filtering): header group component POC #542
SAndreeva Nov 6, 2018
7c2c66a
feat(filtering): header group component POC #542
SAndreeva Nov 6, 2018
a96cd3f
feat(filtering): some MCH related improvements #542
SAndreeva Nov 12, 2018
c1298b0
feat(filtering): fix some minor issues #542
SAndreeva Nov 13, 2018
419561a
test(*): start fixing failing tests for MCH #542
SAndreeva Nov 14, 2018
1b1acf8
feat(filtering): fix build error #542
SAndreeva Nov 14, 2018
b953461
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 14, 2018
4daf8d8
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 14, 2018
3e47a1a
chore(filtering): Small refactoring (#2938)
Nov 9, 2018
67751be
test(*): refactor failing tests #542
SAndreeva Nov 17, 2018
ad4e781
feat(filtering): CD strategy for header group component #542
SAndreeva Nov 18, 2018
1de81f5
feat(filtering): rework column moving dragGhost creation #542
SAndreeva Nov 18, 2018
06f58f3
feat(filtering): minor fixes and improvements #542
SAndreeva Nov 18, 2018
ef196bd
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 19, 2018
334c1a2
chore(filtering): Change filtering components strategy to OnPush (#2938)
Nov 19, 2018
0aec11c
test(filtering): Fix failing tests (#2938)
Nov 19, 2018
e1f3c4c
test(filtering): Fix filtering UI tests (#2938)
Nov 19, 2018
f100af8
test(filtering): filtering UI tests refactoring #542
SAndreeva Nov 20, 2018
4533778
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 20, 2018
9a4bdba
test(filtering): fix timer issues in filtering UI test #542
SAndreeva Nov 20, 2018
611e93b
fix(*): sorting icon not being updated when sort/groupBy via API #542
SAndreeva Nov 20, 2018
e68e4db
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 20, 2018
3a7d4e0
feat(filtering): fix introduced resizer bug #542
SAndreeva Nov 20, 2018
5039723
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 20, 2018
52415a3
chore(*): review comments changes #542
SAndreeva Nov 20, 2018
b88c3e5
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 21, 2018
79cafbb
feat(filtering): fix broken behaviors #542
SAndreeva Nov 21, 2018
878e2eb
chore(*): some clean up, etc. #542
SAndreeva Nov 21, 2018
5f3b310
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
kdinev Nov 21, 2018
d14657b
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
kdinev Nov 22, 2018
5703000
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
kdinev Nov 22, 2018
8555ba9
feat(filtering): some API refinements #542
SAndreeva Nov 22, 2018
e45fb70
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
SAndreeva Nov 22, 2018
678a352
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
kdinev Nov 22, 2018
d520736
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
Nov 22, 2018
e1fda82
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
bkulov Nov 22, 2018
67910c3
fix(filtering): Fix async issue in test (#2995)
Nov 22, 2018
d003b54
Merge branch '6.2.x' into SAndreeva/header-group-component-6.2.x
bkulov Nov 23, 2018
6f92a55
fix(filtering): Fix empty bool expected result (#2938)
Nov 23, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions projects/igniteui-angular/src/lib/core/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ export const enum KEYS {
* let range = document.createRange();
* let column = this.grid.columnList.filter(c => c.field === 'ID')[0];
*
* let size = valToPxlsUsingRange(range, column.cells[0].nativeElement);
* let size = getNodeSizeViaRange(range, column.cells[0].nativeElement);
* ```
*/
export function valToPxlsUsingRange(range: Range, node: any): number {
export function getNodeSizeViaRange(range: Range, node: any): number {
let overflow = null;
if (isIE() || isEdge()) {
overflow = node.style.overflow;
Expand Down Expand Up @@ -194,7 +194,7 @@ export function valToPxlsUsingRange(range: Range, node: any): number {
* let size = valToPxlsUsingCanvas(ctx, column.cells[0].nativeElement);
* ```
*/
export function valToPxlsUsingCanvas(canvas2dCtx: any, node: any): number {
export function getNodeSizeViaCanvas(canvas2dCtx: any, node: any): number {
const s = this.grid.document.defaultView.getComputedStyle(node);

// need to set the font to get correct width
Expand Down Expand Up @@ -230,6 +230,22 @@ export function isNavigationKey(key: string): boolean {
'home', 'end', 'space', 'spacebar', ' '].indexOf(key) !== -1;
}

/**
*@hidden
*/
export function flatten(arr: any[]) {
let result = [];

arr.forEach(el => {
result.push(el);
if (el.children) {
const children = Array.isArray(el.children) ? el.children : el.children.toArray();
result = result.concat(flatten(children));
}
});
return result;
}

export interface CancelableEventArgs {
/**
* Provides the ability to cancel the event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,11 +572,14 @@ export class IgxDragDirective implements OnInit, OnDestroy {

/**
* @hidden
* Create dragGhost element - copy of the base element. Bind all needed events.
* Create dragGhost element - if a Node object is provided it creates a clone of that node,
* otherwise it clones the host element.
* Bind all needed events.
* @param event Pointer event required when the dragGhost is being initialized.
* @param node The Node object to be cloned.
*/
protected createDragGhost(event) {
this._dragGhost = this.element.nativeElement.cloneNode(true);
protected createDragGhost(event, node: any = null) {
this._dragGhost = node ? node.cloneNode(true) : this.element.nativeElement.cloneNode(true);
this._dragGhost.style.transitionDuration = '0.0s';
this._dragGhost.style.position = 'absolute';
this._dragGhost.style.top = this._dragStartY + 'px';
Expand Down
5 changes: 3 additions & 2 deletions projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IgxSelectionAPIService } from '../core/selection';
import { IgxTextHighlightDirective } from '../directives/text-highlight/text-highlight.directive';
import { GridBaseAPIService } from './api.service';
import { IgxColumnComponent } from './column.component';
import { isNavigationKey, valToPxlsUsingRange, KEYS } from '../core/utils';
import { isNavigationKey, getNodeSizeViaRange, KEYS } from '../core/utils';
import { State } from '../services/index';
import { IgxGridBaseComponent, IGridEditEventArgs } from './grid-base.component';
import { first } from 'rxjs/operators';
Expand Down Expand Up @@ -380,6 +380,7 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
* @memberof IgxGridCellComponent
*/
@HostBinding('style.min-width')
@HostBinding('style.max-width')
@HostBinding('style.flex-basis')
get width() {
const hasVerticalScroll = !this.grid.verticalScrollContainer.dc.instance.notVirtual;
Expand Down Expand Up @@ -902,7 +903,7 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
*/
public calculateSizeToFit(range: any): number {
return Math.max(...Array.from(this.nativeElement.children)
.map((child) => valToPxlsUsingRange(range, child)));
.map((child) => getNodeSizeViaRange(range, child)));
}

private isToggleKey(key) {
Expand Down
67 changes: 34 additions & 33 deletions projects/igniteui-angular/src/lib/grids/column.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ import {
IgxCellHeaderTemplateDirective,
IgxCellTemplateDirective
} from './grid.common';
import {
IgxBooleanFilteringOperand, IgxNumberFilteringOperand, IgxDateFilteringOperand,
IgxStringFilteringOperand,
IgxGridBaseComponent,
FilteringExpressionsTree
} from '../../public_api';
import { IgxGridHeaderComponent } from './grid-header.component';
import { valToPxlsUsingRange } from '../core/utils';
import { DefaultSortingStrategy, ISortingStrategy } from '../data-operations/sorting-strategy';
import { getNodeSizeViaRange, flatten } from '../core/utils';
import {
IgxBooleanFilteringOperand,
IgxNumberFilteringOperand,
IgxDateFilteringOperand,
IgxStringFilteringOperand } from '../data-operations/filtering-condition';
import { IgxGridBaseComponent } from './grid-base.component';
import { FilteringExpressionsTree } from '../data-operations/filtering-expressions-tree';
import { IgxGridFilteringCellComponent } from './filtering/grid-filtering-cell.component';

/**
* **Ignite UI for Angular Column** -
Expand Down Expand Up @@ -304,6 +306,11 @@ export class IgxColumnComponent implements AfterContentInit {
*/
@Input()
public headerClasses = '';
/**
*@hidden
*/
@Input()
public headerGroupClasses = '';
/**
* Sets a conditional class selector of the column cells.
* Accepts an object literal, containing key-value pairs,
Expand Down Expand Up @@ -1064,9 +1071,19 @@ export class IgxColumnComponent implements AfterContentInit {
* @memberof IgxColumnComponent
*/
get headerCell(): IgxGridHeaderComponent {
if (this.grid.headerList.length > 0) {
return flatten(this.grid.headerList.toArray()).find((h) => h.column === this);
}
return this.grid.headerCellList.find((header) => header.column === this);
}

/**
* Returns a reference to the filter cell of the column.
* ```typescript
* let column = this.grid.columnList.filter(c => c.field === 'ID')[0];
* let filterell = column.filterell;
* ```
* @memberof IgxColumnComponent
*/
get filterCell(): IgxGridFilteringCellComponent {
return this.grid.filterCellList.find((filterCell) => filterCell.column === this);
}

/**
Expand Down Expand Up @@ -1109,7 +1126,7 @@ export class IgxColumnComponent implements AfterContentInit {
if (this.cells[0].nativeElement.children.length > 0) {
this.cells.forEach((cell) => cellsContentWidths.push(cell.calculateSizeToFit(range)));
} else {
cellsContentWidths = this.cells.map((cell) => valToPxlsUsingRange(range, cell.nativeElement));
cellsContentWidths = this.cells.map((cell) => getNodeSizeViaRange(range, cell.nativeElement));
}

const index = cellsContentWidths.indexOf(Math.max(...cellsContentWidths));
Expand All @@ -1122,16 +1139,15 @@ export class IgxColumnComponent implements AfterContentInit {

if (this.headerCell) {
let headerCell;
const titleIndex = this.grid.hasMovableColumns ? 1 : 0;
if (this.headerTemplate && this.headerCell.elementRef.nativeElement.children[titleIndex].children.length > 0) {
headerCell = Math.max(...Array.from(this.headerCell.elementRef.nativeElement.children[titleIndex].children)
.map((child) => valToPxlsUsingRange(range, child)));
if (this.headerTemplate && this.headerCell.elementRef.nativeElement.children[0].children.length > 0) {
headerCell = Math.max(...Array.from(this.headerCell.elementRef.nativeElement.children[0].children)
.map((child) => getNodeSizeViaRange(range, child)));
} else {
headerCell = valToPxlsUsingRange(range, this.headerCell.elementRef.nativeElement.children[titleIndex]);
headerCell = getNodeSizeViaRange(range, this.headerCell.elementRef.nativeElement.children[0]);
}

if (this.sortable || (this.grid.allowFiltering && this.filterable)) {
headerCell += this.headerCell.elementRef.nativeElement.children[titleIndex + 1].getBoundingClientRect().width;
if (this.sortable) {
headerCell += this.headerCell.elementRef.nativeElement.children[1].getBoundingClientRect().width;
}

const headerStyle = this.grid.document.defaultView.getComputedStyle(this.headerCell.elementRef.nativeElement);
Expand Down Expand Up @@ -1350,25 +1366,10 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
if (typeof val.width === 'string' && val.width.indexOf('%') !== -1) {
isChildrenWidthInPercent = true;
}

return acc + parseInt(val.width, 10);
}, 0)}`;
return isChildrenWidthInPercent ? width + '%' : width;
}

set width(val) { }
}



function flatten(arr: any[]) {
let result = [];

arr.forEach(el => {
result.push(el);
if (el.children) {
result = result.concat(flatten(el.children.toArray()));
}
});
return result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

<ng-template #defaultFilter>
<igx-chips-area #chipsArea class="igx-filtering-chips">
<ng-container *ngFor="let item of visibleExpressionsList; let last = last;" >
<ng-container *ngFor="let item of expressionsList; let last = last; let index = index;" >
<igx-chip
*ngIf="isChipVisible(index)"
[removable]="true"
[displayDensity]="'cosy'"
(click)="onChipClicked(item.expression)"
Expand All @@ -24,7 +25,7 @@
{{filteringService.getChipLabel(item.expression)}}
</span>
</igx-chip>
<span class="igx-filtering-chips__connector" *ngIf="!last">{{filteringService.getOperatorAsString(item.afterOperator)}}</span>
<span class="igx-filtering-chips__connector" *ngIf="!last && isChipVisible(index + 1)">{{filteringService.getOperatorAsString(item.afterOperator)}}</span>
</ng-container>
<div #moreIcon [ngClass]="filteringIndicatorClass()" (click)="onChipClicked()" (keydown)="onChipKeyDown($event)" tabindex="0">
<igx-icon>filter_list</igx-icon>
Expand Down
Loading