Skip to content

Commit 9477400

Browse files
authored
Merge branch '10.1.x' into ddincheva/clipboardIE-10.1
2 parents 53b2420 + 694c029 commit 9477400

File tree

6 files changed

+198
-21
lines changed

6 files changed

+198
-21
lines changed

projects/igniteui-angular/src/lib/dialog/dialog.component.spec.ts

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ describe('Dialog', () => {
2626
CustomTemplates1DialogComponent,
2727
CustomTemplates2DialogComponent,
2828
DialogSampleComponent,
29-
PositionSettingsDialogComponent
29+
PositionSettingsDialogComponent,
30+
DialogTwoWayDataBindingComponent
3031
],
3132
imports: [BrowserAnimationsModule, NoopAnimationsModule, IgxDialogModule]
3233
}).compileComponents();
@@ -80,6 +81,41 @@ describe('Dialog', () => {
8081
expect(messageDebugElement.nativeElement.textContent.trim()).toEqual(expectedMessage);
8182
});
8283

84+
it('Should open and close dialog when set values to IsOpen', fakeAsync(() => {
85+
const fixture = TestBed.createComponent(AlertComponent);
86+
const dialog = fixture.componentInstance.dialog;
87+
const expectedMessage = 'message';
88+
89+
dialog.isOpen = true;
90+
tick();
91+
fixture.detectChanges();
92+
expect(dialog.isOpen).toEqual(true);
93+
94+
dialog.close();
95+
tick();
96+
fixture.detectChanges();
97+
expect(dialog.isOpen).toEqual(false);
98+
}));
99+
100+
it('Should open and close dialog with isOpen two way data binding', fakeAsync(() => {
101+
const fixture = TestBed.createComponent(DialogTwoWayDataBindingComponent);
102+
const dialog = fixture.componentInstance.dialog;
103+
fixture.detectChanges();
104+
105+
fixture.componentInstance.myDialog = true;
106+
107+
fixture.detectChanges();
108+
tick();
109+
expect(dialog.isOpen).toEqual(true);
110+
111+
112+
fixture.componentInstance.myDialog = false;
113+
114+
fixture.detectChanges();
115+
tick();
116+
expect(dialog.isOpen).toEqual(false);
117+
}));
118+
83119
it('Should set custom modal message.', () => {
84120
const fixture = TestBed.createComponent(CustomDialogComponent);
85121
const dialog = fixture.componentInstance.dialog;
@@ -310,6 +346,7 @@ describe('Dialog', () => {
310346
dialog.open();
311347
tick(100);
312348
fix.detectChanges();
349+
tick(100);
313350

314351
// Verify dialog is opened and its default right button is focused
315352
const dialogDOM = fix.debugElement.query(By.css('.igx-dialog'));
@@ -436,6 +473,28 @@ class AlertComponent {
436473
class DialogComponent {
437474
@ViewChild('dialog', { static: true }) public dialog: IgxDialogComponent;
438475
}
476+
477+
@Component({
478+
template: `<div #wrapper>
479+
<igx-dialog #dialog title="dialog" message="message"
480+
[(isOpen)]="myDialog"
481+
leftButtonLabel="left button"
482+
leftButtonType="raised"
483+
leftButtonColor="black"
484+
leftButtonBackgroundColor="darkblue"
485+
leftButtonRipple="pink"
486+
rightButtonLabel="right button"
487+
rightButtonType="raised"
488+
rightButtonColor="orange"
489+
rightButtonBackgroundColor="lightblue"
490+
rightButtonRipple="white">
491+
</igx-dialog>
492+
</div>` })
493+
class DialogTwoWayDataBindingComponent {
494+
@ViewChild('dialog', { static: true }) public dialog: IgxDialogComponent;
495+
public myDialog = false;
496+
}
497+
439498
@Component({
440499
template: `<div #wrapper>
441500
<igx-dialog #dialog

projects/igniteui-angular/src/lib/dialog/dialog.component.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
5858
private static NEXT_ID = 1;
5959
private static readonly DIALOG_CLASS = 'igx-dialog';
6060

61+
62+
6163
@ViewChild(IgxToggleDirective, { static: true })
6264
public toggleRef: IgxToggleDirective;
6365

@@ -316,6 +318,11 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
316318
@Output()
317319
public onRightButtonSelect = new EventEmitter<IDialogEventArgs>();
318320

321+
/**
322+
* @hidden
323+
*/
324+
@Output() public isOpenChange = new EventEmitter<boolean>();
325+
319326
private _positionSettings: PositionSettings = {
320327
openAnimation: useAnimation(slideInBottom, { params: { fromPosition: 'translateY(100%)' } }),
321328
closeAnimation: useAnimation(slideOutTop, { params: { toPosition: 'translateY(-100%)' } })
@@ -359,19 +366,37 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
359366
}
360367

361368
/**
362-
* Returns whether the dialog is visible to the end user.
369+
* State of the dialog.
370+
*
363371
* ```typescript
364-
* @ViewChild("MyDialog")
365-
* public dialog: IgxDialogComponent;
366-
* ngAfterViewInit() {
367-
* let dialogOpen = this.dialog.isOpen;
368-
* }
372+
* // get
373+
* let dialogIsOpen = this.dialog.isOpen;
374+
* ```
375+
*
376+
* ```html
377+
* <!--set-->
378+
* <igx-dialog [isOpen]='false'></igx-dialog>
379+
* ```
380+
*
381+
* Two-way data binding.
382+
* ```html
383+
* <!--set-->
384+
* <igx-dialog [(isOpen)]='model.isOpen'></igx-dialog>
369385
* ```
370386
*/
371387
@Input()
372-
get isOpen() {
388+
public get isOpen() {
373389
return !this.toggleRef.collapsed;
374390
}
391+
public set isOpen(value: boolean) {
392+
393+
this.isOpenChange.emit(value);
394+
if (value) {
395+
this.open();
396+
} else {
397+
this.close();
398+
}
399+
}
375400

376401
@HostBinding('class.igx-dialog--hidden')
377402
get isCollapsed() {

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-search.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
129129
esf.columnChange.pipe(takeUntil(this.destroy$)).subscribe(() => {
130130
this.virtDir.resetScrollPosition();
131131
});
132+
133+
esf.listDataLoaded.pipe(takeUntil(this.destroy$)).subscribe(() => {
134+
if (this.searchValue) {
135+
this.clearInput();
136+
}
137+
});
132138
}
133139

134140
public ngAfterViewInit() {

projects/igniteui-angular/src/lib/grids/filtering/excel-style/grid.excel-style-filtering.component.ts

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
125125
this._columnPinning = this.grid.onColumnPinning.pipe(takeUntil(this.destroy$)).subscribe(() => {
126126
requestAnimationFrame(() => {
127127
if (!(this.cdr as ViewRef).destroyed) {
128-
this.cdr.detectChanges();
128+
this.cdr.detectChanges();
129129
}
130130
});
131131
});
@@ -189,7 +189,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
189189
*/
190190
@Input()
191191
get minHeight(): string {
192-
if (this._minHeight || this._minHeight === 0) {
192+
if (this._minHeight || this._minHeight === 0) {
193193
return this._minHeight;
194194
}
195195

@@ -284,6 +284,12 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
284284
@Output()
285285
public columnChange = new EventEmitter<IgxColumnComponent>();
286286

287+
/**
288+
* @hidden @internal
289+
*/
290+
@Output()
291+
public listDataLoaded = new EventEmitter();
292+
287293
/**
288294
* @hidden @internal
289295
*/
@@ -406,20 +412,20 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
406412
private areExpressionsSelectable () {
407413
if (this.expressionsList.length === 1 &&
408414
(this.expressionsList[0].expression.condition.name === 'equals' ||
409-
this.expressionsList[0].expression.condition.name === 'true' ||
410-
this.expressionsList[0].expression.condition.name === 'false' ||
411-
this.expressionsList[0].expression.condition.name === 'empty' ||
412-
this.expressionsList[0].expression.condition.name === 'in')) {
415+
this.expressionsList[0].expression.condition.name === 'true' ||
416+
this.expressionsList[0].expression.condition.name === 'false' ||
417+
this.expressionsList[0].expression.condition.name === 'empty' ||
418+
this.expressionsList[0].expression.condition.name === 'in')) {
413419
return true;
414420
}
415421

416422
const selectableExpressionsCount = this.expressionsList.filter(exp =>
417423
(exp.beforeOperator === 1 || exp.afterOperator === 1) &&
418424
(exp.expression.condition.name === 'equals' ||
419-
exp.expression.condition.name === 'true' ||
420-
exp.expression.condition.name === 'false' ||
421-
exp.expression.condition.name === 'empty' ||
422-
exp.expression.condition.name === 'in')).length;
425+
exp.expression.condition.name === 'true' ||
426+
exp.expression.condition.name === 'false' ||
427+
exp.expression.condition.name === 'empty' ||
428+
exp.expression.condition.name === 'in')).length;
423429

424430
return selectableExpressionsCount === this.expressionsList.length;
425431
}
@@ -459,7 +465,12 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
459465
this.loadingStart.emit();
460466
const expressionsTree: FilteringExpressionsTree = this.getColumnFilterExpressionsTree();
461467

468+
const prevColumn = this.column;
462469
this.grid.uniqueColumnValuesStrategy(this.column, expressionsTree, (colVals: any[]) => {
470+
if (!this.column || this.column !== prevColumn) {
471+
return;
472+
}
473+
463474
const columnValues = (this.column.dataType === DataType.Date) ?
464475
colVals.map(val => val ? val.toDateString() : val) : colVals;
465476

@@ -496,7 +507,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
496507
if (this.column.dataType === DataType.String && this.column.filteringIgnoreCase) {
497508
const filteredUniqueValues = columnValues.map(s => s?.toString().toLowerCase())
498509
.reduce((map, val, i) => map.get(val) ? map : map.set(val, columnValues[i]),
499-
new Map);
510+
new Map);
500511

501512
this.uniqueValues = Array.from(filteredUniqueValues.values());
502513
} else {
@@ -549,6 +560,8 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
549560
if (!(this.cdr as any).destroyed) {
550561
this.cdr.detectChanges();
551562
}
563+
564+
this.listDataLoaded.emit();
552565
}
553566

554567
private getColumnFilterExpressionsTree() {

projects/igniteui-angular/src/lib/grids/grid/grid-cell-selection.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,8 @@ describe('IgxGrid - Cell selection #grid', () => {
12951295
UIInteractions.triggerKeyDownEvtUponElem('arrowright', firstCell.nativeElement, true, false, true, true);
12961296
await wait(100);
12971297
fix.detectChanges();
1298+
await wait(50);
1299+
fix.detectChanges();
12981300

12991301
expect(selectionChangeSpy).toHaveBeenCalledTimes(1);
13001302
GridSelectionFunctions.verifySelectedRange(grid, 4, 4, 2, 5);
@@ -1332,14 +1334,15 @@ describe('IgxGrid - Cell selection #grid', () => {
13321334
const selectionChangeSpy = spyOn<any>(grid.onRangeSelection, 'emit').and.callThrough();
13331335

13341336
UIInteractions.simulateClickAndSelectEvent(firstCell);
1337+
await wait();
13351338
fix.detectChanges();
13361339

13371340
expect(selectionChangeSpy).toHaveBeenCalledTimes(0);
13381341
GridSelectionFunctions.verifyCellSelected(firstCell);
13391342
expect(grid.selectedCells.length).toBe(1);
13401343

13411344
UIInteractions.triggerKeyDownEvtUponElem('end', firstCell.nativeElement, true, false, true, true);
1342-
await wait(100);
1345+
await wait(200);
13431346
fix.detectChanges();
13441347

13451348
expect(selectionChangeSpy).toHaveBeenCalledTimes(1);

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-ui.spec.ts

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4213,6 +4213,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
42134213

42144214
it('Should correctly update all items based on \'SelectAll\' checkbox.', fakeAsync(() => {
42154215
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4216+
flush();
42164217

42174218
const visibleListItems = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
42184219
const dataListItems = visibleListItems.slice(1, visibleListItems.length);
@@ -4245,6 +4246,7 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
42454246

42464247
it('Should correctly update all \'SelectAll\' checkbox when not a single item is checked.', fakeAsync(() => {
42474248
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Released');
4249+
flush();
42484250

42494251
const visibleListItems = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
42504252
expect(visibleListItems.length).toBe(4);
@@ -4377,6 +4379,48 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
43774379
expect(listItems[3].innerText).toBe('custoM', 'incorrect list item label');
43784380
expect(listItems[4].innerText).toBe('custom', 'incorrect list item label');
43794381
}));
4382+
4383+
it('Should clear search criteria when selecting clear column filters option.', fakeAsync(() => {
4384+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4385+
4386+
let checkboxes = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
4387+
fix.detectChanges();
4388+
4389+
checkboxes[0].click();
4390+
tick();
4391+
fix.detectChanges();
4392+
4393+
checkboxes[2].click();
4394+
tick();
4395+
fix.detectChanges();
4396+
4397+
GridFunctions.clickApplyExcelStyleFiltering(fix);
4398+
tick();
4399+
fix.detectChanges();
4400+
expect(grid.filteredData.length).toEqual(1);
4401+
4402+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4403+
flush();
4404+
4405+
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4406+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, 'Net', fix);
4407+
4408+
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
4409+
expect(listItems.length).toBe(2, 'incorrect rendered list items count');
4410+
4411+
GridFunctions.clickClearFilterInExcelStyleFiltering(fix);
4412+
flush();
4413+
expect(grid.filteredData).toBeNull();
4414+
4415+
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4416+
expect(inputNativeElement.value).toBe('', 'search criteria is not cleared');
4417+
4418+
checkboxes = GridFunctions.getExcelStyleFilteringCheckboxes(fix);
4419+
const listItemsCheckboxes = checkboxes.slice(1, checkboxes.length);
4420+
for (const checkbox of listItemsCheckboxes) {
4421+
ControlsFunction.verifyCheckboxState(checkbox.parentElement);
4422+
}
4423+
}));
43804424
});
43814425

43824426
describe('Templates: ', () => {
@@ -4527,6 +4571,23 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
45274571
GridSelectionFunctions.verifyColumnAndCellsSelected(columnId, false);
45284572

45294573
});
4574+
4575+
it('Should reset esf menu with templates on column change', fakeAsync(() => {
4576+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'Downloads');
4577+
flush();
4578+
4579+
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4580+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, 20, fix);
4581+
4582+
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
4583+
expect(listItems.length).toBe(2, 'incorrect rendered list items count');
4584+
4585+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4586+
flush();
4587+
4588+
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4589+
expect(inputNativeElement.value).toBe('', 'input value didn\'t reset');
4590+
}));
45304591
});
45314592

45324593
describe('Load values on demand', () => {
@@ -4581,6 +4642,17 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
45814642
loadingIndicator = GridFunctions.getExcelFilteringLoadingIndicator(fix);
45824643
expect(loadingIndicator).toBeNull('esf loading indicator is visible');
45834644
}));
4645+
4646+
it('Should not execute done callback for null column', fakeAsync(() => {
4647+
const compInstance = fix.componentInstance as IgxGridFilteringESFLoadOnDemandComponent;
4648+
GridFunctions.clickExcelFilterIcon(fix, 'ProductName');
4649+
fix.detectChanges();
4650+
4651+
expect(() => {
4652+
GridFunctions.clickExcelFilterIcon(fix, 'Downloads');
4653+
tick(2000);
4654+
}).not.toThrowError(/\'dataType\' of null/);
4655+
}));
45844656
});
45854657

45864658
describe(null, () => {
@@ -4729,7 +4801,6 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
47294801
GridSelectionFunctions.verifyColumnAndCellsSelected(columnId, false);
47304802

47314803
});
4732-
47334804
});
47344805
});
47354806

0 commit comments

Comments
 (0)