Skip to content

Commit

Permalink
chore(grid): Resolves merge conflicts and fixes sample to match lib v
Browse files Browse the repository at this point in the history
  • Loading branch information
3phase committed Apr 5, 2022
2 parents cf4171d + e09002b commit 3a6d0dd
Show file tree
Hide file tree
Showing 21 changed files with 274 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -389,13 +389,9 @@ export class IgxDateFilteringOperand extends IgxBaseDateTimeFilteringOperand {
}
}

export class IgxDateTimeFilteringOperand extends IgxDateFilteringOperand {
export class IgxDateTimeFilteringOperand extends IgxBaseDateTimeFilteringOperand {
protected constructor() {
super();
let index = this.operations.indexOf(this.condition('equals'));
this.operations.splice(index, 1);
index = this.operations.indexOf(this.condition('doesNotEqual'));
this.operations.splice(index, 1);
this.operations = [{
name: 'equals',
isUnary: false,
Expand Down Expand Up @@ -432,6 +428,172 @@ export class IgxDateTimeFilteringOperand extends IgxDateFilteringOperand {
targetp.minutes !== searchp.minutes ||
targetp.seconds !== searchp.seconds;
}
}, {
name: 'before',
isUnary: false,
iconName: 'is-before',
logic: (target: Date, searchVal: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

return target < searchVal;
}
}, {
name: 'after',
isUnary: false,
iconName: 'is-after',
logic: (target: Date, searchVal: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

return target > searchVal;
}
}, {
name: 'today',
isUnary: true,
iconName: 'today',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yMd');
const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yMd');
return d.year === now.year &&
d.month === now.month &&
d.day === now.day;
}
}, {
name: 'yesterday',
isUnary: true,
iconName: 'yesterday',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const td = IgxDateTimeFilteringOperand.getDateParts(target, 'yMd');
const y = ((d) => new Date(d.setDate(d.getDate() - 1)))(new Date());
const yesterday = IgxDateTimeFilteringOperand.getDateParts(y, 'yMd');
return td.year === yesterday.year &&
td.month === yesterday.month &&
td.day === yesterday.day;
}
}, {
name: 'thisMonth',
isUnary: true,
iconName: 'this-month',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yM');
const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yM');
return d.year === now.year &&
d.month === now.month;
}
}, {
name: 'lastMonth',
isUnary: true,
iconName: 'last-month',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yM');
const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yM');
if (!now.month) {
now.month = 11;
now.year -= 1;
} else {
now.month--;
}
return d.year === now.year &&
d.month === now.month;
}
}, {
name: 'nextMonth',
isUnary: true,
iconName: 'next-month',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const d = IgxDateTimeFilteringOperand.getDateParts(target, 'yM');
const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'yM');
if (now.month === 11) {
now.month = 0;
now.year += 1;
} else {
now.month++;
}
return d.year === now.year &&
d.month === now.month;
}
}, {
name: 'thisYear',
isUnary: true,
iconName: 'this-year',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const d = IgxDateTimeFilteringOperand.getDateParts(target, 'y');
const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'y');
return d.year === now.year;
}
}, {
name: 'lastYear',
isUnary: true,
iconName: 'last-year',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const d = IgxDateTimeFilteringOperand.getDateParts(target, 'y');
const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'y');
return d.year === now.year - 1;
}
}, {
name: 'nextYear',
isUnary: true,
iconName: 'next-year',
logic: (target: Date) => {
if (!target) {
return false;
}

this.validateInputData(target);

const d = IgxDateTimeFilteringOperand.getDateParts(target, 'y');
const now = IgxDateTimeFilteringOperand.getDateParts(new Date(), 'y');
return d.year === now.year + 1;
}
}].concat(this.operations);
}
}
Expand Down
13 changes: 8 additions & 5 deletions projects/igniteui-angular/src/lib/grids/common/crud.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ export class IgxRowAddCrudState extends IgxRowCrudState {
* @hidden @internal
*/
public endRowTransaction(commit: boolean, event?: Event): IGridEditEventArgs {
if (this.row && this.row.getClassName() === IgxAddRow.name) {
const isAddRow = this.row && this.row.getClassName() === IgxAddRow.name;
if (isAddRow) {
this.grid.rowAdded.pipe(first()).subscribe((addRowArgs: IRowDataEventArgs) => {
const rowData = addRowArgs.data;
const pinnedIndex = this.grid.pinnedRecords.findIndex(x => x[this.primaryKey] === rowData[this.primaryKey]);
Expand All @@ -478,10 +479,12 @@ export class IgxRowAddCrudState extends IgxRowCrudState {
return args;
}

this.endAddRow();
if (commit) {
this.grid.rowAddedNotifier.next({ data: args.newValue });
this.grid.rowAdded.emit({ data: args.newValue });
if (isAddRow) {
this.endAddRow();
if (commit) {
this.grid.rowAddedNotifier.next({ data: args.newValue });
this.grid.rowAdded.emit({ data: args.newValue });
}
}

return args;
Expand Down
1 change: 1 addition & 0 deletions projects/igniteui-angular/src/lib/grids/common/pipes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class IgxGridRowClassesPipe implements PipeTransform {
index: number,
mrl: boolean,
filteredOut: boolean,
_rowData: any,
_: number
) {
const result = new Set(['igx-grid__tr', index % 2 ? row.grid.evenRowCSS : row.grid.oddRowCSS]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6796,14 +6796,12 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements

protected _shouldAutoSize(renderedHeight) {
this.tbody.nativeElement.style.display = 'none';
let res = !this.nativeElement.parentElement ||
const res = !this.nativeElement.parentElement ||
this.nativeElement.parentElement.clientHeight === 0 ||
this.nativeElement.parentElement.clientHeight === renderedHeight;
if (!this.platform.isChromium && !this.platform.isFirefox) {
this.nativeElement.parentElement.clientHeight === renderedHeight ||
// If grid causes the parent container to extend (for example when container is flex)
// we should always auto-size since the actual size of the container will continuously change as the grid renders elements.
res = this.checkContainerSizeChange();
}
this.checkContainerSizeChange();
this.tbody.nativeElement.style.display = '';
return res;
}
Expand Down
15 changes: 15 additions & 0 deletions projects/igniteui-angular/src/lib/grids/grid/column-group.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,21 @@ describe('IgxGrid - multi-column headers #grid', () => {
expect(grid.columnList.length).toEqual(10);
});

it('There shouldn\'t be any errors when the grid is grouped by a column that isn\'t defined', () => {
fixture = TestBed.createComponent(ColumnGroupTestComponent);
fixture.componentInstance.hideGroupedColumns = true;
fixture.detectChanges();
grid = fixture.componentInstance.grid;

expect(() => {
grid.groupBy({
fieldName: 'NonExistentFieldName', dir: SortingDirection.Desc, ignoreCase: false,
strategy: DefaultSortingStrategy.instance()
});
fixture.detectChanges();
}).not.toThrow();
});

it('should set title attribute on column group header spans', () => {
fixture = TestBed.createComponent(ColumnGroupTestComponent);
fixture.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ describe('IgxGrid - Filtering actions #grid', () => {
const today = SampleTestData.todayFullDate;

// Equals 11:15:35
grid.filter('ReleaseDate', cal.timedelta(today, 'hour', 1),
grid.filter('ReleaseDateTime', cal.timedelta(today, 'hour', 1),
IgxDateTimeFilteringOperand.instance().condition('equals'));
fix.detectChanges();
expect(grid.rowList.length).toEqual(1);

// Does not equal 11:15:35
grid.filter('ReleaseDate', cal.timedelta(today, 'hour', 1),
grid.filter('ReleaseDateTime', cal.timedelta(today, 'hour', 1),
IgxDateTimeFilteringOperand.instance().condition('doesNotEqual'));
fix.detectChanges();
expect(grid.rowList.length).toEqual(7);
Expand Down Expand Up @@ -513,6 +513,7 @@ describe('IgxGrid - Filtering actions #grid', () => {
fix.detectChanges();
expect(grid.rowList.length).toEqual(1);
}));

it('should correctly filter by \'date\' filtering conditions when dates are ISO 8601 strings', fakeAsync(() => {
const cal = SampleTestData.timeGenerator;
const today = SampleTestData.today;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ describe('IgxGrid - Row Editing #grid', () => {
row.delete();
fix.detectChanges();
expect(grid.rowEditingOverlay.collapsed).toBeTruthy();
expect(grid.gridAPI.crudService.endEdit).toHaveBeenCalledTimes(2);
expect(grid.gridAPI.crudService.endEdit).toHaveBeenCalledTimes(1);
expect(grid.gridAPI.crudService.endEdit).toHaveBeenCalledWith(true);
});
});
Expand Down Expand Up @@ -2092,7 +2092,7 @@ describe('IgxGrid - Row Editing #grid', () => {

fix.componentInstance.buttons.last.element.nativeElement.click();
expect(grid.gridAPI.crudService.endEdit).toHaveBeenCalled();
expect(grid.gridAPI.crudService.endEdit).toHaveBeenCalledTimes(2);
expect(grid.gridAPI.crudService.endEdit).toHaveBeenCalledTimes(1);
}));

it('Empty template', fakeAsync(/** height/width setter rAF */() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@
</ng-container>
<ng-template #record_template let-rowIndex="index" let-rowData let-disabledRow="disabled">
<igx-grid-row [gridID]="id" [index]="rowIndex" [rowData]="rowData" [disabled]="disabledRow"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:pipeTrigger"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:rowData:pipeTrigger"
[ngStyle]="rowStyles | igxGridRowStyles:rowData:rowIndex:pipeTrigger" #row>
</igx-grid-row>
</ng-template>
<ng-template #pinned_record_template let-rowIndex="index" let-rowData>
<igx-grid-row [gridID]="id" [index]="rowIndex" [rowData]="rowData"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:pipeTrigger"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:rowData:pipeTrigger"
[ngStyle]="rowStyles | igxGridRowStyles:rowData:rowIndex:pipeTrigger"#row #pinnedRow>
</igx-grid-row>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,9 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
if (changes && this.columnList.length > 0) {
changes.forEachAddedItem((rec) => {
const col = this.getColumnByName(rec.item.fieldName);
col.hidden = true;
if (col) {
col.hidden = true;
}
});
changes.forEachRemovedItem((rec) => {
const col = this.getColumnByName(rec.item.fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ export class IgxGroupByMetaPipe implements PipeTransform {

public transform(key: string, grid: GridType) {
const column = grid.getColumnByName(key);
return { groupable: column.groupable, title: column.header || key };
return { groupable: !!column?.groupable, title: column?.header || key };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
</ng-template>
<ng-template #hierarchical_record_template let-rowIndex="index" let-disabledRow="disabled" let-rowData>
<igx-hierarchical-grid-row [gridID]="id" [index]="rowIndex" [disabled]="disabledRow" [rowData]="rowData"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:pipeTrigger"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:rowData:pipeTrigger"
[ngStyle]="rowStyles | igxGridRowStyles:rowData:rowIndex:pipeTrigger" #row>
</igx-hierarchical-grid-row>
</ng-template>

<ng-template #pinned_hierarchical_record_template let-rowIndex="index" let-rowData>
<igx-hierarchical-grid-row [gridID]="id" [index]="rowIndex" [rowData]="rowData"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:pipeTrigger"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:false:rowData:pipeTrigger"
[ngStyle]="rowStyles | igxGridRowStyles:rowData:rowIndex:pipeTrigger" #row #pinnedRow>
</igx-hierarchical-grid-row>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@
<ng-container *ngTemplateOutlet="hasPinnedRecords && !isRowPinningToTop ? pinnedRecordsTemplate : null"></ng-container>
<ng-template #record_template let-rowIndex="index" let-disabledRow="disabled" let-rowData>
<igx-tree-grid-row [gridID]="id" [index]="rowIndex" [treeRow]="rowData" [disabled]="disabledRow"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:row.treeRow.isFilteredOutParent:pipeTrigger"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:row.treeRow.isFilteredOutParent:rowData:pipeTrigger"
[ngStyle]="rowStyles | igxGridRowStyles:rowData:rowIndex:pipeTrigger" #row>
</igx-tree-grid-row>
</ng-template>
<ng-template #pinned_record_template let-rowIndex="index" let-rowData>
<igx-tree-grid-row [gridID]="id" [index]="rowIndex" [treeRow]="rowData"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:row.treeRow.isFilteredOutParent:pipeTrigger"
[ngClass]="rowClasses | igxGridRowClasses:row:row.inEditMode:row.selected:row.dirty:row.deleted:row.dragging:rowIndex:hasColumnLayouts:row.treeRow.isFilteredOutParent:rowData:pipeTrigger"
[ngStyle]="rowStyles | igxGridRowStyles:rowData:rowIndex:pipeTrigger"#row #pinnedRow>
</igx-tree-grid-row>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ng-content select="igx-hint, [igxHint]"></ng-content>
</ng-container>

<input #comboInput igxInput [value]="value" (input)="handleInputChange($event)" (keyup)="handleKeyUp($event)"
<input #comboInput igxInput [value]="value" (focus)="onFocus()" (input)="handleInputChange($event)" (keyup)="handleKeyUp($event)"
(keydown)="handleKeyDown($event)" (blur)="onBlur()" [attr.placeholder]="placeholder" aria-autocomplete="both"
[attr.aria-owns]="dropdown.id" [attr.aria-labelledby]="ariaLabelledBy" [disabled]="disabled"
[igxTextSelection]="!composing" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
super.onBlur();
}

/** @hidden @internal */
public onFocus(): void {
this._internalFilter = this.comboInput.value || '';
}

/** @hidden @internal */
public getEditElement(): HTMLElement {
return this.comboInput.nativeElement;
Expand Down

0 comments on commit 3a6d0dd

Please sign in to comment.