Skip to content

Commit 125d1e1

Browse files
authored
Merge branch '9.1.x' into ddincheva/clipboardIE-9.1
2 parents 6e1e2ed + 3218448 commit 125d1e1

File tree

5 files changed

+166
-20
lines changed

5 files changed

+166
-20
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

@@ -294,6 +296,11 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
294296
@Output()
295297
public onRightButtonSelect = new EventEmitter<IDialogEventArgs>();
296298

299+
/**
300+
* @hidden
301+
*/
302+
@Output() public isOpenChange = new EventEmitter<boolean>();
303+
297304
private _positionSettings: PositionSettings = {
298305
openAnimation: useAnimation(slideInBottom, { params: { fromPosition: 'translateY(100%)' } }),
299306
closeAnimation: useAnimation(slideOutTop, { params: { toPosition: 'translateY(-100%)' } })
@@ -336,19 +343,37 @@ export class IgxDialogComponent implements IToggleView, OnInit, OnDestroy, After
336343
}
337344

338345
/**
339-
* Returns whether the dialog is visible to the end user.
346+
* State of the dialog.
347+
*
340348
* ```typescript
341-
* @ViewChild("MyDialog")
342-
* public dialog: IgxDialogComponent;
343-
* ngAfterViewInit() {
344-
* let dialogOpen = this.dialog.isOpen;
345-
* }
349+
* // get
350+
* let dialogIsOpen = this.dialog.isOpen;
351+
* ```
352+
*
353+
* ```html
354+
* <!--set-->
355+
* <igx-dialog [isOpen]='false'></igx-dialog>
356+
* ```
357+
*
358+
* Two-way data binding.
359+
* ```html
360+
* <!--set-->
361+
* <igx-dialog [(isOpen)]='model.isOpen'></igx-dialog>
346362
* ```
347363
*/
348364
@Input()
349-
get isOpen() {
365+
public get isOpen() {
350366
return !this.toggleRef.collapsed;
351367
}
368+
public set isOpen(value: boolean) {
369+
370+
this.isOpenChange.emit(value);
371+
if (value) {
372+
this.open();
373+
} else {
374+
this.close();
375+
}
376+
}
352377

353378
@HostBinding('class.igx-dialog--hidden')
354379
get isCollapsed() {

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
155155
requestAnimationFrame(() => {
156156
this.isColumnPinnable = this.column.pinnable;
157157
if (!(this.cdr as ViewRef).destroyed) {
158-
this.cdr.detectChanges();
158+
this.cdr.detectChanges();
159159
}
160160
});
161161
});
@@ -528,20 +528,20 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
528528
private areExpressionsSelectable () {
529529
if (this.expressionsList.length === 1 &&
530530
(this.expressionsList[0].expression.condition.name === 'equals' ||
531-
this.expressionsList[0].expression.condition.name === 'true' ||
532-
this.expressionsList[0].expression.condition.name === 'false' ||
533-
this.expressionsList[0].expression.condition.name === 'empty' ||
534-
this.expressionsList[0].expression.condition.name === 'in')) {
531+
this.expressionsList[0].expression.condition.name === 'true' ||
532+
this.expressionsList[0].expression.condition.name === 'false' ||
533+
this.expressionsList[0].expression.condition.name === 'empty' ||
534+
this.expressionsList[0].expression.condition.name === 'in')) {
535535
return true;
536536
}
537537

538538
const selectableExpressionsCount = this.expressionsList.filter(exp =>
539539
(exp.beforeOperator === 1 || exp.afterOperator === 1) &&
540540
(exp.expression.condition.name === 'equals' ||
541-
exp.expression.condition.name === 'true' ||
542-
exp.expression.condition.name === 'false' ||
543-
exp.expression.condition.name === 'empty' ||
544-
exp.expression.condition.name === 'in')).length;
541+
exp.expression.condition.name === 'true' ||
542+
exp.expression.condition.name === 'false' ||
543+
exp.expression.condition.name === 'empty' ||
544+
exp.expression.condition.name === 'in')).length;
545545

546546
return selectableExpressionsCount === this.expressionsList.length;
547547
}
@@ -581,7 +581,12 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
581581
this.excelStyleSearch.isLoading = true;
582582
const expressionsTree: FilteringExpressionsTree = this.getColumnFilterExpressionsTree();
583583

584+
const prevColumn = this.column;
584585
this.grid.uniqueColumnValuesStrategy(this.column, expressionsTree, (colVals: any[]) => {
586+
if (!this.column || this.column !== prevColumn) {
587+
return;
588+
}
589+
585590
const columnValues = (this.column.dataType === DataType.Date) ?
586591
colVals.map(val => val ? val.toDateString() : val) : colVals;
587592

@@ -618,7 +623,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
618623
if (this.column.dataType === DataType.String && this.column.filteringIgnoreCase) {
619624
const filteredUniqueValues = columnValues.map(s => s?.toString().toLowerCase())
620625
.reduce((map, val, i) => map.get(val) ? map : map.set(val, columnValues[i]),
621-
new Map);
626+
new Map);
622627

623628
this.uniqueValues = Array.from(filteredUniqueValues.values());
624629
} else {
@@ -993,6 +998,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy {
993998
*/
994999
public clearFilter() {
9951000
this.filteringService.clearFilter(this.column.field);
1001+
this.excelStyleSearch.clearInput();
9961002
this.selectAllFilterItems();
9971003
}
9981004

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: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4369,6 +4369,49 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
43694369
expect(listItems[3].innerText).toBe('custoM', 'incorrect list item label');
43704370
expect(listItems[4].innerText).toBe('custom', 'incorrect list item label');
43714371
}));
4372+
4373+
it('Should clear search criteria when selecting clear column filters option.', fakeAsync(() => {
4374+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4375+
4376+
let checkboxes: any = Array.from(GridFunctions.getExcelStyleFilteringCheckboxes(fix));
4377+
4378+
tick(100);
4379+
fix.detectChanges();
4380+
4381+
checkboxes[0].click();
4382+
tick();
4383+
fix.detectChanges();
4384+
4385+
checkboxes[2].click();
4386+
tick();
4387+
fix.detectChanges();
4388+
4389+
GridFunctions.clickApplyExcelStyleFiltering(fix);
4390+
tick(100);
4391+
fix.detectChanges();
4392+
4393+
expect(grid.filteredData.length).toEqual(1);
4394+
4395+
GridFunctions.clickExcelFilterIconFromCode(fix, grid, 'ProductName');
4396+
4397+
let inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4398+
UIInteractions.clickAndSendInputElementValue(inputNativeElement, 'Net', fix);
4399+
4400+
const listItems = GridFunctions.getExcelStyleSearchComponentListItems(fix);
4401+
expect(listItems.length).toBe(2, 'incorrect rendered list items count');
4402+
4403+
GridFunctions.clickClearFilterInExcelStyleFiltering(fix);
4404+
fix.detectChanges();
4405+
flush();
4406+
4407+
expect(grid.filteredData).toBeNull();
4408+
4409+
inputNativeElement = GridFunctions.getExcelStyleSearchComponentInput(fix);
4410+
expect(inputNativeElement.value).toBe('', 'search criteria is not cleared');
4411+
4412+
checkboxes = Array.from(GridFunctions.getExcelStyleFilteringCheckboxes(fix));
4413+
expect(checkboxes.every(ch => ch.checked)).toBeTrue();
4414+
}));
43724415
});
43734416

43744417
describe(null, () => {
@@ -4468,6 +4511,17 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
44684511
loadingIndicator = GridFunctions.getExcelFilteringLoadingIndicator(fix);
44694512
expect(loadingIndicator).toBeNull('esf loading indicator is visible');
44704513
}));
4514+
4515+
it('Should not execute done callback for null column', fakeAsync(() => {
4516+
const compInstance = fix.componentInstance as IgxGridFilteringESFLoadOnDemandComponent;
4517+
GridFunctions.clickExcelFilterIcon(fix, 'ProductName');
4518+
fix.detectChanges();
4519+
4520+
expect(() => {
4521+
GridFunctions.clickExcelFilterIcon(fix, 'Downloads');
4522+
tick(2000);
4523+
}).not.toThrowError(/\'dataType\' of null/);
4524+
}));
44714525
});
44724526

44734527
describe(null, () => {
@@ -4616,7 +4670,6 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
46164670
GridSelectionFunctions.verifyColumnAndCellsSelected(columnId, false);
46174671

46184672
});
4619-
46204673
});
46214674
});
46224675

0 commit comments

Comments
 (0)